【发布时间】:2015-07-29 05:42:13
【问题描述】:
我正在尝试将 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 请求仍然可以,但尝试在 @ 上连接 websocket 987654323@ 给出 404 错误。我是否需要其他东西来允许 Elastic Beanstalk 上的 websocket?
【问题讨论】:
标签: nginx jar websocket amazon-elastic-beanstalk