Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@gladilindv
Created December 3, 2018 09:41
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 gladilindv/c934df3f0ef9c8be371ea6d7d4e84ca7 to your computer and use it in GitHub Desktop.
Save gladilindv/c934df3f0ef9c8be371ea6d7d4e84ca7 to your computer and use it in GitHub Desktop.
NGINX Reverse Proxy
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