Re: Setting Directive ServerName in VirtualHost to the full qualified domain of the request

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The ServerName doesn't matter, since it's not used in the ProxyPass.  Just make that server.de or whatever.  Then create a ServerAlias *.server.de.  Keep in mind that this setup allows something like a request to localhost-80.server.de which then gets proxied to localhost:80 and might serve things that were supposed to only be accessed locally.  I'm not sure why you want to proxy.  Is this something that could be solved using mod_vhost_alias ?

On Thu, Feb 28, 2019 at 1:04 AM Jakob M <jakob.mandalka@xxxxxxxxxxxxxx.invalid> wrote:
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):


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

[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux