How to get X-Real-IP upstream request header? #567
-
i am using kong developing with a proxy-wasm base gosdk for some bussine logic, but i can't the the real ip with X-REAL-IP in header using default config of kong container config like this
my getting header code is below
but the result is no include x-real-ip sector , logs are below
And i think base on the describe beolwo, realip module will work before my wasm filtter |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Because these headers are not actually part of the client request, they cannot be retrieved via Nginx variables can be retrieved in Wasm via the |
Beta Was this translation helpful? Give feedback.
Because these headers are not actually part of the client request, they cannot be retrieved via
get_http_request_headers()
. Kong injects these headers in the upstream request via the ngx_http_proxy_module, by first placing the desired value in the$remote_addr
Nginx variable, which is later picked-up atproxy_pass
time. To retrieve this header in Kong you will therefore need to read the$remote_addr
Nginx variable.Nginx variables can be retrieved in Wasm via the
get_property()
SDK function. All Nginx variables are accessible through thengx.VAR
property prefix, e.g.ngx.remote_addr
. In the Rust SDK I believe this translates toget_property(!vec["ngx", "remote_addr"])
(API expects a vecto…