5

I deploy a nodejs application on the aws beanstalk servers and want to use socket.io feature based on WebSocket protocol. I know there's a discussion here to directly connect to nodejs servers instead of using nginx as an proxy server. But if I still want to have the nginx as proxy server because of extra features provide by nginx, such as static files, ...etc.

I find it's already support WebSocket proxying on nginx 1.3.13 and I found it seems aws elastic-beanstalk still use the 1.2.x nginx.

So I am wondering if there's any way to upgrade nginx version under beanstalk and how to enable WebSocket proxying to nodejs server.

Thanks

Community
  • 1
  • 1
HolaMan
  • 381
  • 1
  • 4
  • 11
  • For upgrading nginx version, you can use [Configuration File](http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers.html). After you upgraded the nginx version, you should double check the parameters which were passed from EB. – study Nov 07 '13 at 17:08
  • Do you have an example of updating nginx? – KBeckers Nov 21 '17 at 22:35
  • Check this out if you are using elastic beanstalk. https://stackoverflow.com/questions/47584103/socket-io-in-aws-elasticbeanstalk-node – coolboyjules Feb 01 '19 at 17:10

2 Answers2

0

You would need additional module enabled, which can be done during nginx compilation. To do that you would need to add below line to your configuration script.

--add-module=/root/nginx_patched/nginx_tcp_proxy_module

It is required if you would like to get sockets enabled, for example for node.js socket.io. Full tutorial can be found here. Sorry for the link but it is quite broad topic. You might need step by step guide if you starting from the scratch.

Hope it helps.

Mark Karwowski
  • 619
  • 6
  • 7
0

We use elastic beanstalk with multiple docker containers(allows you custom nginx version) with following

1.Nginx config

location /ws/ 
{
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";
  proxy_pass http://unix:/<<socket>>;
}
  1. Enable TCP mode load balancing in elastic load balancer if you are using one.
pratyush
  • 36
  • 2