Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My server is running Apache2 and the configuration contains several NameVirtualHost settings.

# Example
NameVirtualHost aaa.bbb.ccc.ddd:80
NameVirtualHost xxx.yyy.zzz.qqq:80
NameVirtualHost [aaaa:ssss:dddd:ffff:gggg:hhhh]:80

There are Listen settings for all of them.

At this moment in time I am keeping track of two or more <VirtualHost foo:80> for each site because I want to be able to control which sites can be accessed through specific IP addresses. One of the reasons for doing it this way is ownership of the IP addresses the sites are being served on.

Question: Is it possible to create a "bundle" NameVirtualHost which contains more than 1 NameVirtualHost but not all NameVirtualHosts at once? The idea and reason for asking this question is that if I can bundle multiple NameVirtualHosts into one, then I would not have to administer multiple <VirtualHost foo:80> configuration sets for each site.

Cheers.

share|improve this question

migrated from webmasters.stackexchange.com Apr 14 at 11:57

1 Answer

Yes, it's just a matter of having multiple domains in ServerAlias directive.

You could have one definition:

<VirtualHost aaa.bb.ccc.d:80>
      ServerName primary.domain.tld
      ServerAlias another.domain.tld *.example.org whatever.bla.ble
      #... other confs
      VirtualDocumentRoot /var/www/htdocs/%0
</VirtualHost>

This way you can have only one definition, but several domains being served with just one vhost definition.

share|improve this answer
I think you misunderstood, but thank you for your answer. I already am using aliases, but the question is about making sure that services are served on the correct IP addresses using 1 VirtualHost, not making sure that one VirtualHost is serving several url/domains/hostnames (Not sure what to call it). – Mogget Apr 15 at 22:00
To make sure what IP serves which content, just place separate logfiles within each virtualhost, and you'll have your answers in the log. – Marcel Apr 15 at 22:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.