ElasticBeanstalk Websites Giving 404

I am trying to deploy a websocket server on Elastic Beanstalk. I have a Docker container that contains both nginx and a jar server, with nginx just doing the redirect. Nginx.conf looks like this:

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;
}

      

I can run this docker locally and everything works fine - HTTP requests are served and I can connect websites using ws://localhost:80/ws/

However, when I deploy to Elastic Beanstalk, the http requests are still ok but trying to connect websockets ws://myjunk.elasticbeanstalk.com:80/ws/

gives an error 404. Do I need anything else to allow beanstalk Web sites?

+3


source to share


1 answer


Ok, it worked. I need an ElasticBeanstalk load balancer to use TCP instead of HTTP.



To do this from the AWS console (as described on 5/16/2015), go to the ElasticBeanstalk environment, select Configuration from the left menu, under Network Layer there is a Load Balancing pane, Click its gear, then you can change the load balancing protocol from http to tcp.

+3


source







All Articles