httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakob M <>
Subject [users@httpd] Setting Directive ServerName in VirtualHost to the full qualified domain of the request
Date Thu, 28 Feb 2019 00:04:05 GMT
Hello together,

I need a little bit help setting up my apache to support a dynamic

I have a DNS server which forwards all requests * to my apache.
This leads to these 3 example domains (In fact we talk about 600-800


What I want to achiev is to only configure one VirtualHost but set the
ServerName on each request based on the subdomain which was used to access
the apache.

Therefore I thought I could use variables to pass them to the directive.
Unfortunately the variable is not resolved in my configuration.

Is there any way to pass an env variable to the directive ServerName, so I
can achiev the dynamic setup of ServerName based on the subdomain used?

Example Config:

<VirtualHost *:80>
UseCanonicalName Off
ProxyPreserveHost On
RewriteEngine on
ProxyRequests Off

SetEnvIf Host "^([^.]*)$" SUBDOMAIN=$1
SetEnvIf Host "^([^.]*)-([^.]*)$" HOSTNAME=$1
SetEnvIf Host "^([^.]*)-([^.]*)$" PORTNUMBER=:$2

ProxyPassInterpolateEnv On
ProxyPass        "/"  "http://${HOSTNAME}${PORTNUMBER}/" interpolate
ProxyPassReverse "/"  "http://${HOSTNAME}${PORTNUMBER}/" interpolate

ServerName %{SUBDOMAIN}
</VirtualHost *:80>

Problem: The ServerName is now " %{SUBDOMAIN} " -> The variable
gets not resolved.

Kind regards,

View raw message