rewrite ssl proxy retain query string parms

Maxim Dounin mdounin at mdounin.ru
Thu Aug 13 13:44:22 UTC 2020


Hello!

On Thu, Aug 13, 2020 at 06:57:59AM -0400, Mark Lybarger wrote:

> I'm using rewrite to change some tokens in the url path, and am using ssl
> proxy to send traffic to a downstream server.
> 
> if i post to https://myhost/start/foo/213/hello, the request gets to
> https://client-service-host/client/service/hello/213 using the needed
> certificate. great.
> 
> my question is, how do i retain query string parameters in this example so
> that if i post(or get)   using query strings, they get also used?
> 
> https://myhost/start/foo/213/hello?name=world
> https://myhost/start/foo/213/hello?name=world&greet=full
> 
> thanks!
> 
>         location ~ /start/(.*)/(.*)/hello {
>             # $1 is used to pick which cert to use. removed by proxy pass.
>             rewrite /start/(.*)/(.*)/(.*)? /client/service/$1/$3/$2 ;
>         }

The configuration in question does not touch any query string 
parameters, so they are retained by default.

Note that the rewrite directive retains request arguments by 
default (and you can use a trailing '?' to remove them, see 
http://nginx.org/r/rewrite).

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx mailing list