Welcome! Log In Create A New Profile

Advanced

Re: nginx BUG ? unexpected redirect from https://example.com/download to https://example.com/download/

Gena Makhomed
December 15, 2021 02:16AM
Здравствуйте, Максим!

On 15.12.2021 1:33, Maxim Dounin wrote:

> Воспроизводится ли проблема на приведённом конфиге в чистом виде,
> без каких-либо других location'ов и/или rewrite'ов? Если да - то
> как выглядит минимальный конфиг, на котором проблема
> воспроизводится, полностью (nginx -T)? Что показывает nginx -V?
> Что в debug log'е?

Воспроизводится на таком конфиге:

# nginx -T
error_log /var/log/nginx/error.log debug;
events { use epoll; }
http {
server {
server_name example.com;
location / { proxy_pass http://127.0.0.1; }
location /download/ { proxy_pass http://127.0.0.2; }
}
}

# nginx -V показывает nginx version: nginx/1.21.4
- это официальный бинарник nginx-1.21.4-1.el8.ngx.x86_64.rpm
с сайта http://nginx.org/packages/mainline/centos/8/x86_64/RPMS/

В debug log'е так:

http process request line
http request line: "GET /download HTTP/1.1"
http uri: "/download"
http args: ""
http exten: ""
posix_memalign: 000055D246233D50:4096 @16
http process request header line
http header: "Host: example.com"
http header: "User-Agent: curl/7.61.1"
http header: "Accept: */*"
http header done
event timer del: 3: 29402186335
generic phase: 0
rewrite phase: 1
test location: "/"
test location: "download/"
using configuration "/download/"
http cl:-1 max:1048576
http finalize request: 301, "/download?" a:1, c:1
http special response: 301, "/download?"
http set discard body

HTTP/1.1 301 Moved Permanently
Server: nginx/1.21.4
Date: Wed, 15 Dec 2021 06:54:06 GMT
Content-Type: text/html
Content-Length: 169
Location: http://example.com/download/
Connection: keep-alive

Перечитал еще раз документацию на сайте nginx.org
- запрос "/download" должен попадать в location "/"

Но запрос "/download" обрабатывается в location "/download/"
это BUG в самом nginx или это BUG в документации к nginx ?

Проверил на такой конфигурации:

# nginx -T
error_log /var/log/nginx/error.log debug;
events { use epoll; }
http {
server {
server_name example.net;
location / { return 200 "main locaton\n\n"; }
location /download/ { return 200 "download location\n\n"; }
}
}

Тут все отрабатывает как и должно быть согласно документации.

В debug log'е так:

http process request line
http request line: "GET /download HTTP/1.1"
http uri: "/download"
http args: ""
http exten: ""
posix_memalign: 000055D24625B920:4096 @16
http process request header line
http header: "Host: example.net"
http header: "User-Agent: curl/7.61.1"
http header: "Accept: */*"
http header done
event timer del: 3: 29403087747
generic phase: 0
rewrite phase: 1
test location: "/"
test location: "download/"
using configuration "/"
http cl:-1 max:1048576
rewrite phase: 3
http set discard body

HTTP/1.1 200 OK
Server: nginx/1.21.4
Date: Wed, 15 Dec 2021 07:09:07 GMT
Content-Type: text/plain
Content-Length: 14
Connection: keep-alive

--
Best regards,
Gena
_______________________________________________
nginx-ru mailing list
nginx-ru@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-ru
Subject Author Posted

nginx BUG ? unexpected redirect from https://example.com/download to https://example.com/download/

Gena Makhomed December 14, 2021 04:28PM

Re: nginx BUG ? unexpected redirect from https://example.com/download to https://example.com/download/

Maxim Dounin December 14, 2021 06:34PM

Re: nginx BUG ? unexpected redirect from https://example.com/download to https://example.com/download/

Gena Makhomed December 15, 2021 02:16AM

Re: nginx BUG ? unexpected redirect from https://example.com/download to https://example.com/download/

Maxim Dounin December 15, 2021 08:40AM

Re: nginx BUG ? unexpected redirect from https://example.com/download to https://example.com/download/

Gena Makhomed December 15, 2021 09:16AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 78
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready