# VHost on :8080 only for one domain



## oversize (Jan 26, 2009)

Hi, in my httpd.conf

  Listen xx.xx.xx.xx:80
  Listen xx.xx.xx.xx:8080

Now i have various domainname.conf like this: 

<VirtualHost *:80>
    ServerName serveme.com
    ServerAlias http://www.serveme.com
    DocumentRoot "/path/to/somewhere"
</VirtualHost>


No i wanted to add a development VHosts for _one_ Domain on :8080. 

The VHosts looks like this:
<VirtualHost *:8080>
    ServerName serveme.com
    ServerAlias http://www.serveme.com
    DocumentRoot "/path/to/elsewhere"
</VirtualHost>

The VHosts on 8080 for the Domain i have setup in ServerName (of the *:8080 VHosts) works fine. But accessing any of the other domains, that resolve to this servers IP using :8080 delivers me the same content. 

I would like to have the VHosts on *:8080 only available on one Domain (that what has been set in ServerName). 

What am i doing wrong? 

Thank you


----------



## mjguzik (Jan 26, 2009)

oversize said:
			
		

> The VHosts on 8080 for the Domain i have setup in ServerName (of the *:8080 VHosts) works fine. But accessing any of the other domains, that resolve to this servers IP using :8080 delivers me the same content.
> 
> I would like to have the VHosts on *:8080 only available on one Domain (that what has been set in ServerName).
> 
> What am i doing wrong?



It's because this vhost is the default (only) one available and Apache uses it as the only match. Adding +/- the following before it should help:

<VirtualHost _default_:8080>
        DocumentRoot /nonexistent
</VirtualHost>


----------



## oversize (Jan 26, 2009)

Thank you.

i misunderstood, that there has to be one default vhost (for every port). And that the first that is configured is the default one.

i then added to httpd.conf

NameVirtualHost *:80
NameVirtualHost *:8080
DocumentRoot "/path/to/default/htdocs"

<VirtualHost *:80>
  ServerName mydefaultdomain.com
  ServerAdmin me@mydomain.com
</VirtualHost>

<VirtualHost *:8080>
  ServerName mydefaultdomain.com
  ServerAdmin me@mydomain.com
</VirtualHost>

And then included every VHosts configuration *afterwards*, which totaly solves the Problem!

--
Cheers


----------

