Reputation: 1085
I got a Rails app (3.2.x) running on Ubuntu and using Passenger.
I added the option
gzip on;
into the nginx.conf file but testing the page with
http://www.gidnetwork.com/tools/gzip-test.php
shows that compression is not used.
My nginx.conf file looks as follows:
worker_processes 8;
events {
worker_connections 1024;
}
http {
passenger_root /usr/local/rvm/gems/ruby-1.9.3-p392/gems/passenger-3.0.19;
passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.3-p392/ruby;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
server {
listen 80;
server_name xxx.com;
root /var/www/xxx/public;
rewrite ^ https://$server_name$request_uri? permanent;
passenger_enabled on;
}
server {
listen 443;
server_name xxx.com;
root /var/www/xxx/public;
passenger_enabled on;
ssl on;
ssl_certificate /etc/ssl/private/ssl_xxx_com_certificate.txt;
ssl_certificate_key /etc/ssl/private/ssl_xxx_com_private_key.txt;
ssl_client_certificate /etc/ssl/private/cabundle.txt;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
}
}
Upvotes: 0
Views: 2057
Reputation: 9914
You gzip is working. Maybe you shouldn't use web browser to verify that. I used curl and it shows that gzip is on. See the last line.
curl -IL -H "accept-encoding: gzip" http://vircurex.com/
HTTP/1.1 301 Moved Permanently
Server: nginx/1.2.6
Date: Mon, 25 Mar 2013 10:52:42 GMT
Content-Type: text/html
Content-Length: 184
Connection: keep-alive
Location: https://vircurex.com/
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Status: 200
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.19
X-UA-Compatible: IE=Edge,chrome=1
ETag: "b36d8bb7e713ad93aeb6e5fb1e351135"
Cache-Control: max-age=0, private, must-revalidate
Set-Cookie: v0100session=BAh7CUkiD3Nlc3Npb25faWQGOgZFRkkiJTEyZjQ0ZGJjOWI0NTQ4ZGMwNGQxZWM2YTNiZWJjZDcxBjsAVEkiFmlucHV0X2RldmljZV90eXBlBjsARkkiCk1PVVNFBjsARkkiFGhvdmVyX3N1cHBvcnRlZAY7AEZUSSIQX2NzcmZfdG9rZW4GOwBGSSIxRmNkOGViQXlTL0t1K3l2TTlVVUQwbmFZVW1VZHpoQ1kwT2JkZlhrU3pDZz0GOwBG--3cc39d4d71943811224fb350b8ed6cd0a7d6e363; path=/; HttpOnly
X-Request-Id: c1be4f7e0ebaffbdfd7a1da0b47143c8
X-Runtime: 0.154884
Date: Mon, 25 Mar 2013 10:52:47 GMT
X-Rack-Cache: miss
Server: nginx/1.2.6 + Phusion Passenger 3.0.19
Content-Encoding: gzip
Upvotes: 6
Reputation: 18803
Your problem is that you didn't specify the types to gzip. Add the following gzip_types
line to your config file:
gzip on;
gzip_types text/css text/xml application/x-javascript application/atom+xml text/mathml text/plain text/vnd.sun.j2me.app-descriptor text/vnd.wap.wml text/x-component;
You might want to adjust the types to suit your configuration.
Note that text/html
is on by default, so you do not have to specify it. If you use an http debugger, you will see that your current configuration (without the above gzip_types
line) does indeed do gzip compression on the php
file, but not on other types.
Upvotes: 0