httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brett @Google" <brett.maxfi...@gmail.com>
Subject Re: [users@httpd] apache 2.4 virtualhosts
Date Thu, 15 Mar 2012 13:43:24 GMT
On Thu, Mar 15, 2012 at 7:37 PM, Tom Evans <tevans.uk@googlemail.com> wrote:

>> 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>

primarily we want reject clearly which server names we respond to or
not, and we don't want to have to run an excessive number of Apache
instances. we are also not responsible for the back end servers to
whom we redirect, so connectivity to particular entities is already
difficult enough, we want to simplify our config as much as possible
so adding of new reverse proxies is as reproducible and as error free
as we can make it. generally as a rule for backend server for which we
are not responsible, we want a custom error page for the bad gateway
error that points backend connectivity errors to the the support team
of that server.

we also now have a very large number of virtualhosts we need to
migrate over which are structured based of the 2.0 / 2.2
NameVirtualHost paradygm, to something that is not 1:1 compatible with
the NameVirtualHost pattern. the documentation says that you can have
a mix of *.example.com ServerAliases and foo.example.com ServerNames,
but expermentation has shown that a foo.example.com will always be
mapped to the *.example.com serveralias.

we have many reverse proxies for inter connectivity, upwards of 30-40,
but generally we have 3-4 Apache instances with 8-10 listening ip's
each (presently each a NameVirtualHost - with multiple virtualhosts),
grouped by service agreement or owner of the backend server(s) to
which we redirect traffic. having 30 or 40 seperate apache instances
would create a very large memory footprint, that would use excessive
server resources for no good reason.. our internal charging model
penalizes excessive resource consumption.

if the docs were true, we could simulate the old structure by having a
wildard virtualhost for each NameVirtualHost "default" server and
error pages for of each group of related customers, in other words we
would have a config migration path.

my current thought is to have a default container for each ip
(currently are NameVirtualHost's), which does both proxy_express style
reverse proxies and custom error page, with a standard reverse proxy
behavior configured by the map file, and more specific or non-standard
server names added as additional virtual hosts on the same ip (such as
servers splitting the url space to multiple back end servers). it
seems apache 2.4 is a big change in paragdym, in the sense of now
having only one "global" default container, whereas it was possible to
have one default container for each NameVirtualHost ip before.

a map file, configuring maybe 80% of the typical reverse proxy style,
will be simpler to modify and maintain, and only the non-standard
reverse proxy styles would need to have bespoke virtualhosts / reverse
proxy configs.

i have configured a test apache instance, with a default container
that does custom error pages for *.myserver.com, a default
proxy_express behavior configured by a map file,  and can have other
virtualhosts that override the default, but i can only do this once
per apache instance, due to the removal of NameVirtualHost. With
NameVirtualHost, we can have a default page several times per apache
instance, for groups of related customers, eg. each of *.myserver1.com
*.myserver2.com, etc., is a group based on a single listening ip but
with multiple virtualhosts split out by the host header.

Cheers
Brett

-- 
The only thing that interferes with my learning is my education.

Albert Einstein

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


Mime
View raw message