Redirect IP requests to the default cPanel page?

jndawson

Well-Known Member
Aug 27, 2014
342
37
78
Western US
cPanel Access Level
DataCenter Provider
On non-ssl websites, entering a shared IP address assigned to the domain results in defaulting to whichever website on port 80 is listed first in httpd.conf.

Is there an easy way to redirect all IPs on a server to the default 'Sorry' page? Options in Tweak Settings don't seem to address this.
 

Jcats

Well-Known Member
PartnerNOC
May 25, 2011
807
160
168
New Jersey
cPanel Access Level
DataCenter Provider
Are you sure port 80, usually this is the case but only for port 443(SSL), this is because of SNI.

In the browser do you see http or https when browsing to the IP?

Are the IP's dedicated IP's or shared?
 

jndawson

Well-Known Member
Aug 27, 2014
342
37
78
Western US
cPanel Access Level
DataCenter Provider
Are you sure port 80, usually this is the case but only for port 443(SSL), this is because of SNI.
Yes.
In the browser do you see http or https when browsing to the IP?
Entering IP in a browser results in http, and pointing to the first port 80 entry in httpd.conf. Using https results in pointing to the first port 443 entry in httpd.conf.

Are the IP's dedicated IP's or shared?
Issue is with shared IPs.

When reassigning the domain to a dedicated IP, the issue then repeats itself by rendering the now-first port 80/443 entry in httpd.conf.
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,273
1,281
313
Houston
Hi @jndawson

I've never seen this behavior exhibit itself on a shared IP over http. The default behavior for connections over http would be to show the default page not the first page in the apache configuration as suggested by @Jcats . The only exception to this being in the instance of a dedicated IP address, or if you've customized the configuration to include multiple shared IP's which is not supported by cPanel.

Would it be possible for you to either private message me an IP address to check or open a ticket with us using the link in my signature?
 

jndawson

Well-Known Member
Aug 27, 2014
342
37
78
Western US
cPanel Access Level
DataCenter Provider
I've never seen this behavior exhibit itself on a shared IP over http. The default behavior for connections over http would be to show the default page not the first page in the apache configuration as suggested by @Jcats . The only exception to this being in the instance of a dedicated IP address, or if you've customized the configuration to include multiple shared IP's which is not supported by cPanel.

Would it be possible for you to either private message me an IP address to check or open a ticket with us using the link in my signature?
We have several shared IPs on the box. The shared IP that is also assigned to the box does display the default page when the IP is used; the others do not. We know the basis for the issue - we just need to know if there's a handy way to redirect those shared IPs to the default page. We could use an include file for httpd.conf, but there's no guarantee the entry will be first since one can't edit httpd.conf directly.
 

jndawson

Well-Known Member
Aug 27, 2014
342
37
78
Western US
cPanel Access Level
DataCenter Provider
After more poking around, we found whm > service configuration > Apache configuration > Include editor, which has a pre-virtual host include editor which is supposed to place the virt host entry first above the rest of the virt entries.

Here's what we added - seems to work nicely with shared IPs and leave dedicated IPs to their own websites:
Code:
<VirtualHost 123.*.*.*:80>
 RewriteEngine On
 RewriteCond %{HTTP_HOST} !^cp3.servername.tld$
 RewriteRule /.* https://cp3.servername.tld/ [R]
</VirtualHost>
We used variables for the IP quads since we have a couple of different subnets on that server. Note that using a virtual host for port 443 still ends up pointing to the first SSL virtual host; possibly due to ssl negotiating prior to reading httpd.conf.

If anybody sees any issues with this, or a more efficient method, we'd appreciate the feedback.
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,273
1,281
313
Houston
Hi @jndawson

I'm glad to hear you found a solution and thanks for posting what worked for you. I hope you get some feedback from others in the community in regards to your solution as well.

Thanks!
 
  • Like
Reactions: jndawson