Introduction
This article explains how to set up non-existent sites and IP addresses to go to a particular site or the default web page instead of the first vhost entry bound to an IP address.
If you have a domain that resolves to an IP address on a server, but doesn't exist on the server, Apache will serve the content for the first site bound to the IP address that the domain resolves to. See more: Secondary shared IP address shows a website
Procedure
To change the behavior, you need to add a new virtualhost to /etc/apache2/conf.d/includes/pre_virtualhost_global.conf
that will become the first virtualhost.
The easy way to do this is as follows:
1. Navigate to WHM »Service Configuration »Apache Configuration »Include Editor
2. Under Pre VirtualHost Include, select the 2.4.X Apache version
3. Add the virtualhost for the IP address over the webserver ports in the box that opens
4. Click Update
5. Click Restart Apache
Examples of virtualhosts to include:
You can use any Apache directive that works in the VirtualHost context.
If you want the default web page to load on the IP address, add this, replacing the IP in the VirtualHost directive:
<VirtualHost 10.0.1.1:80>
DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost 10.0.1.1:443>
DocumentRoot /var/www/html
<IfModule suphp_module>
suPHP_UserGroup nobody nobody
</IfModule>
<Directory "/var/www/html">
AllowOverride All
</Directory>
<IfModule ssl_module>
SSLEngine on
SSLCertificateFile /var/cpanel/ssl/cpanel/cpanel.pem
SSLCertificateKeyFile /var/cpanel/ssl/cpanel/cpanel.pem
SSLCertificateChainFile /var/cpanel/ssl/cpanel/cpanel.pem
SSLUseStapling Off
</IfModule>
<IfModule security2_module>
SecRuleEngine On
</IfModule>
</VirtualHost>
Do this for each IP on the server if desired.
Comments
0 comments
Article is closed for comments.