I basically have those two locations in NGINX (Return codes added for debugging purpose)
location / {
return 401;
}
location ~ "^/(assets|((de|en|es|fr|it|zh|ru)-[a-z]{3}))" {
return 402;
}
The idea is to return 401 on GET https://www.example.com/, but it always returns 402
How can that be?
$ http https://www.example.com/ --print Hh
GET / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: www.example.com
User-Agent: HTTPie/1.0.3
HTTP/1.1 402 Payment Required
Connection: keep-alive
Content-Length: 176
Content-Type: text/html
Date: Mon, 07 Jun 2021 10:07:37 GMT
Server: nginx/1.18.0 (Ubuntu)
I also tested the regexp on https://nginx.viraptor.info/ and it does not match a www.example.com/ request, so I believe it should run into the location /
block?
EDIT: Before that I have some
rewrite ^/$ /de-abc/;
The reasons was a rewrite which was not a redirect earlier in the config
I intented to use