Apache2 virtual hosts

Most complicated case:

Listen 80
Listen 443

NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:443

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

<VirtualHost 172.20.30.40:443>
    ServerName www.example1.com
    DocumentRoot /www/domain-ssl
    SSLEngine on
    SSLCertificateFile /etc/apache2/certs/cert1.crt
    SSLCertificateKeyFile /etc/apache2/certs/key1.key
    SSLCertificateChainFile /etc/apache2/certs/cacert1.crt
</VirtualHost>

<VirtualHost 172.20.30.40:80>
    ServerName www.example2.org
    DocumentRoot /www/otherdomain-80
</VirtualHost>

<VirtualHost 172.20.30.40:443>
    ServerName www.example2.org
    DocumentRoot /www/otherdomain-ssl
    SSLEngine on
    SSLCertificateFile /etc/apache2/certs/cert2.crt
    SSLCertificateKeyFile /etc/apache2/certs/key2.key
    SSLCertificateChainFile /etc/apache2/certs/cacert2.crt
</VirtualHost>

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 Listen directive, your configuration will not work.

 
virtualhosts.txt · Last modified: 31.03.2010 17:51 (external edit)
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki