Skip to content

Instantly share code, notes, and snippets.

@v0112358
Last active August 17, 2018 04:56
Show Gist options
  • Save v0112358/6aea69ee5d85066c3bbb870386b86e7c to your computer and use it in GitHub Desktop.
Save v0112358/6aea69ee5d85066c3bbb870386b86e7c to your computer and use it in GitHub Desktop.
Configure Wordpress use SSL behind reverse proxy (Nginx)
- Topology: Client ==> Reverse proxy (Nginx is listened at port 443) ======> Backend (Apache is listened at port 80).
- Nginx configure
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- Wordpress configure:
cat wp-config.php
.....
/**
* Make PHP HTTPS aware via HTTP_X_FORWARDED_PROTO
*/
if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
$_SERVER['HTTPS']='on';
}
/** Sets up WordPress vars and included files. */
define('FS_METHOD', 'direct');
require_once(ABSPATH . 'wp-settings.php');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment