Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tech:others:wordpress_nginx [2017/11/27 06:26] (current)
Line 1: Line 1:
 +====== 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)
 +
 +<code php>
 +// 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'​];​
 +}
 +</​code>​
 +
 +4. I have the below proxy header settings in my NGINX (for all sites):
 +<code nginx>
 +### 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;​
 +</​code>​
 +
 +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)