I'm trying to configure Apache to dynamically set the ServerName directive to include the system's hostname as part of the fully qualified domain name. I need the ServerName to follow this pattern: subdomain-genericname-HOSTNAME-suffix.domain.com, where HOSTNAME should be the actual hostname of the machine where Apache is running.
For example, if the machine's hostname is server12345, the ServerName should end up being subdomain-genericname-server12345-suffix.domain.com.
Here's the configuration snippet that I've been working with:
PassEnv HOSTNAME - passed through httpd confg
ServerName subdomain-genericname-${HOSTNAME}-suffix.domain.com this is what I want to pass in my vhost.cof
However, Apache doesn't seem to substitute ${HOSTNAME} with the actual environment variable value in the ServerName directive.
My goal is to manage this configuration directly within Apache without pre-processing the configuration files with external scripts or tools like Ansible if possible.
Does Apache offer a way to use environment variables directly within the ServerName directive, or is there a recommended method for achieving this with standard Apache modules or directives?