Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

path param and query param in nginx

$
0
0
I have an upstream nginx module with redis in the backend. The '/upstream/key/12345678' is the HTTP request which i need to process, i.e check if there is an entry for 12345678 in redis store and return its value.

I am able to process the following '/upstream?key=12345678 HTTP/1.1' by extracting the characters between '=' and ' ' in the handler function and creating a redis query in the create_request function. The config is as below :
location /upstream/ {
server_backend 127.0.0.1:6379;
}
In this case, everything goes fine and the key's value from redis is returned.

For processing '/upstream/key/12345678 HTTP/1.1', I extracted the characters between 3rd '/' and ' ' in the handler and created corresponding redis query in the create_request function. The config is as below:
location /upstream/key/ {
server_backend 127.0.0.1:6379;
}
In this case, i am able to extract the key but nginx doesn't send the upstream redis query and request times out.

As the change in the code is only in the way I extract the key from request (in the handler function), I guess its a problem with configuration in nginx.conf .

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>