SOLVED Settings forcing connections to HTTPS?

inspiredearth

Member
Dec 1, 2015
19
2
3
New Zealand
cPanel Access Level
Reseller Owner
Hi..

I have added Redis and Nginx to a WHM/CP server, following the excellent instructions and scripts provided and recommended by @Jcats on this thread: Extremely slow TTFB

There's one part where I've come a bit unstuck.

According to the information here, I understand I need to set Cloudflare to use "Flexible SSL" in order to gain the full benefits of the Nginx implementation. However, when I set it to "Flexible", once Cloudflare has had a change to update itself, I ended up unable to load the site. We have just two sites on the server, sharing the one dedicated IP.

They end up in redirect loop (ERR_TOO_MANY_REDIRECTS).

Looking for information on this, I found the following article on cloudflare.com: Why does Flexible SSL cause a redirect loop?

It says,

Cloudflare's Flexible SSL option can cause redirect loops when combined with certain configurations. Because all requests are sent to origins over HTTP when Flexible SSL is selected, an origin configured to redirect HTTP requests to HTTPS will cause a redirect loop, causing browsers to display "The page isn’t redirecting properly" or "ERR_TOO_MANY_REDIRECTS".

If you encounter this, you will need to remove redirects at your origin. Look for RewriteRules in Apache or rewrite directives/301 return directives in Nginx and remove them to clear the issue.
We have no relevant rewrite rules in the .htaccess files on the two sites. So I am assuming they are either occurring at a WHM Apache server level, or maybe in the Nginx plug-in.

I would like to know if there are any settings in WHM that might force HTTP requests over to HTTPS?

Or, if anyone else has encountered this issue, and has a solution.
 

24x7server

Well-Known Member
Apr 17, 2013
1,894
91
78
India
cPanel Access Level
Root Administrator
Hi,

We have no relevant rewrite rules in the .htaccess files on the two sites. So I am assuming they are either occurring at a WHM Apache server level, or maybe in the Nginx plug-in.
There is only 2 place where this can actually occur, one is at the .htaccess level and other is at the webserver level. I doubt that there would be such redirection looping set in the cPanel provided Apache.. However, there could be possibility of having it in the Nginx, so you have to check the Nginx settings once again to check for this..

What does the Nginx and Apache error logs suggests when the actual redirect error occurs? Open up to SSH login session and execute the below command one on each terminal and then browse the website where you see redirect loop..
# tail -f /usr/local/apache/logs/error_logs.
# tail -f /var/log/nginx/error_logs


On more thing you can try is try renaming the .htaccess file in the account to see if that provides any effect on the website regarding the redirect loop..

# mv .htaccess .htaccess-org
 

cPanelMichael

Technical Support Community Manager
Staff member
Apr 11, 2011
47,911
2,233
363
cPanel Access Level
DataCenter Provider
Twitter
I would like to know if there are any settings in WHM that might force HTTP requests over to HTTPS?
Hello,

There's nothing configured to force redirects by default in cPanel & WHM, except in the case of access attempts to cPanel/WHM/Webmail (see the "Redirection" section in "WHM >> Tweak Settings").

If you are using Engintron, check out their document here regarding the custom rules file:

Engintron & the "Custom Rules" file (for Nginx) · engintron/engintron Wiki · GitHub

Thank you.