Forked from chris-garrett/gist:8b9831ca2e2c05eacaa16b75f15213bf
Created
December 1, 2018 18:06
-
-
Save olaferlandsen/6b643b9a3945458b7eba1acdb4284e54 to your computer and use it in GitHub Desktop.
initial nginx config for feathers.js
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
upstream app_server { | |
ip_hash; | |
server app_react:3000 max_fails=3 fail_timeout=30s; | |
} | |
upstream api_server { | |
ip_hash; | |
server api_feathers:3040 max_fails=3 fail_timeout=30s; | |
} | |
# this section is needed to proxy web-socket connections | |
map $http_upgrade $connection_upgrade { | |
default upgrade; | |
'' close; | |
} | |
server { | |
listen 80 default_server; | |
listen [::]:80 default_server ipv6only=on; | |
root /usr/share/nginx/html; | |
index index.html index.htm; | |
ssl on; | |
ssl_certificate /work/ssl/certificate-bundle.pem; | |
ssl_certificate_key /work/ssl/private-key-nopass.pem; | |
location /favicon.ico { | |
alias /assets/web/favicon.ico; | |
} | |
location /assets/ { | |
rewrite ^/assets/(.*) /$1 break; | |
root /assets/web; | |
autoindex off; | |
} | |
# Make site accessible from http://localhost/ | |
server_name io.nesteggs.ca; | |
client_max_body_size 20M; | |
proxy_max_temp_file_size 2048m; # default 1024m | |
rewrite_log on; | |
location / { | |
#access_log off; | |
proxy_pass http://app_server; | |
proxy_http_version 1.1; | |
proxy_redirect off; | |
proxy_buffering off; | |
proxy_cache off; | |
proxy_cache_bypass $http_upgrade; | |
add_header Cache-Control no-cache; | |
proxy_set_header Upgrade $http_upgrade; #for websockets | |
proxy_set_header Connection $connection_upgrade; | |
proxy_set_header Host $host; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Real-Scheme $scheme; | |
proxy_set_header X-Real-Host $host; | |
proxy_set_header X-Real-Uri $request_uri; | |
proxy_set_header User-Agent $http_user_agent; | |
proxy_set_header Referer $http_referer; | |
proxy_pass_header Authorization; | |
proxy_pass_header Set-Cookie; | |
} | |
location /socket.io { | |
#access_log off; | |
proxy_pass http://api_server; | |
proxy_http_version 1.1; | |
proxy_redirect off; | |
proxy_buffering off; | |
proxy_cache off; | |
proxy_cache_bypass $http_upgrade; | |
add_header Cache-Control no-cache; | |
proxy_set_header Upgrade $http_upgrade; #for websockets | |
proxy_set_header Connection $connection_upgrade; | |
proxy_set_header Host $host; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Real-Scheme $scheme; | |
proxy_set_header X-Real-Host $host; | |
proxy_set_header X-Real-Uri $request_uri; | |
proxy_set_header User-Agent $http_user_agent; | |
proxy_set_header Referer $http_referer; | |
proxy_pass_header Authorization; | |
proxy_pass_header Set-Cookie; | |
} | |
#location /api { | |
# return 302 $uri/; | |
#} | |
location /api/ { | |
#access_log off; | |
rewrite ^/api/(.*) /$1 break; | |
proxy_pass http://api_server; | |
proxy_http_version 1.1; | |
proxy_redirect off; | |
proxy_buffering off; | |
proxy_cache off; | |
proxy_cache_bypass $http_upgrade; | |
add_header Cache-Control no-cache; | |
proxy_set_header Upgrade $http_upgrade; #for websockets | |
proxy_set_header Connection $connection_upgrade; | |
proxy_set_header Host $host; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Real-Scheme $scheme; | |
proxy_set_header X-Real-Host $host; | |
proxy_set_header X-Real-Uri $request_uri; | |
proxy_set_header User-Agent $http_user_agent; | |
proxy_set_header Referer $http_referer; | |
proxy_pass_header Authorization; | |
proxy_pass_header Set-Cookie; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment