Hello together,

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

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

- subomain1.server.de
- subomain2.server.de
- subomain3.server.de

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 "^([^.]*).server.de$" SUBDOMAIN=$1
SetEnvIf Host "^([^.]*)-([^.]*).server.de$" HOSTNAME=$1
SetEnvIf Host "^([^.]*)-([^.]*) .server.de$" PORTNUMBER=:$2

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

ServerName %{SUBDOMAIN}e.server.de
</VirtualHost *:80>

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

Kind regards,
Jakob

Reply via email to