Created
March 7, 2017 19:12
-
-
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
This file contains 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
## 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