Skip to content

Instantly share code, notes, and snippets.

@chris-garrett
Created December 13, 2017 00:40
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save chris-garrett/8b9831ca2e2c05eacaa16b75f15213bf to your computer and use it in GitHub Desktop.
Save chris-garrett/8b9831ca2e2c05eacaa16b75f15213bf to your computer and use it in GitHub Desktop.
initial nginx config for feathers.js
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