Welcome! Log In Create A New Profile

Advanced

path param and query param in nginx

Posted by melwin_jose 
path param and query param in nginx
June 12, 2015 02:24AM
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 .
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 164
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready