Cannot strip QS in rewrite

aquilinux aquilinux at gmail.com
Fri Jun 21 10:50:44 UTC 2019


Hi Maxim, thanks for the rewrite_log hint.
Actually it does rewrite as expected:

2019/06/21 12:35:37 [notice] 7495#7495: *4693835 "(?i)^/ambassadors$"
> matches "/ambassadors", client: 1.1.1.1, server: www.example.co.uk,
> request: "GET /ambassadors?test=1 HTTP/1.1", host: "www.example.co.uk"
> 2019/06/21 12:35:37 [notice] 7495#7495: *4693835 rewritten redirect: "
> https://www.example.com/uk-en/experience/ambassadors/", client:
> 93.46.189.23, server: www.example.co.uk, request: "GET
> /ambassadors?test=1 HTTP/1.1", host: "www.example.co.uk"


but i still get the response as above.
So i suspect the culprit may be varnish, saving the QS in be.req and
re-adding the QS in be.resp .
I see no other explanation.

Thanks!






On Thu, Jun 20, 2019 at 5:21 PM Maxim Dounin <mdounin at mdounin.ru> wrote:

> Hello!
>
> On Thu, Jun 20, 2019 at 05:05:57PM +0200, aquilinux wrote:
>
> > Hi guys, i've always used ? to strip QS in rewrites but i cannot get past
> > this odd issue i'm having:
> >
> > URL SOURCE:
> >
> > > https://www.example.co.uk/ambassadors?test=1
> >
> >
> > REWRITE:
> >
> > > rewrite (?i)^/ambassadors$
> > > https://www.example.com/uk-en/experience/ambassadors/? permanent;
> >
> >
> > OR EVEN:
> >
> > > location ~* ^/ambassadors$ {
> > >   rewrite (.*) https://www.example.com/uk-en/experience/ambassadors/?
> > > permanent;
> > > }
> >
> >
> > RESULT WITH REWRITE:
> >
> > > [~]> curl -kIL https://www.example.co.uk/ambassadors?test=1
> > > HTTP/2 301
> > > date: Thu, 20 Jun 2019 14:44:21 GMT
> > > content-type: text/html
> > > location: https://www.example.com/uk-en/experience/ambassadors/?test=1
> > > x-who: SVAORMG2V01
>
> An nginx response is expected to contain "server:
> nginx/<version>", for example:
>
> $ curl -kI https://127.0.0.1:8443/ambassadors?test=1
> HTTP/2 301
> server: nginx/1.17.1
> date: Thu, 20 Jun 2019 15:11:51 GMT
> content-type: text/html
> content-length: 169
> location: https://www.example.com/uk-en/experience/ambassadors/
>
> Are you sure the response you've provided is from nginx?
>
> (Also, as you can see from the above example response, the rewrite
> is working fine.)
>
> You may also want to drop "-L" from your curl options to make sure
> you are looking at a particular response, and not a chain of
> redirects.
>
> If the above doesn't help, you may consider using "rewrite_log on;"
> to find out how your rewrites are processed (see
> http://nginx.org/r/rewrite_log for details).
>
> --
> Maxim Dounin
> http://mdounin.ru/
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>


-- 
"Madness, like small fish, runs in hosts, in vast numbers of instances."

Nessuno mi pettina bene come il vento.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20190621/07d47355/attachment.html>


More information about the nginx mailing list