Virtual hosts for other domains
NetManager can host as many independent websites as you wish. It does this by looking at the domain name requested by the web-browser and selecting which website to serve on the basis of this. This is known as name-based virtual hosting.
To use virtual hosting, you need to do two things:
- Pointing the names in question (e.g. www.example.com) at your external IP address
- Create a sub-directory in the main webspace and configure NetManager to use this for the desired domain names.
apache_virtualhostconfiguration file option contains a space-separated list of sub-directory,domain-name pairs. For example:
In the example above, both www.example.com and example.com (because people often miss off the www when typing an address into their browser) will be served using the documents in the example sub-directory (actual path
Virtual hosts by IP address or port number (advanced)
In addition to name-based virtual hosts, different websites can be selected by the IP address or port number on the server that the browser connects to. To configure an IP/port virtual host, specify the IP address (and optionally port, defaults to 80 is not specified) in addition to the
directory,domain-name option in the
apache_virtualhost configuration file option, i.e. format is:
If the directory begins with / it specifies an absolute path to the website. If it begins with ~user, it is in the home directory of user (can also specify a sub-directory). Otherwise, it specifies a subdirectory of the main webspace.
If specifying an IP address, you do not need to specify a domain name. If no domain name is given, the website specified will be served whatever the address used in the browser, otherwise normal name-based virtual host rules apply as above.
You may also skip the IP address part if you just want to distinguish by port number. Port 443 is specifically handled, it will enable https if an SSL certificate is defined and enabled for the webserver. If you do not give an SSL certificate in the config, it will use the global one defined for the webserver.So, for example (all on one line):
apache_virtualhost="example,www.example.com example,www.example.com,:443 test,,10.20.30.40 test1,www.test.com,10.20.30.40 test1,www.test.com,10.20.30.40:443,www.test.com:live test2,,10.20.30.40:81"
For this example, let us assume www.example.com points to 10.20.30.10 and www.test.com points to 10.20.30.40.
- http://10.20.30.10/ will give the default intranet site (as not specified in any virtual host)
- http://www.example.com/ will give the example website (as name-based match)
- https://www.example.com/ will give the example website over https (as name-based match on port 443)
- http://10.20.30.40/ will give the test website as IP-based match
- http://10.20.30.40:81/ will give the test2 website as IP- and port-based match
- http://www.test.com/ will give the test1 website as name- and IP-based match
- https://www.test.com/ will give the test1 website as name- and IP-based match on port 443. As domain is different, an overridden SSL certificate needs to be given
N.B. You will need to configure the webserver to listen on any non-standard ports by adding them to the
apache_additional_ports configuration file option.