Welcome! Log In Create A New Profile

Advanced

Re: Cannot strip QS in rewrite

aquilinux
June 21, 2019 06:52AM
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@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@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.
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Cannot strip QS in rewrite

aquilinux June 20, 2019 11:08AM

Re: Cannot strip QS in rewrite

Maxim Dounin June 20, 2019 11:22AM

Re: Cannot strip QS in rewrite

aquilinux June 21, 2019 06:52AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 301
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