In the application load balancing, we need to use WebSockets XSS
- AWS ELB doesn’t support WebSockets on HTTP/HTTPS (Layer 7).
- Switching ELB protocols to TCP/SSL does the trick, but we do not receive X-Forwarded-For header from ELB anymore.
This can be done by enabling proxy protocol on the LB, so it starts using proxy_protocol. We could do only from AWS CLI. In order to do this, the web server must be Nginx. Proxy protocol adds an additional header to requests to pass server client’s IP which can be used if there is a load balancer between your server and clients.
In our case, the server is configured with Apache web server. So we can’t use proxy_protocol anymore. On Apache, it could be fixed by creating an additional target group with websocket port and enabling stickiness. Then increase the connetion timout of the application. Here we have 3 WebSockets. So we have created 3 Listeners for LB and passed the request to corresponding Target groups (websockets). From that websockets target, it goes to the target instances.
Customer Benefits: The main benefit is assured HA for his website. AWS autoscaling will adjust the resource capacity, so it is cost effective. We need to pay only for what we use. By the help of Elastic Cache, the contents will be served faster as it will load from Cache cluster. So less resource usage. This architecture will be able to handle to up to 50 K requests and this was confirmed after serveral benchmarking tests.