Use case: a Play application behind Amazon ELB which is configured for TCP load balancing.
Amazon ELB provides the client's connection information via Proxy Protocol 1.
How to retrieve this information in Play?
If you have turned on proxy protocol support, it adds haproxy's proprietary proxy protocol header as the first thing sent in the TCP request. Effectively, it adds the following line before the http request:
PROXY TCP4 192.168.0.1 192.168.0.11 56324 443
This is not valid HTTP, so Play does not support it, if Play receives a request like this, it will simply return an error.
What you can do is install a proxy on your EC2 node that does support proxy protocol, and then have that add the proxy protocol ip address into the X-Forwarded-For header to the Play app. Instructions on how to configure nginx to support proxy protocol in this way can be found here:
https://chrislea.com/2014/03/20/using-proxy-protocol-nginx/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With