This document attempts to answer the commonly-asked questions about setting up virtual hosts.
These scenarios are those involving multiple web sites running on a single server, via name-based or IP-based virtual hosts.
The name-based vhost with the hostname http://www.example2.org/ (from our name-based example, setup 2) should get its own IP address. To avoid problems with name servers or proxies who cached the old IP address for the name-based vhost we want to provide both variants during a migration phase.
The solution is easy, because we can simply add the new IP address (172.20.30.50) to the VirtualHost directive.
##############################################
Server configuration
Listen 80
ServerName http://www.example1.com/
DocumentRoot /www/example1
NameVirtualHost 172.20.30.40
<VirtualHost 172.20.30.40 172.20.30.50>
DocumentRoot /www/example2
ServerName http://www.example2.org/
# ...
</VirtualHost>
<VirtualHost 172.20.30.40>
DocumentRoot /www/example3
ServerName http://www.example3.net/
ServerAlias *.example3.net
# ...
</VirtualHost>
##############################################
The vhost can now be accessed through the new address (as an IP-based vhost) and through the old address (as a name-based vhost).
These scenarios are those involving multiple web sites running on a single server, via name-based or IP-based virtual hosts.
The name-based vhost with the hostname http://www.example2.org/ (from our name-based example, setup 2) should get its own IP address. To avoid problems with name servers or proxies who cached the old IP address for the name-based vhost we want to provide both variants during a migration phase.
The solution is easy, because we can simply add the new IP address (172.20.30.50) to the VirtualHost directive.
##############################################
Server configuration
Listen 80
ServerName http://www.example1.com/
DocumentRoot /www/example1
NameVirtualHost 172.20.30.40
<VirtualHost 172.20.30.40 172.20.30.50>
DocumentRoot /www/example2
ServerName http://www.example2.org/
# ...
</VirtualHost>
<VirtualHost 172.20.30.40>
DocumentRoot /www/example3
ServerName http://www.example3.net/
ServerAlias *.example3.net
# ...
</VirtualHost>
##############################################
The vhost can now be accessed through the new address (as an IP-based vhost) and through the old address (as a name-based vhost).
No comments:
Post a Comment