-
-
Save artzub/b4eac6f3a69f0483186d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add to nginx.conf http section | |
map $http_upgrade $connection_upgrade { | |
default upgrade; | |
'' close; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment