Recipe 4.11 Port-Based Virtual Hosts
Problem
You want to present different content for HTTP
connections on different ports.
Solution
Explicitly list the port number in the
<VirtualHost> declaration:
Listen 8080
<VirtualHost 10.0.1.2:8080>
DocumentRoot /www/vhosts/port8080
</VirtualHost>
Listen 9090
<VirtualHost 10.0.1.2:9090>
DocumentRoot /www/vhosts/port9090
<VirtualHost>
Discussion
Port-based virtual hosting is somewhat
less common than other techniques shown in this chapter. However,
there are a variety of situations in which it can be useful. If you
have only one IP address, have no ability to add hostnames to DNS, or
if your ISP blocks in-bound traffic on port 80, it may be useful to
run virtual hosts on other ports.
Visitors to your web site must list the port number in the URL that
they use. For example, to load content from the second virtual host
previously listed, the following URL might be used:
http://server.example.com:9090/
See Also
|