WordPress: Too Many Redirects Issue when NGINX reverse proxy to Apache

I installed NGINX and put it in front of Apache for SSL offloading and caching static content. Traffic is proxied from Nginx to Apache.  When I tried to open site via https, it returned this painful error “Too Many Redirects”.

Try to add this in your wp-config.php – if you have everything else configured correctly, it should work:

$_SERVER['HTTPS'] = 'On';

[kofi]

18 Comments

Got Something To Say:

Your email address will not be published. Required fields are marked *

*

I accept the Privacy Policy

This site uses Akismet to reduce spam. Learn how your comment data is processed.

You are a life saver! Thank you so much for posting this!

Kudos for this. Would be great to have a little more detail to this solution. Thanks@

I’ve searched a lot, but this artcle helped me so much.
Thank you very muuuuuuch 🙂

OMG, I wish I had read this 3 hours ago! Thank you, I finally can sleep now!
Just one line, and yet it makes all the different. A must for everyone using docker, for example, with an nginx reverse proxy.

Just add this to your proxy_pass configuration

proxy_set_header X-Forwarded-Proto https;

as you see wp is already searching for that

if (isset($_SERVER[‘HTTP_X_FORWARDED_PROTO’]) && $_SERVER[‘HTTP_X_FORWARDED_PROTO’] === ‘https’) {
$_SERVER[‘HTTPS’] = ‘on’;
}

This is the only answer to my 100 question to my senior dev.HAHAHA

Very useful. It worked for me.

I tried many other solutions but this one did the trick.

Thanks a lot!

I was struggling with this issue for more than 6 hours
Thank you so much

You are soooo amazing. I could kiss your.

Amazing, you saved me hours of work ! Thank you !

Truly amaizing how such a small line of code can change so much. We are really thankful for this. Regards

Life saver!!!!

THIS WORKED !!!!! THANK YOU – HOURS SPENT AND HOURS SAVED

Cannot believe this worked. You win the internet.

© 2024 geegkytuts.net
Hosted by SIEL


About author