httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Evans <tevans...@googlemail.com>
Subject Re: [users@httpd] apache 2.4 virtualhosts
Date Thu, 15 Mar 2012 09:37:28 GMT
On Thu, Mar 15, 2012 at 1:35 AM, Brett @Google <brett.maxfield@gmail.com> wrote:
> Hello,
>
> There is an example at : http://httpd.apache.org/docs/2.4/vhosts/name-based.html
>
> <VirtualHost *:80>
> # This first-listed virtual host is also the default for *:80
> ServerName www.example.com
> ServerAlias example.com *.example.com
> DocumentRoot /www/domain
> </VirtualHost>
>
> <VirtualHost *:80>
> ServerName other.example.com
> DocumentRoot /www/otherdomain
> </VirtualHost>
>
> I configured something similar, like :
>
> UseCanonicalName Off
>
> # serves a "we dont host this web site error message" by default
> <VirtualHost revproxy.internal:80>
>    ServerName revproxy.internal
>    ServerAlias *.example.com # if enabled snarfs all traffic, even
> test.example.com
>    RewriteRule ^/  /bad_host_error_page.html [L]
> </VirtualHost>
>
> # serves content for test.example.com
> <VirtualHost revproxy.internal:80>
>    RewriteEngine on
>    ServerName test.example.com
>    ProxyPass / test.someserver.internal
>    ProxyPassReverse / test.someserver.internal
> </VirtualHost>
>
> The documented becaviour does not seem to be correct. If i comment out
> "ServerAlias *.example.com" traffic to test.example.com goes to the
> more specific container and others to the default, but only because
> "revproxy.internal" is also the name of the server in the global
> server configuration, so the first virtualhost also happens to be the
> "default" server int he global sense which is what happens because no
> ServerName/ServerAlias is matched in the VirtualHosts. This could only
> be done once per apache instance, whereas previously it could be done
> once for every NameVirtualHost IP that belongs to an apache instance.
>
> Ideally i'd like to do something like (whihc i could do in apache 2.2
> - by virtue of NameVirtualHost, and grouping by IP with one as the
> default) :
>
> # serve a "we dont host this web site error message" by default for
> *.example.com
> <VirtualHost revproxy.internal:80>
>    ServerAlias *.example.com
>    RewriteRule ^/  /bad_host_error_page.html [L]
> </VirtualHost>
>
> # content for test.example.com
> <VirtualHost revproxy.internal:80>
>    ServerName test.example.com
>    ProxyPass / test.someserver.internal
>    ProxyPassReverse / test.someserver.internal
> </VirtualHost>
>
> # content for test2.example.com
> <VirtualHost revproxy.internal:80>
>    ServerName test2.example.com
>    ProxyPass / test2.someserver.internal
>    ProxyPassReverse / test2.someserver.internal
> </VirtualHost>
>
> # serve a "we dont host this web site error message" by default for
> *.example.net
> <VirtualHost revproxy.internal:80>
>    ServerAlias *.example.net
>    RewriteRule ^/  /bad_host_error_page.html [L]
> </VirtualHost>
>
> # content for test.example.net
> <VirtualHost revproxy.qgdevcore.govnet.internal:80>
>    ServerName test.example.net
>    ProxyPass / test.someotherserver.internal
>    ProxyPassReverse / test.someotherserver.internal
> </VirtualHost>
>
> # content for test2.example.net
> <VirtualHost revproxy.qgdevcore.govnet.internal:80>
>    ServerName test2.example.net
>    ProxyPass / test2.someotherserver.internal
>    ProxyPassReverse / test2.someotherserver.internal
> </VirtualHost>
>
> [.. etc ..]
>
> I'm guessing that apache 2.4 does not search for more specific
> ServerName if it matches a wildcard ServerAlias ?
>
> I'd like it to work like the docs state, ideally..
>
> Cheers
> Brett
>

Any reason why you aren't using the standard recipe?

<VirtualHost *:80>
  # This is the first vhost, and hence the default vhost.
  # Anything not matched by another vhost goes here
  # Note, no server name or server alias
</VirtualHost>

<VirtualHost *:80>
  ServerName foo.example.com
</VirtualHost>

<VirtualHost *:80>
  ServerName foo.example.com
</VirtualHost>

Cheers

Tom
Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message