Welcome! Log In Create A New Profile

Advanced

X-Accel-Redirect + proxy_pass не сохраняет заголовок Content-Type

Сергей Трофимов
April 13, 2016 08:38AM
Имеется конфигурация: nginx 1.8.1, X-Accel-Redirect + try_files $uri
@upstream
Своими словами - нужно отдавать через x-accel-redirect файлы, которые могут
лежать или на локальном диске или на другом сервере.
Приложение устанавливает заголовки X-Accel-Redirect и Content-Type.

Ожидаемое поведение: заголовок Content-Type будет без изменения передан
клиенту.
Наблюдаемое поведение: в случае, если происходит proxy_pass на upstream, то
клиенту передаётся заголовок Content-Type полученный от upstream.

Я решил эту проблему добавив proxy_hide_header Content-Type; к location
@filestorage.
Я нашёл в документации такое утверждение:
https://www.nginx.com/resources/wiki/start/topics/examples/xsendfile/

Note that the following HTTP headers aren’t modified by NGINX:

Content-Type
Content-Disposition
Accept-Ranges
Set-Cookie
Cache-Control
Expires

Хочу выяснить у знатоков, является ли данное поведение nginx верным, или
это баг?

Выдержка из конфига:

location /internal/ {
internal;

alias /home/user/fs/;
try_files $uri @filestorage;
}

location @filestorage {
rewrite ^/internal(/.*)$ $1 break;

proxy_pass http://storage; # to upstream
proxy_read_timeout 90;
proxy_connect_timeout 90;
proxy_redirect off;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

# proxy_hide_header Content-Type; # preserves content-type for
x-accel-redirect

proxy_next_upstream http_404;
}
_______________________________________________
nginx-ru mailing list
nginx-ru@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-ru
Subject Author Posted

X-Accel-Redirect + proxy_pass не сохраняет заголовок Content-Type

Сергей Трофимов April 13, 2016 08:38AM

Re: X-Accel-Redirect + proxy_pass не сохраняет заголовок Content-Type

Maxim Dounin April 13, 2016 11:22AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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