Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

recently got into VPS systems and installing them, and all that blah blah etc etc. So, I have a couple working websites, and on one of them I'm trying to really optimize it for speed. Using Yahoo's ySlow as a guide, I am still failing the gzip and header expires sections. My nginx.conf is located in /etc/nginx/nginx.conf, and here is its details:

PLEASE HELP! i have no idea why it isn't working.

#######################################################################
#
# 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/*;
}
share|improve this question

migrated from stackoverflow.com Jul 3 '12 at 13:05

This question came from our site for professional and enthusiast programmers.

add comment

1 Answer

From http://wiki.nginx.org/HttpGzipModule

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]\.";

From http://wiki.nginx.org/HttpHeadersModule

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

It appears that some of these options exist inside of your phpmyadmin area but not in your main website config.

share|improve this answer
    
Thanks for your reply Aaron, and pardon me for being such a newbie..but how do I take your reply and make my VPS gzip all files and add expire headers? –  mazing May 8 '12 at 1:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.