como obter o nginx para gzip todos os arquivos e adicionar um cabeçalho de expiração

1

recentemente entrou em sistemas VPS e instalando-os, e todos os que blah blah etc etc Então, eu tenho um par de sites de trabalho, e em um deles eu estou tentando realmente otimizá-lo para a velocidade. Usando o ySlow do Yahoo como guia, ainda estou falhando as seções gzip e header expires. Meu nginx.conf está localizado em /etc/nginx/nginx.conf e aqui estão seus detalhes:

POR FAVOR AJUDE! Eu não tenho idéia porque não está funcionando.

#######################################################################
#
# This is the main Nginx configuration file.
#
# More information about the configuration options is available on
#   * the English wiki - http://wiki.codemongers.com/Main
#   * the Russian documentation - http://sysoev.ru/nginx/
#
#######################################################################

#----------------------------------------------------------------------
# Main Module - directives that cover basic functionality
#
#   http://wiki.codemongers.com/NginxMainModule
#
#----------------------------------------------------------------------

user              www www;
worker_processes  2;

error_log         /var/log/nginx/error.log;
#error_log        /var/log/nginx/error.log  notice;
#error_log        /var/log/nginx/error.log  info;

pid               /var/run/nginx.pid;


#----------------------------------------------------------------------
# Events Module
#
#   http://wiki.codemongers.com/NginxEventsModule
#
#----------------------------------------------------------------------

events {
    worker_connections  1024;
}


#----------------------------------------------------------------------
# HTTP Core Module
#
#   http://wiki.codemongers.com/NginxHttpCoreModule
#
#----------------------------------------------------------------------

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    client_max_body_size 10M;
    client_body_buffer_size 128k;

    log_format  main  ' -  []  '
                      '""  "" '
                      '"" ""';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    tcp_nopush     on;

    keepalive_timeout  20;
    tcp_nodelay on;

    # Load config files from the /etc/nginx/conf.d directory
    include /etc/nginx/conf.d/*.conf;

    #
    # The default server
    #

    server {
        listen      443;
        server_name 127.0.0.2;
        ssl on;
        ssl_certificate      /etc/nginx/sslconf/server.crt;
        ssl_certificate_key  /etc/nginx/sslconf/server.key;
        location /phpmyadmin {
            root /usr/html;
            index index.php;

        gzip on;
        gzip_http_version 1.1;
        gzip_vary on;
        gzip_comp_level 6;
        gzip_proxied any;
        gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js;
        gzip_buffers 16 8k;

        location ~* \.(jpg|png|gif|jpeg|css|js)$ {
        expires 1h;
}

        }
        location ~ \.php$ {
            include /etc/nginx/fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /usr/html$fastcgi_script_name;
            fastcgi_param HTTPS on;
        }
    }

    server {
        listen       80;
        server_name  127.0.0.2;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
            root   /usr/html;
            index  index.html index.htm index.php;
        }
        location = /phpmyadmin/ {
            rewrite ^ https://127.0.0.2$uri redirect;
        }

        error_page  404              /404.html;
        location = /404.html {
            root   /usr/html;
        }

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
          location ~ \.php$ {
          include /etc/nginx/fastcgi_params;
          fastcgi_pass 127.0.0.1:9000;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME /usr/html$fastcgi_script_name;
        }
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
            deny  all;
        }
    }
    # Load virtual host configuration files.
      include /etc/nginx/sites-enabled/*;
}
    
por sysadmin1138 08.05.2012 / 01:58

1 resposta

1

De link

gzip             on;
gzip_min_length  1000;
gzip_proxied     expired no-cache no-store private auth;
gzip_types       text/plain application/xml;
gzip_disable     "MSIE [1-6]\.";

De link

expires       24h;
expires       modified +24h;
expires       @15h30m;
expires       0;
expires       -1;
expires       epoch;
add_header    Cache-Control  private;

Parece que algumas destas opções existem dentro da sua área phpmyadmin, mas não na sua configuração principal do site.

    
por 08.05.2012 / 02:07