0

I have big problems trying to figure this out so please help me out.

I have several virutal hosts configured and using the Debian default way of configuring vhosts.

2 folders

  • sites-available
  • sites-enabled

and some files are symlinked to sites-enabled using ln -s ... and in this step I rename the files to have a weight, 200-... 300-... to have priority.

When I try to configure a bunch of vhosts:

<VirtualHost test.host.priv:80>
  ServerName test.host.priv
  DocumentRoot "/htdocs/Private/web/production/somedomain/web"
</VirtualHost>

<VirtualHost host.com:80>
  ServerName host.com
  ServerAlias www.host.com
  DocumentRoot "/htdocs/Private/web/production/somedomain/web"
</VirtualHost>

Now I have several of these, and I have some *:80 as well. But How do I make sure that these only listen to the server name I have specified? Because apache start using these as wildcard etc. Loke every domain in this case is defaulting back to the test.host.priv if it havn't been configured in a highter priority file. I dont want that, I've tried using *:80, test.host.priv:80 and it just doesn't care, it still defaults to this, so any subdomain that isn't specified goes here.

Any advice would be great!

/Marcus

1 Answer 1

2

Apache matches VHosts by ServerName and ServerAlias when NameVirtualHost is active on a specific Listener, I guess that's what you are missing here.

When using Debian you will have a ports.conf with a default of Listen 80 which means listen on port 80 on all available interfaces. Then you can use NameVirtualHost *:80 and write your hosts like:

<VirtualHost *:80>
  ServerName test.host.priv
  DocumentRoot "/htdocs/Private/web/production/somedomain/web"
</VirtualHost>

<VirtualHost *:80>
  ServerName host.com
  ServerAlias www.host.com
  DocumentRoot "/htdocs/Private/web/production/somedomain/web"
</VirtualHost>

You can alter that as you like, just the <VirtualHost [something]:[someport]> needs a "matching" NameVirtualHost [something]:[someport] before.

See http://httpd.apache.org/docs/2.2/mod/core.html#NameVirtualHost for details.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .