Skip to content

Instantly share code, notes, and snippets.

@wernersmit
Created March 7, 2017 19:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wernersmit/a2db422162e28ea0808e3e6918728ce2 to your computer and use it in GitHub Desktop.
Save wernersmit/a2db422162e28ea0808e3e6918728ce2 to your computer and use it in GitHub Desktop.
Plesk Nginx Extra Config for Custom Reverse Proxy - nodejs app or other host IP
## If someone enters two slashes, '//' combine them into one
merge_slashes on;
## Make sure everything is forwarded to https://
if ($scheme = http) {
return 301 http://$server_name$request_uri;
}
## Remove trailing slashes
rewrite ^/(.*)/$ /$1 permanent;
## If the index.html (can be anything) is looked for, redirect to /
## Fix for Plesk location /{} forcing index.html to be loaded
rewrite ^(.+)/index.html$ $1 permanent;
location = /index.html {
internal;
error_page 404 =301 $scheme://domain.com/;
}
## If the location is equal to /
location = / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:3000;
}
## Proxy pass everything else to node as well
location ~ / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:3000;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment