Apache con virtual hosts

Da Caos per caso.
Jump to navigation Jump to search

You have multiple domains going to the same IP and also want to serve multiple ports. By defining the ports in the "NameVirtualHost" tag, you can allow this to work. If you try using <VirtualHost name:port> without the NameVirtualHost name:port or you try to use the Port directive, your configuration will not work.

Server configuration:

       ...   
       NameVirtualHost 111.22.33.44:80
       NameVirtualHost 111.22.33.44:8080

       <VirtualHost 111.22.33.44:80>
       ServerName www.domain.tld
       DocumentRoot /www/domain-80
       </VirtualHost>

       <VirtualHost 111.22.33.44:8080>
       ServerName www.domain.tld
       DocumentRoot /www/domain-8080
       </VirtualHost>

       <VirtualHost 111.22.33.44:80>
       ServerName www.otherdomain.tld
       DocumentRoot /www/otherdomain-80
       </VirtualHost>

       <VirtualHost 111.22.33.44:8080>
       ServerName www.otherdomain.tld
       DocumentRoot /www/otherdomain-8080
       </VirtualHost>


Fonte

http://httpd.apache.org/docs/1.3/vhosts/examples.html