I am migrating a node.js app from Heroku to AWS Elastic Beanstalk that uses WebSockets on port 80. The WebSockets are returning a 301 error on AWS Elastic Beanstalk, but not on
I found part of the answer here, https://scopestar.com/blog/aws/elasticbeanstalk/websockets/2016/10/21/enable-websockets-on-elasticbeanstalk-nginx-proxy.html
I added a file in the .ebextensions
folder with the following content and that fixed it for single instance environments.
container_commands:
01_nginx_websocket_support:
command: |
sed -i '/\s*proxy_set_header\s*Connection/c \
proxy_set_header Upgrade $http_upgrade;\
proxy_set_header Connection "upgrade";\
' /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf
To get the WebSockets to work on the load balanced, auto scaling environment I needed to do the following in addition