@zzmaster

Почему nginx портит заголовок Content-length?

Я собираюсь скриптом PHP отдать видео файл, однако заголовок Content-length который доходит до клиента отличается от значения, которое выдал скрипт. (Пробовал также Content-type который закоментарен - не помогло)

header("HTTP/1.1 200 OK");
 	//header("Content-Type: video/webm"); 
	header("Content-Type: application/octet-stream"); 
	header("Content-length: " . filesize($file)); 
	header('Content-Disposition: attachment; filename="' . $output_name . '"'); 
	print("Real Content-length: " . filesize($file));


И вот как curl это трейсит

0067: Accept: */*
0074: 
<= Recv header, 17 bytes (0x11)
0000: HTTP/1.1 200 OK
<= Recv header, 15 bytes (0xf)
0000: Server: nginx
<= Recv header, 37 bytes (0x25)
0000: Date: Mon, 22 Jul 2019 07:30:01 GMT
<= Recv header, 40 bytes (0x28)
0000: Content-Type: application/octet-stream
<= Recv header, 20 bytes (0x14)
0000: Content-Length: 24
<= Recv header, 24 bytes (0x18)
0000: Connection: keep-alive
<= Recv header, 24 bytes (0x18)
0000: Keep-Alive: timeout=60
<= Recv header, 26 bytes (0x1a)
0000: X-Powered-By: PHP/5.4.16
<= Recv header, 57 bytes (0x39)
0000: Content-Disposition: attachment; filename="lalafa.webm"
<= Recv header, 2 bytes (0x2)
0000: 
<= Recv data, 24 bytes (0x18)
0000: Real Content-length: 49584338


PHP версия старая, 5.4, но, вероятно проблема в nginx-е.
nginx version: nginx/1.12.2
Установлена Vesta.

server {
    listen       11.22.33.44:80 default;
    server_name  _;
    #access_log  /var/log/nginx/11.22.33.44.log main;
    location / {
        proxy_pass  http://11.22.33.44:8080;
   }
}
server {
    listen       127.0.0.1:8084 default;
    server_name  _;
    server_name_in_redirect  off;
    location / {
        stub_status on;
        access_log   off;
   }
}
server {
    listen      11.22.33.44:80;
    server_name getfile.qu www.getfile.qu;
    error_log  /var/log/httpd/domains/getfile.qu.error.log error;

    location / {
        proxy_pass      http://11.22.33.44:8080;
        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
            root           /home/admin/web/getfile.qu/public_html;
            access_log     /var/log/httpd/domains/getfile.qu.log combined;
            access_log     /var/log/httpd/domains/getfile.qu.bytes bytes;
            expires        max;
            try_files      $uri @fallback;
        }
    }

    location /error/ {
        alias   /home/admin/web/getfile.qu/document_errors/;
    }

    location @fallback {
        proxy_pass      http://11.22.33.44:8080;
    }

    location ~ /\.ht    {return 404;}
    location ~ /\.svn/  {return 404;}
    location ~ /\.git/  {return 404;}
    location ~ /\.hg/   {return 404;}
    location ~ /\.bzr/  {return 404;}

    include /home/admin/conf/web/nginx.getfile.qu.conf*;
}


Что вообще происходит и как это пофиксить? Спасибо.
  • Вопрос задан
  • 726 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы