nginx to return compressed file while proxying

Vasil Mikhalenya bazilek на gmail.com
Чт Мар 3 16:39:37 UTC 2016


Всем привет,

помогите понять почему nginx(host: o) отдает несжатый файл в случае
проксирования другому nginx(host: l) однако отдает сжатый для curl

при запросе курлом все получаю Content-Encoding: gzip
curl -I http://o/big.txt -H 'Accept-Encoding: gzip'
2016/03/03 16:35:24 [debug] 49741#49741: *1 http header: "Host: o"
2016/03/03 16:35:24 [debug] 49741#49741: *1 http header: "Accept: */*"
2016/03/03 16:35:24 [debug] 49741#49741: *1 http header: "Accept-Encoding:
gzip"
2016/03/03 16:35:24 [debug] 49741#49741: *1 http header done
2016/03/03 16:35:24 [debug] 49741#49741: *1 event timer del: 17:
1457023524813
2016/03/03 16:35:24 [debug] 49741#49741: *1 generic phase: 0
2016/03/03 16:35:24 [debug] 49741#49741: *1 rewrite phase: 1
2016/03/03 16:35:24 [debug] 49741#49741: *1 using configuration ""
2016/03/03 16:35:24 [debug] 49741#49741: *1 http cl:-1 max:1048576
2016/03/03 16:35:24 [debug] 49741#49741: *1 rewrite phase: 3
2016/03/03 16:35:24 [debug] 49741#49741: *1 post rewrite phase: 4
2016/03/03 16:35:24 [debug] 49741#49741: *1 generic phase: 5
2016/03/03 16:35:24 [debug] 49741#49741: *1 generic phase: 6
2016/03/03 16:35:24 [debug] 49741#49741: *1 generic phase: 7
2016/03/03 16:35:24 [debug] 49741#49741: *1 generic phase: 8
2016/03/03 16:35:24 [debug] 49741#49741: *1 access phase: 9
2016/03/03 16:35:24 [debug] 49741#49741: *1 access phase: 10
2016/03/03 16:35:24 [debug] 49741#49741: *1 access phase: 11
2016/03/03 16:35:24 [debug] 49741#49741: *1 post access phase: 12
2016/03/03 16:35:24 [debug] 49741#49741: *1 content phase: 13
2016/03/03 16:35:24 [debug] 49741#49741: *1 content phase: 14
2016/03/03 16:35:24 [debug] 49741#49741: *1 content phase: 15
2016/03/03 16:35:24 [debug] 49741#49741: *1 content phase: 16
2016/03/03 16:35:24 [debug] 49741#49741: *1 content phase: 17
2016/03/03 16:35:24 [debug] 49741#49741: *1 content phase: 18
2016/03/03 16:35:24 [debug] 49741#49741: *1 content phase: 19
2016/03/03 16:35:24 [debug] 49741#49741: *1 http filename:
"/var/www/o/big.txt"
2016/03/03 16:35:24 [debug] 49741#49741: *1 add cleanup: 00000000029E0CD0
2016/03/03 16:35:24 [debug] 49741#49741: *1 malloc: 00000000029D0C30:144
2016/03/03 16:35:24 [debug] 49741#49741: *1 malloc: 0000000002A116B0:19
2016/03/03 16:35:24 [debug] 49741#49741: *1 cached open file:
/var/www/o/big.txt, fd:18, c:1, e:0, u:1
2016/03/03 16:35:24 [debug] 49741#49741: *1 http static fd: 18
2016/03/03 16:35:24 [debug] 49741#49741: *1 http set discard body
2016/03/03 16:35:24 [debug] 49741#49741: *1 HTTP/1.1 200 OK
Server: nginx
Date: Thu, 03 Mar 2016 16:35:24 GMT
Content-Type: text/plain
Last-Modified: Thu, 03 Mar 2016 15:06:50 GMT
Connection: keep-alive
Vary: Accept-Encoding
ETag: W/"56d8530a-43c"
Expires: Thu, 03 Mar 2016 16:37:24 GMT
Cache-Control: max-age=120
Content-Encoding: gzip


если запрос от другого на o идет от друго nginx (l) получаю несжатый контент
2016/03/03 16:39:33 [debug] 49741#49741: *4 http header: "Host: o"
2016/03/03 16:39:33 [debug] 49741#49741: *4 http header: "Connection: close"
2016/03/03 16:39:33 [debug] 49741#49741: *4 http header: "User-Agent:
curl/7.29.0"
2016/03/03 16:39:33 [debug] 49741#49741: *4 http header: "Accept: */*"
2016/03/03 16:39:33 [debug] 49741#49741: *4 http header: "Accept-Encoding:
gzip"
2016/03/03 16:39:33 [debug] 49741#49741: *4 http header done
2016/03/03 16:39:33 [debug] 49741#49741: *4 event timer del: 18:
1457023773456
2016/03/03 16:39:33 [debug] 49741#49741: *4 generic phase: 0
2016/03/03 16:39:33 [debug] 49741#49741: *4 rewrite phase: 1
2016/03/03 16:39:33 [debug] 49741#49741: *4 using configuration ""
2016/03/03 16:39:33 [debug] 49741#49741: *4 http cl:-1 max:1048576
2016/03/03 16:39:33 [debug] 49741#49741: *4 rewrite phase: 3
2016/03/03 16:39:33 [debug] 49741#49741: *4 post rewrite phase: 4
2016/03/03 16:39:33 [debug] 49741#49741: *4 generic phase: 5
2016/03/03 16:39:33 [debug] 49741#49741: *4 generic phase: 6
2016/03/03 16:39:33 [debug] 49741#49741: *4 generic phase: 7
2016/03/03 16:39:33 [debug] 49741#49741: *4 generic phase: 8
2016/03/03 16:39:33 [debug] 49741#49741: *4 access phase: 9
2016/03/03 16:39:33 [debug] 49741#49741: *4 access phase: 10
2016/03/03 16:39:33 [debug] 49741#49741: *4 access phase: 11
2016/03/03 16:39:33 [debug] 49741#49741: *4 post access phase: 12
2016/03/03 16:39:33 [debug] 49741#49741: *4 content phase: 13
2016/03/03 16:39:33 [debug] 49741#49741: *4 content phase: 14
2016/03/03 16:39:33 [debug] 49741#49741: *4 content phase: 15
2016/03/03 16:39:33 [debug] 49741#49741: *4 content phase: 16
2016/03/03 16:39:33 [debug] 49741#49741: *4 content phase: 17
2016/03/03 16:39:33 [debug] 49741#49741: *4 content phase: 18
2016/03/03 16:39:33 [debug] 49741#49741: *4 content phase: 19
2016/03/03 16:39:33 [debug] 49741#49741: *4 http filename:
"/var/www/o/big.txt"
2016/03/03 16:39:33 [debug] 49741#49741: *4 add cleanup: 00000000029D6C28
2016/03/03 16:39:33 [debug] 49741#49741: *4 cached open file:
/var/www/o/big.txt, fd:19, c:1, e:0, u:2
2016/03/03 16:39:33 [debug] 49741#49741: *4 http static fd: 19
2016/03/03 16:39:33 [debug] 49741#49741: *4 http set discard body
2016/03/03 16:39:33 [debug] 49741#49741: *4 HTTP/1.1 200 OK
Server: nginx
Date: Thu, 03 Mar 2016 16:39:33 GMT
Content-Type: text/plain
Content-Length: 1084
Last-Modified: Thu, 03 Mar 2016 15:06:50 GMT
Connection: close
Vary: Accept-Encoding
ETag: "56d8530a-43c"
Expires: Thu, 03 Mar 2016 16:41:33 GMT
Cache-Control: max-age=120
Accept-Ranges: bytes


# cat o.conf l.conf

server {
    listen 80;
    server_name o;
    expires 120s;

    access_log  /var/log/nginx/o_access.log;
    #error_log   /var/log/nginx/o_error.log notice;
    error_log   /var/log/nginx/o_error.log debug;

    root /var/www/o;

    gzip on;
    gzip_vary on;
    gzip_types      text/plain text/html;
    gzip_min_length 10;
    gzip_proxied any;
}

proxy_cache_path /var/lib/nginx/cache/l keys_zone=l:2m inactive=1h
use_temp_path=off;

server {
    listen 80;
    server_name l;

    access_log  /var/log/nginx/l_access.log;
    #error_log   /var/log/nginx/l_error.log notice;
    error_log   /var/log/nginx/l_error.log debug;

    proxy_cache l;

    location / {
        proxy_pass http://o;
        proxy_set_header Host $proxy_host;
        proxy_cache_lock on;
        proxy_cache_lock_age 1d;
        proxy_cache_lock_timeout 1d;
        proxy_cache_revalidate on;
        proxy_cache_use_stale updating;
        proxy_cache_key "$uri";
        proxy_cache_purge  PURGE from 127.0.0.1;
        add_header Cache $upstream_cache_status;
    }
}



-- 
Best regards,
Vasil Mikhalenya
----------- следущая часть -----------
Вложение в формате HTML было извлечено…
URL: <http://mailman.nginx.org/pipermail/nginx-ru/attachments/20160303/d6ff8bc4/attachment.html>


Подробная информация о списке рассылки nginx-ru