Chinaunix首页 | 论坛 | 博客
  • 博客访问: 175681
  • 博文数量: 159
  • 博客积分: 7007
  • 博客等级: 准将
  • 技术积分: 1750
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-17 15:05
文章分类

全部博文(159)

文章存档

2010年(39)

2009年(106)

2008年(14)

我的朋友

分类: LINUX

2009-12-22 14:57:07


user nobody;
worker_processes 2;
events {
    use epoll;
    worker_connections 2048;
}
http {
    include mime.types;
    default_type application/octet-stream;
    access_log logs/access.log;
    sendfile on;
    tcp_nodelay on;
    keepalive_timeout 65;
    include      gzip.conf;

    配置cache空间

    levels指定该缓存空间有两层hash目录,第一层目录是1个字母,第二层为2个字母,保存的文件名就会类似/tmp/nginxcacheone/c/29/b7f54b2df7773722d382f4809d65029c;keys_zone为这个空间起个名字,10m指空间大小为10MB;inactive的5m指缓存默认时长5分钟;max_size的2m是指单个文件超过2m的就不缓存;clean_time指定一分钟清理一次缓存。
    proxy_cache_path /tmp/nginxcacheone levels=1:2 keys_zone=one:10m inactive=5 max_size=2m;
    proxy_cache_path /tmp/nginxcachetwo levels=1:2 keys_zone=two:10m inactive=5 max_size=2m;
    log_format mduochina    '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    log_format jyhjk    '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
server
    {
        listen 80;
        server_name mduochina.com;
    access_log logs/mduochina.access.log mduochina;
    location ~ ^/NginxStatus/ {
    stub_status on;
    access_log off;
     }
     location ~ ^/(WEB-INF)/ {
     deny all;
     }
    location ~ \.(htm|html|gif|jpg|jpeg|png|bmp|ico|rar|css|js|zip|java|jar|txt|flv|swf|mid|doc|ppt|xls|pdf|txt|mp3|wma)$ {
            root /projects/miduo;
     expires 24h;
        }    
    location ~* .*\.pl$
    {
    include awstats.conf;
    }
    location /awstatsicon/
    {
       alias /usr/local/awstats/wwwroot/icon/;
    }
    location /{
    proxy_pass http://localhost:8080;
    include proxy.conf;

    缓存时间再下面文件里:
    include proxy_cacheone.conf;
    }
        error_page 404 /html/404.html;
    error_page 502 503 /html/502.html;
        error_page 500 504 /50x.html;
        location = /50x.html {
            root html;
    }
    }
server
    {
    listen 80;
        server_name jyhjk,cn jyhjk.net;
    access_log logs/jyhjk.access.log jyhjk;
         location ~ ^/(WEB-INF)/ {
            deny all;
         }
        location ~ \.(htm|html|gif|jpg|jpeg|png|bmp|ico|rar|css|js|zip|java|jar|txt|flv|swf|mid|doc|ppt|xls|pdf|txt|mp3|wma)$ {
            root /projects/jiuyang;
            expires 24h;
        }
        location ~* .*\.pl$
        {
        include awstats.conf;
        }
        location /awstatsicon/
        {
        alias /usr/local/awstats/wwwroot/icon/;
        }
        location /{
        proxy_pass http://localhost:8080;
        include proxy.conf;
        include proxy_cachetwo.conf;
    }
        error_page 404 /html/404.html;
        error_page 502 503 /html/502.html;
        error_page 500 504 /50x.html;
        location = /50x.html {
            root html;
        }
    }
}


[root@ud20077 conf]# more proxy_cacheone.conf
#!nginx (-)
# proxy_cache.conf
proxy_cache one;  #使用NAME这个keys_zone
proxy_cache_valid 200 302 1h; #200和302状态码保存1小时
proxy_cache_valid 301 1d;  #301状态码保存一天
proxy_cache_valid any 1m;  #其它的保存一分钟
proxy_cache_min_uses 1;
proxy_cache_use_stale error timeout invalid_header http_500;


阅读(617) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~