Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Redirect IP requests to the default cPanel page?

Discussion in 'General Discussion' started by jndawson, Jun 7, 2018.

  1. jndawson

    jndawson Well-Known Member

    Joined:
    Aug 27, 2014
    Messages:
    199
    Likes Received:
    20
    Trophy Points:
    18
    Location:
    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.
     
  2. Jcats

    Jcats Well-Known Member

    Joined:
    May 25, 2011
    Messages:
    720
    Likes Received:
    123
    Trophy Points:
    168
    Location:
    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?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. jndawson

    jndawson Well-Known Member

    Joined:
    Aug 27, 2014
    Messages:
    199
    Likes Received:
    20
    Trophy Points:
    18
    Location:
    Western US
    cPanel Access Level:
    DataCenter Provider
    Yes.
    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.

    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.
     
  4. cPanelLauren

    cPanelLauren Forums Analyst II
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    3,137
    Likes Received:
    222
    Trophy Points:
    173
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    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?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. jndawson

    jndawson Well-Known Member

    Joined:
    Aug 27, 2014
    Messages:
    199
    Likes Received:
    20
    Trophy Points:
    18
    Location:
    Western US
    cPanel Access Level:
    DataCenter Provider
    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.
     
  6. jndawson

    jndawson Well-Known Member

    Joined:
    Aug 27, 2014
    Messages:
    199
    Likes Received:
    20
    Trophy Points:
    18
    Location:
    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.
     
  7. cPanelLauren

    cPanelLauren Forums Analyst II
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    3,137
    Likes Received:
    222
    Trophy Points:
    173
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    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!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    jndawson likes this.
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice