Skip to content

Instantly share code, notes, and snippets.

@arlando
Created December 3, 2013 04:19
Show Gist options
  • Select an option

  • Save arlando/7763818 to your computer and use it in GitHub Desktop.

Select an option

Save arlando/7763818 to your computer and use it in GitHub Desktop.
I was using the Yeoman Marionette Generator to make a site. Node.js serves as an API server, socketIO tool, and serves the index. Nginx handles the static assets. This configuration seems to work okay with the architecture...
#user nobody;
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
access_log logs/access.log;
#gzip compression
gzip on;
gzip_comp_level 6;
gzip_vary on;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_buffers 16 8k;
#Proxy for blog
upstream blogv2_upstream {
server 127.0.0.1:5000;
keepalive 64;
}
server {
listen 8080;
server_name localhost;
#location / {
# proxy_redirect off;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header Host $http_host;
# proxy_set_header X-NginX-Proxy true;
# proxy_set_header Connection "";
# proxy_http_version 1.1;
# proxy_pass http://blogv2_upstream;
# #root /data/www;
#}
location / {
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection "";
proxy_http_version 1.1;
root /Users/arlando/blogv2/blogv2/dist;
}
#proxy to Node's socket
location /socket.io/ {
proxy_pass http://blogv2_upstream;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
#proxy to our API
location /api/v1/ {
proxy_pass http://blogv2_upstream;
proxy_http_version 1.1;
}
location ~ ^/(styles/|scripts/|bower_components/|images/|robots.txt|humans.txt|favicon.ico) {
root /Users/arlando/blogv2/blogv2/dist;
access_log off;
expires max;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment