Skip to content

Instantly share code, notes, and snippets.

@rajaramtt
Created November 27, 2018 12:37
Show Gist options
  • Save rajaramtt/24662c6f024e8ae81c264171bfabbe1b to your computer and use it in GitHub Desktop.
Save rajaramtt/24662c6f024e8ae81c264171bfabbe1b to your computer and use it in GitHub Desktop.
nginx angular and node proxy config
server {
listen 80;
server_name 0.0.0.0;
root /var/www/html/dist;
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
# This will allow you to refresh page in your angular app. Which will not give error 404.
}
# proxy pass
location /api/ {
proxy_pass http://127.0.0.1:4000/;
}
# Sub folder
location /other {
alias /var/other/other/dist;
try_files $uri /other/index.html;
}
}
@rajaramtt
Copy link
Author

WebSocket Proxy

location /xxx/xxx/ {
proxy_pass http://xx.xxx.xx:xxx/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment