Resolving Dispatcher environment variables that don’t resolve or apply in AEM Dispatcher
Dispatcher environment variables fail to resolve, become unavailable inside IfDefine blocks, or behave inconsistently across environments when they’re mis-scoped, mis-named, assigned to the wrong service, referenced in unsupported directives, or overridden by an invalid dispatcher configuration. On AEMaaCS only ENVIRONMENT_DEV, ENVIRONMENT_STAGE, and ENVIRONMENT_PROD are injected as Apache defines, while custom Cloud Manager variables work only for string substitution and can’t be used inside IfDefine; on AMS, variables must be defined in /etc/sysconfig/httpd. Validating the variable definition, confirming it’s used in a supported context, and verifying the correct vhost loads at runtime restores the expected values.
Description description
Environments:
- Adobe Experience Manager as a Cloud Service (AEMaaCS)
- AEM Managed Services (AMS)
- AEM Dispatcher (Apache) on Publish tiers
- Dispatcher SDK for local validation
Issue/Symptoms:
- A custom header outputs the literal variable name instead of the resolved value, such as Access-Control-Allow-Origin: ${VAR_NAME}.
- The Dispatcher validator reports AH00111: Config variable ${VAR_NAME} is not defined.
- Apache reports Bad Authority for an empty variable used in a virtual host.
IfDefineblocks fail to apply becauseENVIRONMENT_STAGEorENVIRONMENT_DEVisn’t detected.- The pipeline fails during dispatcher validation or deploy without a clear error, and the local validator shows undefined variables.
- Environment-specific rules never execute because RDE has no
ENVIRONMENT_RDEdefine.
Root cause:
Dispatcher variable resolution varies by platform and directive type. On AEMaaCS, only ENVIRONMENT_DEV, ENVIRONMENT_STAGE, and ENVIRONMENT_PROD are Apache defines; Cloud Manager variables are available only as string substitutions and can’t be used in IfDefine. Using variables inside unsupported directives (IfDefine, <If>, or an empty ServerName), or not defining them for both the pipeline and runtime, produces undefined values. When vhost symlinks or farm virtual-host mappings are incorrect, the wrong vhost file loads and the variables appear non-functional. Empty strings in a vhost ServerName or ServerAlias cause Apache runtime failures. AMS requires variables defined in /etc/sysconfig/httpd, and mismatched values across environments cause incorrect behavior.
How to confirm
- Confirm the variable exists and is correctly defined. In Cloud Manager, go to Program
>Environment>Environment Variables and confirm the variable name (case-sensitive) and value match exactly what the dispatcher configs reference. Confirm the variable is defined for the Publish service, since the dispatcher isn’t present on Author tiers. - Confirm the variable type is supported in the context where it’s used. AEMaaCS doesn’t support Cloud Manager environment variables inside
IfDefine— onlyENVIRONMENT_DEV,ENVIRONMENT_STAGE, andENVIRONMENT_PRODwork there. If you seeIfDefinewrapping a Cloud Manager variable, that usage is unsupported. - Confirm no variable resolves to an empty string, especially in vhosts. An empty FQDN variable in a
ServerNameproduces the Apache Bad Authority error.
Resolution resolution
- Correct the variable definition or service assignment. If the name or value is wrong, or it’s assigned to the wrong service, add or correct the environment variable in Cloud Manager and rerun the pipeline.
- Use variables only in supported contexts. Keep Cloud Manager variables to string substitution, headers, rewrite rules, and vhost config. For environment-specific logic, use an Apache expression such as
<If "${ENV:ENVIRONMENT_TYPE} == 'dev'">or theENVIRONMENT_DEVdefine instead of wrapping a custom variable inIfDefine. - Define referenced variables in
custom.vars. Add aDefineentry for every variable referenced in the vhost files, in the formDefine VAR_NAME ${varname}. With the definitions in place, the validator stops reporting AH00111: Config variable is not defined. - Ensure vhost and farm symlinks are valid. Run the dispatcher validator locally; errors appear when
enabled_vhostsorenabled_farmscontain regular files instead of symlinks. Recreate the symlinks withln -sundersrc/conf.d/enabled_vhostsandenabled_farmsuntil the validator shows zero errors. - Ensure the correct vhost loads at runtime. Confirm the farm files point to the correct
virtualhosts.anyfile — an incorrect/virtualhostsmapping causes the dispatcher to load the default vhost and ignore custom variables. Correct the farm/virtualhostsblock to include../virtualhosts/virtualhosts.any, then visit a page and confirm the custom header shows the resolved value. - For AMS only, set variables in
/etc/sysconfig/httpd. SSH into the dispatcher server and runcat /etc/sysconfig/httpdto confirm the variables reflect the correct environment, then restart Apache withsudo systemctl restart httpd. If values revert, contact AMS Support. - Test locally using the Dispatcher SDK. Run the dispatcher locally with the AEM SDK Dispatcher Tools, then confirm header resolution with
curl -I http://localhost:8080/....
Validation
- Run
dispatcher-sdk/bin/validate srcand confirm no undefined-variable errors (AH00111) appear. - Check the actual HTTP response headers with
curl -Ior browser DevTools and confirm the variables resolve to their Cloud Manager values.