nginx-ElasticBeanstalk上的Websocket提供404

我正在尝试将Websocket服务器部署到Elastic Beanstalk.
我有一个既包含Nginx又包含jar服务器的Docker容器,其中Nginx只是进行转发. Nginx.conf是这样的:

listen 80;
location /ws/ {             # <-- this part only works locally
    proxy_pass http://127.0.0.1:8090/;     # jar handles websockets on port 8090
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}
location / {                     # <-- this part works locally and on ElasticBeanstalk
    proxy_pass http://127.0.0.1:8080/;   # jar handles http requests on port 8080
    proxy_set_header   Host $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-Host $server_name;
}

我可以在本地运行此docker,并且一切正常-可以处理http请求,并且可以使用ws:// localhost:80 / ws /连接websocket.但是,当我部署到Elastic Beanstalk时,http请求仍然可以,但是尝试在ws://myjunk.elasticbeanstalk.com:80 / ws /上连接websockets会出现404错误.我是否需要其他东西才能在Elastic Beanstalk上允许websocket?

最佳答案
好吧,让它正常工作.我需要ElasticBeanstalk负载平衡器以使用TCP而不是HTTP.

要从AWS控制台(如2015年5月16日所述)执行此操作,请转到您的ElasticBeanstalk环境,在左侧菜单中选择“配置”,在“网络层”下,有一个负载平衡”窗格.单击其齿轮,然后可以将负载均衡器协议从http更改为tcp.

相关文章

Nginx (engine x) 是一个高性能的HTTP和反向代理服务,也是一...
本地项目配置 1 复制 luffy/settings/dev.py为prop.py 修改l...
nginx不仅可以隐藏版本信息,还支持自定义web服务器信息 先看...
一 、此次漏洞分析 1 nginx HTTP/2漏洞 [nginx-announce] ng...
###进入nginx 目录cd /usr/local/nginx###递归显示 2 级目录...
在cmd命令窗口输入下面命令进行查看 tasklist /fi "ima...