Welcome! Log In Create A New Profile

Advanced

Странное поведением с включённым gzip

March 01, 2011 04:48AM
Здравствуйте,
У меня довольно странная проблема, при включённой директиве gzip (on) страница спонтанно теряет некоторые объекты (чаще всего картинки, но иногда архивы css и javascipt). Ответ на запрос объекта может вовсе не прийти или прийти но не целым. Причём закономерность выявить не могу, те же самые картинки иногда появляются иногда нет.
Все объекты читаются с диска хотя изначально они создаются с помощью php, но только в случае их отсутствия.
Читал про конфликты между бакендом и nginx, что сжатие должно присутствовать только на одном из двух, либо nginx или php-fpm (в моём случае). На php-fpm сжатие отсутствует, к тому-же повторюсь php используется только один раз, далее по идеи работает только nginx.

Я не уверен если виновато сжатие, так как оно не распространяется на архивы картинок, но эмпирически заметил что проблема пропадает при его отключение (gzip off;).
Возможно проблема даже в чём то другом. Подскажите, что может вызывать такое поведение.

Версия nginx 0.8.54
Далее привожу конфигурацию. nginx
===/nginx/conf/vhosts.conf===
user daemon;
worker_processes 1;
error_log logs/error.log debug;

pid logs/nginx.pid;

events {
worker_connections 1024;
use epoll;
}


http {
include mime.types;
default_type application/octet-stream;
include fastcgi_params;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" "$upstream_status"';

access_log logs/access.log main;

client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;

client_header_buffer_size 1k;
large_client_header_buffers 4 4k;

output_buffers 1 32k;
postpone_output 1460;

sendfile on;
tcp_nopush on;
tcp_nodelay on;

keepalive_requests 1024;
keepalive_timeout 75 75;

gzip on;
gzip_min_length 1100;
gzip_disable "msie6";
gzip_buffers 16 8k;
gzip_types text/plain application/x-javascript text/css text/javascript;
gzip_vary on;
gzip_proxied any;

fastcgi_read_timeout 3m;
fastcgi_send_timeout 3m;
include vhosts.conf;
}

===vhosts.conf===
#
# includes servers configuration from there source code dirs
#
include /home/www/public_html/pub_mixgrill/mynginx.conf;

===/home/www/public_html/pub_mixgrill/mynginx.conf===
#
# nginx config file for mixgrill.gr
#
server {
listen 80;
server_name ~^(test\.)?(?<domain>mixgrill.gr)$;

root /home/www/public_html/pub_mixgrill;
error_page 404 403 =200 empty_gif; #/images/icon.png;

location =/ {
try_files /html/index.html @build;
}
location =/kg147el_arxiki.html { rewrite ^ / permanent; }
location =/index_el.html { rewrite ^ / permanent; }
location =/kg147en_arxiki.html { rewrite ^ /index_en.html permanent; }
location =/administration.php { rewrite ^ http://backup.$domain/administration.php permanent; }
location / {
error_page 404 = /error.php;
}

location ~* \.html$ {
try_files /html$uri @build;
}
location ^~ /images/ {
expires 30d;
access_log off;
}
location ^~ /uploaded/ {
expires 30d;
}
location ~* \.jpg$ {
try_files /imgs$uri $uri @images;
expires 30d;
access_log off;
}
location ~* ^/(js/([^\-/]*)\-(el|en)\.js)$ {
try_files $uri /build.php?fullname=$1&filename=$2_js.php&gl=$3;
expires 30d;
access_log off;
}
location = /style.css {
if ($http_user_agent ~ MSIE) {
rewrite ^ /css/style-ie.css last;
}
if ($http_user_agent !~ MSIE) {
rewrite ^ /css/style-gc.css last;
}
}
location ~* ^/(css/([^\-/]*)\-(ie|gc)\.css)$ {
try_files $uri /build.php?fullname=$1&filename=style.php&browser=$3;
expires 30d;
access_log off;
}

location @images{
rewrite "^(/imgs)?(/img([0-9]+)_([a-f0-9]{32})_([0-9!\^ec]+)_([0-9!\^ec]+)\.jpg)$" /image.php?fullname=imgs$2&id=$3&md_5=$4&width=$5&height=$6 last;
rewrite "^(/imgs)?(/img([0-9]+)_([a-f0-9]{32})_([0-9!\^ec]+)\.jpg)$" /image.php?fullname=imgs$2&id=$3&md_5=$4&width=$5 last;
rewrite "^(/imgs)?(/img([0-9]+)_([a-f0-9]{32})\.jpg)$" /image.php?fullname=imgs$2&id=$3&md_5=$4 last;
rewrite "^(/imgs)?(/imgm([vh])([cl])([0-9!\^ec]+)x([0-9!\^ec]+)_([0-9_]+)\.jpg)$" /image_montage.php?fullname=imgs$2&tile=$3&gravity=$4&width=$5&height=$6&ids=$7 last;
rewrite "^(/imgs)?(/imgc([0-9]+)\.jpg)$" /imgage_confirm.php?id=$3 last;
}
location @build {
rewrite "^/(index\.html)?$" /build.php?fullname=html/index.html&filename=index.php last;
rewrite "^(/index_en\.html)$" /build.php?fullname=html$1&filename=index.php&gl=en last;
rewrite "^(/(kg|xr)([0-9]+)(el|en)([0-9]+)(.*)\.html)$" /build.php?fullname=html$1&filename=index.php&gl=$4&$2_id=$3&limit1=$5&rest=$6 last;
rewrite "^(/(ar|kg|xr)([0-9]+)(el|en)(.*)\.html)$" /build.php?fullname=html$1&filename=index.php&gl=$4&$2_id=$3&rest=$5 last;
rewrite "^(/kw0(el|en)([0-9]+)_(.*)\.html)$" /build.php?fullname=html$1&filename=index.php&gl=$2&keyword=$4&limit1=$3 last;
rewrite "^(/kw0(el|en)_(.*)\.html)$" /build.php?fullname=html$1&filename=index.php&gl=$2&keyword=$3 last;
rewrite "^/reserve_(confirm|cancel)_(el|en)_([0-9]+)_([a-f0-9]{32})\.html$" /index.php?reserve=$1&gl=$2&reserve_id=$3&md5=$4 last;
error_page 404 =200 /;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
if (!-f $request_filename) {
rewrite ^ /error.php;
}

# error_page 404 = /error.php;
# fastcgi_pass unix:/tmp/php.socket;
}

}

С уважением,
Хусаинов Искандер
Subject Author Posted

Странное поведением с включённым gzip

soviet March 01, 2011 04:48AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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