HTTPS in WordPress behind a NGINX Reverse Proxy with SSL Offload

Enabling HTTPS in WordPress behind a NGINX Reverse Proxy SSL Offload

1. Leave the WordPress Address (URL) as HTTP

2. Change the Site Address (URL) to HTTPS

Note: If you mess up the above settings and cannot reload WP, then you may change this in the options table in the WP database

3. Add these lines to wp-config.php (I added it at the beginning)

// Added for HTTPS behind a NGINX Reverse Proxy with SSL Offload
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
    $_SERVER['HTTPS']='on';
 
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
    $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
}

4. I have the below proxy header settings in my NGINX (for all sites):

### proxy-header ###
proxy_set_header        Accept-Encoding   "";
proxy_set_header        Host              $http_host;
proxy_set_header        X-Forwarded-By    $server_addr:$server_port;
proxy_set_header        X-Forwarded-For   $remote_addr;
proxy_set_header        X-Forwarded-Proto $scheme;
map $scheme $msiis      { http off; https on; }
proxy_set_header        Front-End-Https   $msiis;

Reference: https://www.variantweb.net/blog/wordpress-behind-an-nginx-ssl-reverse-proxy/


QR Code
QR Code tech:others:wordpress_nginx (generated for current page)