Skip to content

Instantly share code, notes, and snippets.

@hophacker
Forked from atma/nginx.conf
Created October 1, 2015 09:46
Show Gist options
  • Save hophacker/e1832e6d21aa1ea4e882 to your computer and use it in GitHub Desktop.
Save hophacker/e1832e6d21aa1ea4e882 to your computer and use it in GitHub Desktop.

Revisions

  1. @atma atma created this gist Aug 18, 2013.
    5 changes: 5 additions & 0 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    # Add to nginx.conf http section
    map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
    }
    52 changes: 52 additions & 0 deletions site.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    upstream some_upsteram_com {
    server 127.0.0.1:3000;
    keepalive 15;
    }

    server {
    listen 80;

    root /home/user/www/public;
    index index.html index.htm;

    access_log /home/user/logs/site-access.log;
    error_log /home/user/logs/site-error.log;

    server_name site.com www.site.com;

    large_client_header_buffers 8 32k;

    location / {
    try_files $uri @nodejs;
    }


    # Important! Serve client socket.io file as normal static file, e.g. /js/libs/socket.io/socket.io.min.js
    location /socket.io/ {
    proxy_pass http://some_upsteram_com;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_redirect off;

    proxy_buffers 8 32k;
    proxy_buffer_size 64k;

    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;
    }

    location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
    expires 30d;
    }

    location @nodejs {
    proxy_pass http://some_upsteram_com;
    }

    location ~ /\. {
    deny all;
    }
    }