NGINX 编译和 gzip 配置(使用 Rails 3 + php-fpm):“无法解压缩”由 php tracker 的 torrent 客户端提供
您好:我有一个关于安装了 Nginx+php-fpm+passenger 的新服务器的奇怪问题。一切都是最新版本。我已经将所有内容配置良好,所有网页都在运行,但是当用户尝试访问我的私人跟踪器的 php 跟踪器时,它会返回一个错误:“无法解压缩”。这是 uTorrent。在 Vuze 上,这是一个 Java Gzip 异常,表示它不是有效的 gzip 文件等,这清楚地表明服务器已返回一些客户端不理解的 gzip 数据。
这是我的 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/*;
}
nginx 是由乘客编译的,参数为: --with-http_stub_status_module --with-http_gzip_static_module 基于此处所述的教程 http://geeksharp.com/2010/09/ 14/nginx-rails-and-php-round-2/ 所以我猜这是一个 gzip 问题,任何人都有任何解决方案可以让服务器返回正确的 gzip 数据,以便客户端吃掉它吗?非常感谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试关闭动态生成的位置的 gzip_static 。 gzip_static 将尝试在与请求相同的目录中创建 .gz 文件,这可能会导致 PHP、Ruby 等出现问题。
另外,我会将 gzip_comp_level 设置为 5 或 6,特别是在缓存压缩文件时与 gzip_static。
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.