Created
December 3, 2018 09:41
-
-
Save gladilindv/c934df3f0ef9c8be371ea6d7d4e84ca7 to your computer and use it in GitHub Desktop.
NGINX Reverse Proxy
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
http { | |
# NGINX will handle gzip compression of responses from the app server | |
gzip on; | |
gzip_proxied any; | |
gzip_types text/plain application/json; | |
gzip_min_length 1000; | |
server { | |
listen 80; | |
# NGINX will reject anything not matching /api | |
location /api { | |
# Reject requests with unsupported HTTP method | |
if ($request_method !~ ^(GET|POST|HEAD|OPTIONS|PUT|DELETE)$) { | |
return 405; | |
} | |
# Only requests matching the whitelist expectations will | |
# get sent to the application server | |
proxy_pass http://app:3000; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host $host; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_cache_bypass $http_upgrade; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment