这里是我的nginx的配置
server {
listen 80;
server_name _;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://flask:8001;
}
location /socket.io {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass http://flask:8001/socket.io;
}
}
对于应用程序基于此代码
其结果是,我无法连接从代码我的客户端页面的WebSocket
var socket = io.connect(location.protocol + '//' + document.domain + ':' + (location.port || 80) + namespace)
当我尝试使用include proxy_params;
在nginx的配置行,我得到2018年3月6日19时52分06秒[EMERG] 1#1:打开() “的/ etc / nginx的/ proxy_params” 失败:(2没有这样的文件或目录)在/ etc / nginx的/ conf.d / default.conf:6
我哪里错了,如何让nginx的检索WebSocket连接?