0

In some apache file (site-enabled) you can see :

<VirtualHost 172.20.30.40:80>
    DocumentRoot /www/example1
    ServerName www.example.com
</VirtualHost>

Another :

<VirtualHost *:80>
    DocumentRoot /www/example1
    ServerName www.example.com
</VirtualHost>

What's the difference between this two ligne :

<VirtualHost 172.20.30.40:80>
<VirtualHost *:80>

Usually i always use : *:80 for the VirtualHost. But one of my friend on is server need to put the IP of the server. The *:80 doesn't work.

Do you know why ? Did it's a special config ? There is a way to know when we need to put the ip or not ?

1 Answer 1

2

<VirtualHost *:80> Will serve the page to all requests on port 80

<VirtualHost <IP>:80> Will only serve requests that are sent to IP address specified. Can be useful if your web server has more than 1 IP address and you want to serve a specific page for each address. This can take precedence over *:80 depending on your configuration, check the output of apachectl -S to see what's attached where.

In most cases, <VirtualHost *:80> is a sensible value and your host will be able to serve pages even if the IP address might change in the future.

4
  • So if the *:80 doesn't work on his server it's because he have more than 1 ip ? There is a way to know when we need to put the ip or not ?
    – mpgn
    Jun 22, 2014 at 16:07
  • The only way it might not work is if there are multiple VirtualHost entries. *:80 should serve the page, no matter for wich address the request was sent. Check the apache logs for anything out of the ordinary.
    – cebalrai
    Jun 22, 2014 at 16:09
  • There is a way to know of i need to put the ip or not ? Did the file port.conf give an advice ?
    – mpgn
    Jun 22, 2014 at 16:11
  • If *:80 does not work, is it possible the server's host-based firewall (iptables) is blocking incoming http requests? Jun 22, 2014 at 17:15

You must log in to answer this question.

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