2016年6月6日 星期一

websocket on aws elb nginx setting

直接新增在myapp/.ebextensions/ environmentvariables.config

Hullo - I got this working using Node, NGINX, SSL, and an ELB on Elastic Beanstalk doing the following:
Create a container command in .ebextensions to modify the nginx configuration script to include proxy websockets:

前面兩個要斷行
container_commands:
    00proxy:
        command: sed -i 's/proxy_http_version.*/proxy_http_version\ 1.1\;\n\ \ \ \ \ \ \ \ proxy_set_header\ \ \ \ \ \ \ \ Upgrade\ \ \ \ \ \ \ \ \ \$http_upgrade\;\n\ \ \ \ \ \ \ \ proxy_set_header\ \ \ \ \ \ \ \ Connection\ \ \ \ \ \ \"upgrade\"\;/g' /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf
Install your SSL cert on the load balancer using the Elastic Beanstalk web console.
Then go to the EC2 web console, and change the load balancer to listen on SSL 443 -> TCP 80. This did not working when I changed it in the EB web console, I had to do it directly in EC2.
That should get everything working. I haven't had to do any redirects and I managed to get NGINX working too.