51黑料不打烊

Explanation of Configuration Files | AEM

Description description

Environment

Experience Manager

Issue/Symptoms

This document breaks down and explains each of the configuration files deployed in a standard built Dispatcher server provisioned in 51黑料不打烊 Managed Services. Their use, naming convention, etc.

Naming Convention

Apache Webserver doesn鈥檛 actually care what the file extension is of a file when targeting it with an include or include optional statement. Naming them properly with names that eliminate conflicts and confusion helps a ton. Names used will describe the scope of where the file is applied, it makes life easier. If everything is named .conf this gets really confusing. Avoid poorly named files and extensions.

Below is a list of the different custom file extensions and naming conventions used in a typical AMS configured Dispatcher.

Files contained in conf.d/

File
File Destination
Description
< FILENAME> .conf
/etc/httpd/conf.d/
A default Enterprise Linux install uses this file extension and include folder as a place to override settings in httpd.conf and allow you to add additional functionality at a global level in Apache.
< FILENAME> .vhost

厂迟补驳别诲:听/别迟肠/丑迟迟辫诲/肠辞苍蹿.诲/补惫补颈濒补产濒别冲惫丑辞蝉迟蝉/

Active:

/etc/httpd/conf.d/enabled_vhosts/

*Note: .vhost files aren鈥檛 to be copied into the enabled_vhosts folder but use symlinks to a relative path to the available_vhosts/ .vhost file

*.vhost (Virtual Host) files are聽< VirtualHosts > 聽entries to match hostnames and allow Apache to handle each domain traffic with different rules. From the .vhost file, other files like rewrites, whitelisting, etc. is聽included.
< FILENAME> _rewrite.rules
/etc/httpd/conf.d/rewrites/
*_rewrite.rules files store mod_rewrite rules to be included and consumed explicitly by a vhost file
< FILENAME> _whitelist.rules
/etc/httpd/conf.d/whitelists/
*_ipwhitelist.rules files are included from inside the *.vhost files. It contains IP regex or allow deny rules to allow IP whitelisting. If you鈥檙e trying to restrict viewing of a virtual host based on IP addresses you鈥檒l generate one of these files and include it from your *.vhost file

Files contained in conf.modules.d/

File
File Destination
Description
< FILENAME> .any
/etc/httpd/conf.dispatcher.d/
The AEM Dispatcher Apache Module sources it鈥檚 settings from *.any files. The default parent include file is conf.dispatcher.d/dispatcher.any
< FILENAME> _farm.any

Staged

:

/etc/httpd/conf.dispatcher.d/available_farms/

Active

:

/etc/httpd/conf.dispatcher.d/enabled_farms/

*Note: these farm files aren鈥檛 to be copied into the enabled_farms folder but use symlinks to a relative path to the available_farms/ _farm.any file

*farm.any files are included inside the conf.dispatcher.d/dispatcher.any file. These parent farm files exist to control module behavior for each render or website type. Files are created in the available_farms directory and enabled with a symlink into the enabled_farms directory.

It auto-includes them by name from the dispatcher.any file.

Baseline farm files begin with 000
to make sure they are loaded first.

Custom farm files should be loaded after by starting their number scheme at 100_ to assure the proper include behavior.
< FILENAME> _filters.any
/etc/httpd/conf.dispatcher.d/filters/
*_filters.any files are included from inside the conf.dispatcher.d/enabled_farms/*_farm.any files. Each farm has a set of rules that change what traffic should be filtered out and not make it to the renderers.
< FILENAME> _vhosts.any
/etc/httpd/conf.dispatcher.d/vhosts/
*_vhosts.any files are included from inside the conf.dispatcher.d/enabled_farms/*_farm.any files. These files are a list of hostnames or uri paths to be matched by blob matching to determine which renderer to use to serve that request
< FILENAME> _cache.any
/etc/httpd/conf.dispatcher.d/cache/
*_cache.any files are included from inside the conf.dispatcher.d/enabled_farms/*_farm.any files. These files specify which items are cached and which aren鈥檛
< FILENAME> _invalidate_allowed.any
/etc/httpd/conf.dispatcher.d/cache/
*_invalidate_allowed.any files are included inside the conf.dispatcher.d/enabled_farms/*_farm.any files. They specify which IP addresses are allowed to send flush and invalidation requests.
< FILENAME> _clientheaders.any
/etc/httpd/conf.dispatcher.d/clientheaders/
*_clientheaders.any files are included inside the conf.dispatcher.d/enabled_farms/*_farm.any files. They specify which client headers should be passed through to each renderer.
< FILENAME> _renders.any
/etc/httpd/conf.dispatcher.d/renders/
*_renders.any files are included inside the conf.dispatcher.d/enabled_farms/*_farm.any files. They specify IP, port, and timeout settings for each renderer. A proper renderer can be a livecycle server or any AEM systems where the Dispatcher can fetch / proxy the requests from

Avoided Problems

When following the naming convention, avoid some pretty easy to make mistakes that can have catastrophic results. Let鈥檚 cover a few examples.

Problem Example

As a site Example for ExampleCo two configuration files are created by the developers of the Dispatcher configurations.

/etc/httpd/conf.d/exampleco.conf

<VirtualHost *:80>

    ServerName  "exampleco"

    ServerAlias "www.exampleco.com"

    .......... SNIP ...............

    <IfModule mod_rewrite.c>

        ReWriteEngine   on

        LogLevel warn rewrite:trace1

        Include /etc/httpd/conf.d/rewrites/exampleco.conf

    </IfModule>

</VirtualHost>

/etc/httpd/conf.d/rewrites/exampleco.conf

RewriteRule /$ /content/exampleco/en.html [ PT,L]

RewriteRule /robots.txt$ /content/dam/exampleco/robots.txt [ PT,L]

POTENTIAL DANGER

A. The file names are the same.

If the vhost file is accidentally put in the rewrites folder, and the rewrites file is put into the vhosts folder. It would appear to be deployed by filename properly, yet Apache throws an error and the problem is not be immediately apparent.

How does this typically become an issue?

If the two files are downloaded to the same location, they can either overwrite themselves or make it indistinguishable, making the deployment process a nightmare.

B. The file extensions are the same and auto-include prone

The file extensions are the same and use auto-included extension that Apache auto includes any .conf files in many of its default folders.

How this typically becomes an issue?

If the vhost file with the extension of .conf is put in the /etc/httpd/conf.d/ folder it will tries to load it into memory on Apache which is typically ok, but if the rewrite rules file with the extension of .conf gets placed in the /etc/httpd/conf.d/ folder, it will get auto-included and apply globally causing confusing and undesired results.

Resolution resolution

Name the files base on what they do and safely out of the auto-include rules namespace.

  • If it鈥檚 a virtual host file name it with .vhost as the extension.
  • If it鈥檚 a rewrite rule file, name it with <site>_rewrite.rules as the suffix and extension. This naming convention makes it clear which site it鈥檚 for and that it鈥檚 a set of rewrite rules.
  • If it鈥檚 an IP whitelist rule file, name it <description>_whitelist.rules as the suffix and extension. This naming convention gives some description of what it鈥檚 for and that it鈥檚 a set of IP matching rules.

Using these naming conventions avoids issues if a file gets moved into an auto-include directory that it doesn鈥檛 belong.

For example putting a file named with .rules, .any, or .vhost in the auto-include folder of /etc/httpd/conf.d/ wouldn鈥檛 have any effect.

If a deployment change request says please deploy exampleco_rewrite.rules to production dispatchers the person deploying the changes can already know that they aren鈥檛 adding a new site; they鈥檙e just updating rewrite rules as indicated by the filename.

Include Order

When extending functionality and configurations in Apache Webserver installed on Enterprise Linux, you have some important include orders you鈥檒l want to understand.

A. Apache Baseline Includes

Apache binary starts with httpd.conf which does an includeoptional to the conf.d/*.conf and conf.modules.d/*.conf directories.

As seen in the diagram above the httpd binary only looks to the httpd.conf file as it鈥檚 configuration file. That file contains the following statements in it:

Include conf.modules.d/*.conf
IncludeOptional conf.d/*.conf

B. AMS Top Level Includes

When we applied our standard we added some additional file types and includes of our own.

Here is the AMS baseline directories and top level includes

Building off Apache鈥檚 baseline we show how AMS created some addtional folders and top level includes for conf.d folders as well as module specific directories nested under /etc/httpd/conf.dispatcher.d/

When Apache loads it pulls in the /etc/httpd/conf.modules.d/02-dispatcher.conf and that file includes the binary file /etc/httpd/modules/mod_dispatcher.so into its running state.

LoadModule dispatcher_module modules/mod_dispatcher.so

To use the module in our </VirtualHost> we drop a configuration file into /etc/httpd/conf.d/ named dispatcher_vhost.conf and inside this file you鈥檒l see use setup the basic parameters needed for the module to work:

<IfModule disp_apache2.c>
DispatcherConfig conf.dispatcher.d /dispatcher .any
...SNIP...
</IfModule>

As you can see above this includes the top level dispatcher.any file for our Dispatcher module to pick up it鈥檚 configuration files from /etc/httpd/conf.dispatcher.d/dispatcher.any

Pay attention to the contents of this file:

/farms {
 $include "enabled_farms/*_farm.any"
}

The top level dispatcher.any file includes all of the enabled farm files that live in聽/etc/httpd/conf.dispatcher.d/enabled_farms/聽with the file name of聽<FILENAME>_farm.any聽which follows our standard naming convention.

Later in the聽dispatcher_vhost.conf聽file mentioned earlier we also do an include statement to enable each enabled virtual host files that live in聽/etc/httpd/conf.d/enabled_vhosts/聽with the filename of <FILENAME>.vhost聽which follows our standard naming convention.

IncludeOptional /etc/httpd/conf.d/enabled_vhosts/*.vhost

In each of our .vhost files you鈥檒l note the dispatcher module gets initialized as a default file handler for a directory.聽Here is an example .vhost file to show the syntax:

<VirtualHost *:80>
 ServerName "weretail"
 ServerAlias www.weretail.com weretail.com
 <Directory />
 <IfModule disp_apache2.c>
 ....SNIP....
 SetHandler dispatcher-handler
 </IfModule>
 ....SNIP....
 </Directory>
 ....SNIP....
</VirtualHost>

After the top level includes resolve they have other sub includes that are worth mentioning.聽Here is a high level diagram on how the farms and vhosts files include other sub elements

C. AMS Virtual Host Includes

When any .vhost files from聽/etc/httpd/conf.d/availabled_vhosts/聽directory get symlinked into the聽/etc/httpd/conf.d/enabled_vhosts/聽directory they will be used in the running configuration.

The .vhost files have sub includes based on common pieces we have found. Things like variables, whitelists, and rewrite rules.

The .vhost file will have include statements for each file based on where they need to be included in the .vhost file. Here is an example syntax of a .vhost file as a good reference:

Include /etc/httpd/conf .d /variables/weretail .vars VirtualHost *:80
ServerName "${MAIN_DOMAIN}"
Directory / Include /etc/httpd/conf .d /whitelists/weretail *_whitelist.rules
IfModule disp_apache2.c
....SNIP....
SetHandler dispatcher-handler
/IfModule
....SNIP....
/Directory
....SNIP....
IfModule mod_rewrite.c
ReWriteEngine on
LogLevel warn rewrite:trace1
Include /etc/httpd/conf .d /rewrites/weretail_rewrite .rules
/IfModule /VirtualHost

As you can see in the above example there is an include for the variables needed in this configuration file that are later used.

Inside the file /etc/httpd/conf.d/variables/weretail.vars we can see what variables are defined:

Define MAIN_DOMAIN dev.weretail.com

You can also see a line that includes a list of whitelist.rules files that restrict who can view this content based on different whitelist criteria. Lets look at the contents of one of the white list files /etc/httpd/conf.d/whitelists/weretail_mainoffice_whitelist.rules:

<RequireAny>
 Require ip 192.150.16.0/23
</RequireAny>

You can also see a line that includes a set of rewrite rules. Let鈥檚 take a look at the contents of the weretail_rewrite.rules file:

RewriteRule /robots.txt$ /content/dam/weretail/robots.txt [ NC,PT]
RewriteCond %{SERVER_NAME} brand1.weretail.net [ NC]
RewriteRule /favicon1.ico$ /content/dam/weretail/favicon1.ico [ NC,PT]
RewriteCond %{SERVER_NAME} brand2.weretail.com [ NC]
RewriteRule /sitemap.xml$ /content/weretail/general/sitemap.xml [ NC,PT]
RewriteRule /logo.jpg$ /content/dam/weretail/general/logo.jpg [ NC,PT]

D. AMS Farm Includes

When any <FILENAME>_farm.any files from聽/etc/httpd/conf.dispatcher.d/available_farms/聽directory get symlinked into the聽/etc/httpd/conf.dispatcher.d/enabled_farms/聽directory they will be used in the running configuration.

The farm files have sub includes based on聽top level sections of the farm聽like聽cache, clientheaders, filters, renders, and vhosts.

The <FILENAME>_farm.any files will have include statements for each file based on where they need to be included in the farm file.聽Here is an example syntax of a <FILENAME>_farm.any file as a good reference:

/weretailfarm {
 /clientheaders {
 $include "/etc/httpd/conf.dispatcher.d/clientheaders/ams_publish_clientheaders.any"
 $include "/etc/httpd/conf.dispatcher.d/clientheaders/ams_common_clientheaders.any"
 }
 /virtualhosts {
 $include "/etc/httpd/conf.dispatcher.d/vhosts/weretail_vhosts.any"
 }
 /renders {
 $include "/etc/httpd/conf.dispatcher.d/renders/ams_publish_renders.any"
 }
 /filter {
 $include "/etc/httpd/conf.dispatcher.d/filters/ams_publish_filters.any"
 $include "/etc/httpd/conf.dispatcher.d/filters/weretail_search_filters.any"
 }
 ....SNIP....
 /cache {
 ....SNIP....
 /rules {
 $include "/etc/httpd/conf.dispatcher.d/cache/ams_publish_cache.any"
 }
 ....SNIP....
 /allowedClients {
 /0000 {
 /glob "*.*.*.*"
 /type "deny"
 }
 $include "/etc/httpd/conf.dispatcher.d/cache/ams_publish_invalidate_allowed.any"
 }
 ....SNIP....
 }
}

As you can see each section for the weretail farm instead of having all of the syntax needed it鈥檚 instead using an include statement.

Let鈥檚 look at the syntax of a few of these includes to get the idea of what each sub include would look like /etc/httpd/conf.dispatcher.d/vhosts/weretail_publish_vhosts.any:

"brand1.weretail.com"
"brand2.weretail.com"
"www.weretail.comf"

As you can see it鈥檚 a new line separated list of domain names that should render from this farm over the others.

Next let鈥檚 look at the /etc/httpd/conf.dispatcher.d/filters/weretail_search_filters.any:

/400 { /type "allow" /method "GET" /path "/bin/weretail/lists/*" /extension "json" }
/401 { /type "allow" /method "POST" /path "/bin/weretail/search/" /extension "html" }
recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f