Chapter 5: Apache Modules Up Part I: Fundamental Webserver Management with InterWorx Part II: Advanced Topics 

6 Default Sites for each IP address

Figure 6.1 An Example Default Sites Configuration Screen
figure images/nodeworx/IP/ip-default.png
The Default Sites feature is shown in figure 6.1↑ and is located in NodeWorx under Server ▷ IP Management ▷ Default Sites. By default, when you visit an IP address with the NameVirtualHost system, the webserver will check the Host: <domain> portion of the HTTP request, check it’s in-memory listing of the virtualhosts on that IP address, and load the correct virtual host configuration to continue processing the HTTP request. If it is unable to match the domain sent in with its list of virtual hosts, then it will by default load the first virtualhost on its list and use that. The order is based on the order the /etc/httpd/conf.d/vhost_*.conf files were read, which means alphabetical. That means the domain with the highest alphabetical domain name is going to show up on that IP. We realized that for many this behavior is not desirable as someone’s site might show up that shouldn’t be visible, so we created a Default Sites system which lets you specify a URL that the user should be redirected to if they either:
  • Visit a domain that is pointing at an IP address on your server but there is no domain with that name registered on your server
  • Visit an IP address on your server directly in their browser
The URL should be something that can be redirected to, thus something resolve-able via DNS. In addition, you can have default site be /var/www/html where you can put some sort of splash page for your hosting service. To use the Default Sites feature:
  1. Go to Server ▷ IP Management ▷ Default Sites in NodeWorx.
  2. Make sure the Default Sites feature is enabled by setting the “Status” drop-down to “Enabled” if it’s not already.
  3. Check the boxes next to the IP addresses you wish to have redirect to a different URL if they are accessed directly.
  4. Select “Update Default Sites” from the drop-down and click “Go”.
  5. In the window that pops up, either put the URL in “Site:” that you want the IP(s) to redirect to, or leave blank for /var/www/html.
  6. Click save.
By default /var/www/html is an InterWorx splash page, but you can edit or upload files to replace the index file we have in /var/www/html. Keep in mind with suPHP, PHP will not function on the default site load because suPHP does not have a user it can switch to to execute PHP code.
Default Sites Under the Panel
On the file system, the configuration file that sets default sites is located at /etc/httpd/conf.d/vhost_000_defaults.conf. The 000 is our attempt to keep this VirtualHost file parsed first alphabetically so it is the one that gets loaded by default when the IP is visited without a matching domain. When the feature is turned off, the file is renamed with .disabled appened to the filename to prevent it from being loaded by the webserver (yes, only files ending in .conf are parsed and loaded by the webserver).
 Chapter 5: Apache Modules Up Part I: Fundamental Webserver Management with InterWorx Part II: Advanced Topics 

(C) 2019 by InterWorx LLC