`

websoket ngix域名连接400

 
阅读更多
出现400问题是因为ngix将请求拦截,需要做以下处理(红色部分)
# we're in the http context here
map $http_upgrade $connection_upgrade {
  default upgrade;
  ''      close;
}


# the Meteor / Node.js app server
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-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;

  # pass the host header - http://wiki.nginx.org/HttpProxyModule#proxy_pass

    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;

  }

}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics