Thank you for the info. However, I'm having an issue how where if I turn on Force HTTPS Redirect from the Domains section inside cPanel, within a couple minutes of doing this the site starts producing "too many redirects" errors:
ERR_TOO_MANY_REDIRECTS
If I turn off force https redirect, it starts working fine again. This is only happening with one specific account on my server and I'm not sure why. Any ideas?
Thanks,
Tommy
Hi
@tptompkins , this is a cPanel bug when your customer uses this option in conjunction with Cloudflare in Flex mode.
When activating the "
Force HTTPS Redirect" option in cPanel, the customer's website enters a redirection loop (ERR_TOO_MANY_REDIRECTS). This is because the redirection rule that cPanel create does not take
X-Forwarded-Proto into account, which is sented by all reverse proxies and is extensively documented.
More about it can be read here:
https://aws.amazon.com/pt/premiumsupport/knowledge-center/redirect-http-https-elb/
A simple solution for this would be to just add the rule below along with the existing rule responsible for the redirect inside
/etc/apache2/conf/httpd.conf
:
Apache config:
RewriteCond %{HTTP:X-Forwarded-Proto} !https
Note, if you are trying to fix this problem yourself, do not edit httpd.conf
directly, use "customize the Apache Virtual Host templates" instead. As in this image. https://imgur.com/WWrzCbN
I do not recommend correcting this on your own, because you will need to update the template manually after that. Ask cPanel support to correct the problem instead.
To reproduce this problem, just use a reverse proxy or Cloudflare with the Flex option enabled and activate the option "Force HTTPS Redirect".
I reproduced this problem with Varnish Cache, Nginx as a proxy, Cloudflare and load balancers.
I also tried my best to take it to the development team of cPanel and was created an internal case number
CPANEL-36901.
@cPRex Could you follow this up for us and update this page if it has any updates?
Thank you.