mattgodbolt / seasocks

Simple, small, C++ embeddable webserver with WebSockets support
BSD 2-Clause "Simplified" License
734 stars 120 forks source link

Connection->getRemoteAddress() when running behind a load balancer #149

Closed kanak closed 3 years ago

kanak commented 3 years ago

... will just return the IP address and port of the load balancer.

I'm migrating from tornado web server, which has an option to respect the X-Real-Ip, X-Forwarded-For headers:

https://www.tornadoweb.org/en/stable/httpserver.html#tornado.httpserver.HTTPServer

I'm currently doing a quick and dirty conn->getHeaeder("X-Real-IP"), but maybe this should be baked in?

mattgodbolt commented 3 years ago

I don't think that should be baked in: the remote address really is the load balancer. If applications want to use the "X-Real-IP" (or whatever custom header their load balancer uses), then it's pretty simple for them to wrap the code appropriately. I know some web frameworks have support for this and they support a number of different "no, really this IP" but not by default (it can be spoofed etc)... so I think this is something that Seasocks won't handle itself. Sorry!