Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandys/ac1469089c076eda2df6 to your computer and use it in GitHub Desktop.
Save sandys/ac1469089c076eda2df6 to your computer and use it in GitHub Desktop.
Wordpress: nginx proxying to apache2. Wordpress installed in a subdirectory. All wp-admin and wp-login links working
# in wp-config.php
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/recipedia');
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/recipedia');
$_SERVER['REQUEST_URI'] = '/recipedia' . $_SERVER['REQUEST_URI'];
#in nginx config
location /recipedia/ {
proxy_pass http://127.0.0.1:85/;
#rewrite /recipedia/(.*) /$1 break;
#proxy_redirect http://127.0.0.1:85/ http://$host/recipedia/;
rewrite ^/recipedia/?$ / break;
rewrite ^/recipedia/(.*) /$1 break;
proxy_redirect off;
proxy_buffering on;
proxy_buffers 12 12k;
proxy_redirect off;
server_name_in_redirect off;
port_in_redirect off;
#proxy_set_header Referer $http_referer;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass_header Set-Cookie;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Server $http_host;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header X-M-Secure "true";
#proxy_set_header Host $http_host;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $remote_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
#fastcgi_param HTTP_HOST $host;
expires 5m;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment