【发布时间】:2014-08-08 14:07:36
【问题描述】:
我有一个在 vm 上运行的 websocket 服务(远程地址端口 8090)。使用 Nginx 代理连接。 nginx配置如下:
server {
listen 80;
server_name _;
location / {
proxy_pass http://127.0.0.1:8090;
proxy_pass_request_headers on;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
从我的本地主机,我能够使用 ip 作为ws://111.11.1.1/websocket 连接到 websocket
但是,当我从本地主机或应用程序向远程 websocket websocket.sendTextMessage("Message") 发送消息时,我无法访问套接字..假设我的 nginx 配置有问题..
更新:通过添加更改 Nginx 的配置
http{ server{..location/{...}}}
当我重新启动 Nginx 服务时,我得到一个错误
nginx emerg http directive is not allowed here in /default.conf:1
nginx: configuration file /nginx.conf test failed
任何建议都有帮助!
【问题讨论】: