问题
I have read through the documentation (both API and Manual), and haven't seem to find any support by gwan for the X-Forwarded-For
header. The only thing I have found that could be related was REMOTE_BIN_ADDR
.
I know to get a client IP you can use REMOTE_ADDR
however my gwan servers are behind a HA Proxy load balancer, which forwards the client IP via X-Forwarded-For
.
Does Gwan not support this header?
回答1:
As far as we know, while widely used, the X-Forwarded-For
HTTP header is not part of the RFCs. Some servers, like Nginx, are using alternatives because proxy servers can "chain" the client IP address, leading to unreliable results.
On a side note, keep in mind that HTTP headers providing an X-Forwarded-For
value cannot be trusted... unless your own proxy is cleaning-up any previously setup value and adding its own. This makes this X-Forwarded-For
header less useful than expected at first glance - and surely contributes to explain why Nginx felt the need to create its own.
G-WAN initially supported this header but we have removed this entry because we believe that it is redundant with the native G-WAN reverse-proxy and load-balancer (a feature that was implemented last year but which is still not documented as documenting and exporting the interfaces in a polished way takes time - and we want to merge this feature with protocol handlers, to simplify things).
Note that, right now, you can easily parse it from the HTTP headers exposed by G-WAN, either from a handler
or from servlets
.
来源:https://stackoverflow.com/questions/15147503/x-forwarded-for-in-gwan