rewrite ssl proxy retain query string parms

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

rewrite ssl proxy retain query string parms

Mark Lybarger
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?


thanks!

        location ~ /start/(.*)/(.*)/hello {
            # $1 is used to pick which cert to use. removed by proxy pass.
            rewrite /start/(.*)/(.*)/(.*)? /client/service/$1/$3/$2 ;
        }

        location /client/service/foo/ {
            proxy_buffering off;
            proxy_cache off;
            proxy_ssl_certificate     /etc/ssl/certs/client-service-foo-cert.pem;
            proxy_ssl_certificate_key /etc/ssl/certs/client-service-foo.key;
            proxy_pass https://client-service-host/client/service/;
            proxy_ssl_session_reuse on;
            proxy_set_header X-Proxy true;
            proxy_set_header Host $proxy_host;
            proxy_ssl_server_name on;
            proxy_set_header X-Real-IP $remote_addr;
        }

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: rewrite ssl proxy retain query string parms

Maxim Dounin
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/
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx