gamester88
gamester88_cu
全部博文(159)
2010年(39)
2009年(106)
2008年(14)
zhaiqi16
cynthia
52246852
ghsyeu
dj15621
lmt81858
笑倚春风
JenGuo
求上进
分类: 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;
上一篇:fedora13无线Broadcom使用
下一篇:使用awstats 分析 Nginx 的访问日志
登录 注册