I am trying to set up a reverse proxy for requesting rest api, let's say for instance that i am making a request like this:
127.0.0.1/v1/resources/get/list/23948
The expected request on target host should be like this:
http://api.example.com/v1/resources/get/list/23948?key=skdma239mfmd0idfm9844
You can see in the expected request there is a query string, the reason for this is to protect the values from the client so the sensitive data is not leaked.
I have tried location definitions like this:
location /v1/resources/get/ {
proxy_pass http://api.example.com$uri?key=sdkmfg234msdkmad9898
}
but for some reason NGINX responds with 500.
Is it possible to add query strings in a proxy_pass
? or is it possible to add the query string to the reverse proxy so this data is protected?
NOTE: i know there is a question in stackoverflow that looks similar to this one, but none of the answers in that question helps with my problem. I have edited the code on how i attempted it last time and nginx responds 502 status