Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save opensourcelib/78ce4d44b54306b0d98a7ee173b79c36 to your computer and use it in GitHub Desktop.
Save opensourcelib/78ce4d44b54306b0d98a7ee173b79c36 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