Skip to content

How to get X-Real-IP upstream request header? #567

Answered by thibaultcha
ray1888 asked this question in Q&A
Discussion options

You must be logged in to vote

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 at proxy_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 the ngx.VAR property prefix, e.g. ngx.remote_addr. In the Rust SDK I believe this translates to get_property(!vec["ngx", "remote_addr"]) (API expects a vecto…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ray1888
Comment options

Answer selected by thibaultcha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #566 on July 10, 2024 14:19.