Skip to content

Instantly share code, notes, and snippets.

@SunDi3yansyah
Created February 26, 2016 06:45
Show Gist options
  • Save SunDi3yansyah/bea6ab08c686e03ce3ec to your computer and use it in GitHub Desktop.
Save SunDi3yansyah/bea6ab08c686e03ce3ec to your computer and use it in GitHub Desktop.
Configuration NGINX with NodeJS
map $http_origin $cors_header {
default "";
"~^http?://[^/]+\.sundi3yansyah\.id(:[0-9]+)?$" "$http_origin";
}
server {
listen 80;
server_name node.sundi3yansyah.id;
location / {
proxy_pass http://188.166.228.104:1234;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
add_header Access-Control-Allow-Origin $cors_header;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-NginX-Proxy true;
proxy_redirect off;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment