Saturday, May 16, 2020

[SOLVED] Wordpress Behind Reverse Proxy: Too Many Redirect Error

I have installed a wordpress behind a reverse proxy to conserve IP address and also to simplify SSL certification renewal.

However I have encountered issue with wordpress thinking that it is running on NON-HTTPS while in-fact it is.

To trick wordpress to think it is running in SSL mode, I inserted the following PHP codes on the very top of wp-config.php:


if ( (!empty( $_SERVER['HTTP_X_FORWARDED_HOST'])) ||
     (!empty( $_SERVER['HTTP_X_FORWARDED_FOR'])) ) {
    $_SERVER['HTTPS'] = 'on';
}

I hope this helps somebody. Thanks for reading -LinuxCloudCoder

2 comments:

  1. Hey what a brilliant post I have come across and believe me I have been searching out for this similar kind of post for past a week and hardly came across this. Thank you very much and will look for more postings from you. reverse mortgage in Utah

    ReplyDelete
  2. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. diebestenvpn

    ReplyDelete