Introduction
This article explains how to set up non-existent sites and IP addresses to go to a particular site or the default Webpage instead of the first VirtualHost 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 serves the content for the first site bound to the IP address to which the domain resolves. You can read more about this here: Secondary shared IP address shows a website.
Procedure
To change this behavior, you need to add a new VirtualHost to /etc/apache2/conf.d/includes/pre_virtualhost_global.conf
that will become the first VirtualHost.
To do this, perform the following actions:
- Navigate to WHM » Service Configuration » Apache Configuration » Include Editor.
- Under Pre VirtualHost Include, select the 2.4.X Apache version.
- Add the VirtualHost for the IP address over the webserver ports in the box that opens.
- Click Update.
- 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 Webpage to load on the IP address, add this content, replacing the IP in the VirtualHost directive with the desired IP address on your server:
<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.