NGINX compile and gzip config (with rails 3 + php-fpm): "can't unzip" by torrent client from php tracker

1.1k views Asked by At

Hi there: I have got a weird question about a new server installed with Nginx+php-fpm+passenger. Everything is the latest version. I have got everything configured well, all the web pages are running, however when the users tried to access the php tracker of my private tracker, it returns them an error: "can't unzip". This is uTorrent. On Vuze it is a Java Gzip exception saying it's not a valid gzip file or so, which clearly shows that the server has been returning some gzip data the clients don't understand.

So here's my nginx.conf:


user  www-data;
worker_processes  4;

events {
    worker_connections  1024;
}

http {
    passenger_root /home/meng/.rvm/gems/ruby-1.9.2-p136/gems/passenger-3.0.2;
    passenger_ruby /home/meng/.rvm/wrappers/ruby-1.9.2-p136/ruby;

    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    gzip on;
    gzip_static  on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    gzip_comp_level 2;
    gzip_vary on;
    gzip_proxied any;
    gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    include /opt/nginx/conf/sites-enabled/*;
}

The nginx was compiled by passenger with the arguments of: --with-http_stub_status_module --with-http_gzip_static_module based on the tutorial stated here http://geeksharp.com/2010/09/14/nginx-rails-and-php-round-2/ So I guess this is a gzip problem, anyone have any solutions to get the server return the correct gzip data, so the clients eat it? Thanks very much.

1

There are 1 answers

2
Mark Rose On

Try turning off gzip_static for your dynamically generated locations. gzip_static will try to create a .gz file in the same directory as the request, and this may cause issues with PHP, Ruby, etc.

Also, I'd turn up gzip_comp_level to 5 or 6, especially if you are caching the compressed file with gzip_static.