Introduction
You may want to produce an error so no site is loaded when the server IP or additional IPs are accessed. This can be done with a VirtualHost for each IP on port 80 and 443 with a specific DocumentRoot. If the port is offset because NGINX is installed, then the alternate port needs to be set instead.
Procedure
- Log into WHM as the root user and navigate to "Apache Configuration / Include Editor."
- Select "All Versions" under the "Pre VirtualHost Include."
- Alternatively, access the following file through a command line text editor as the root user:
/etc/apache2/conf.d/includes/pre_virtualhost_global.conf
- Enter the following configuration into the text area. You will replace the generic IP address(255.255.255.255) with the IP address on your server that you wish to prevent from loading a page:
<VirtualHost 255.255.255.255:80>
ServerName 255.255.255.255
DocumentRoot /dev/null
<IfModule mod_suphp.c>
suPHP_UserGroup nobody nobody
</IfModule>
UserDir disabled
</VirtualHost>
<VirtualHost 255.255.255.255:443>
ServerName 255.255.255.255
DocumentRoot /dev/null
<IfModule mod_suphp.c>
suPHP_UserGroup nobody nobody
</IfModule>
UserDir disabled
SSLEngine on
SSLCertificateFile /var/cpanel/ssl/cpanel/cpanel.pem
SSLCertificateKeyFile /var/cpanel/ssl/cpanel/cpanel.pem
SSLCertificateChainFile /var/cpanel/ssl/cpanel/cpanel.pem
</VirtualHost> - Restart Apache by navigating to "Restart Services / HTTP Server (Apache)"
- If configured correctly, Apache will restart and no longer load pages when the IP address is accessed directly.
Please note the following entries will propagate to your Apache logs when the IP is accessed directly:
Forbidden: /dev/null doesn't point to a file or directory
This is the expected error and can be ignored.
Comments
0 comments
Article is closed for comments.