Last active
August 17, 2018 04:56
-
-
Save v0112358/6aea69ee5d85066c3bbb870386b86e7c to your computer and use it in GitHub Desktop.
Configure Wordpress use SSL behind reverse proxy (Nginx)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - 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