AWS ELB and Secure WebSockets with Play Framework

UPDATE 2016/08/10: AWS improved their ELB and they now support websocket and http/2 protocols. More on this link https://aws.amazon.com/blogs/aws/new-aws-application-load-balancer/.

AWS ELB does not support WSS protocol on its HTTPS endpoints. If you are using it for load balancing this becomes a blocker for scaling your service. Hopefully there is a way to overcome this limitation.

Switching ELB protocols to TCP/SSL will not be enough as the server will not receive X-Forwarded-For header anymore.

To solve this you will need to

Add ProxyProtocol policy to ELB so it starts using proxy_protocol

Enable proxy_protocol support on nginx (Play unfortunatelly cannot be configured to understand proxy protocol at this moment :( )

Proxy protocol adds 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.

6. Test it out

Read next

Software engineering today is all about building better, [value-driven digital products](https://spicefactory.co/blog/2017/04/27/building-user-value-into-digital-products/) more efficiently. This 'mantra of efficiency' is especially present in the...