Skip to content

Instantly share code, notes, and snippets.

@foru17
Created April 18, 2015 07:18
Show Gist options
  • Save foru17/3e31cb313bba4cd227bf to your computer and use it in GitHub Desktop.
Save foru17/3e31cb313bba4cd227bf to your computer and use it in GitHub Desktop.
nginx websocket配置
# we're in the http context here
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# Node Nginx 配置
server {
server_name yourdomain.com;
access_log /etc/nginx/logs/yourapp.access;
error_log /etc/nginx/logs/yourapp.error error;
location / {
proxy_pass http://localhost:3000;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_http_version 1.1;
# WebSocket proxying - from http://nginx.org/en/docs/http/websocket.html
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment