worker_processes 8; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 65535; } http { include mime.types; default_type application/octet-stream; log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘ ‘$status $body_bytes_sent "$http_referer" ‘ ‘"$http_user_agent" "$http_x_forwarded_for" "$upstream_cache_status" "$host" "$request_time"‘; access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; resolver 8.8.8.8; #gzip on; client_body_buffer_size 512k; proxy_connect_timeout 5; proxy_read_timeout 60; proxy_send_timeout 5; proxy_buffer_size 16k; proxy_buffers 4 64k; proxy_busy_buffers_size 128k; proxy_temp_file_write_size 128k; proxy_temp_path /data/tmp; proxy_cache_path /data/cache1 levels=1:2 keys_zone=cache_1:200m inactive=365d max_size=112g use_temp_path=off; proxy_cache_path /data/cache2 levels=1:2 keys_zone=cache_2:200m inactive=365d max_size=120g use_temp_path=off; proxy_cache_path /data/cache3 levels=1:2 keys_zone=cache_3:200m inactive=365d max_size=120g use_temp_path=off; proxy_cache_path /data/cache4 levels=1:2 keys_zone=cache_4:200m inactive=365d max_size=120g use_temp_path=off; proxy_cache_path /data/cache5 levels=1:2 keys_zone=cache_5:200m inactive=365d max_size=120g use_temp_path=off; split_clients $request_uri $disk { 20% 1; 20% 2; 20% 3; 20% 4; 20% 5; } #server { # listen 80 default_server; # server_name _; # location / { # return 403; # } #} server { listen 80; # server_name hpcc-page.cnc.ccgslb.com.cn img3.2345.com; location / { proxy_set_header Accept-Encoding ""; proxy_pass http://$host; proxy_cache_key $request_uri; proxy_cache cache_$disk; proxy_cache_valid 200 302 1d; proxy_cache_valid 404 1d; #aio threads=pool_$disk; add_header Nginx-Cache "$upstream_cache_status"; sendfile on; } location /nginx_status { stub_status on; access_log off; allow 127.0.0.1; deny all; } } }
公司需要做缓存,squid 因为好久没用,还的重新学,就选nginx了;之前都是单块盘做,这次用多块盘做缓存,发现很好用,而且比squid简单。
下面是硬盘图和tsar监控的一些数据
本文出自 “立成为网络安全工程师” 博客,请务必保留此出处http://luyafei.blog.51cto.com/1092421/1833596
原文地址:http://luyafei.blog.51cto.com/1092421/1833596