rewrite ssl proxy retain query string parms

Mark Lybarger mlybarger at gmail.com
Thu Aug 13 10:57:59 UTC 2020


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 ;
        }

        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;
        }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20200813/482e0bea/attachment.htm>


More information about the nginx mailing list