……致我那曾经苦逼的岁月……
全部博文(83)
分类: 系统运维
2013-12-27 21:32:45
user nginx;
worker_processes 2;
worker_cpu_affinity 0001 0010;
worker_rlimit_nofile 65535;
error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events {
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
log_format access ' $remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
sendfile on;
keepalive_timeout 0;
##缓存配置
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 /var/nginx/temp_dir; 设置临时目录
proxy_cache_path /var/nginx/cache levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=30g; 设置缓存目录,和上面的目录必须在一个分区里面
gzip on;
upstream appserver {
server 192.168.0.1:8080;
}
server {
listen 80 default;
server_name 192.168.0.1;
location /
{
proxy_pass ;
proxy_cache cache_one;
proxy_cache_methods GET HEAD POST;
proxy_cache_min_uses 1;
proxy_cache_valid 200 302 10m; 200和302状态缓存10分钟,10分钟后失效
proxy_cache_valid 404 1m; 404状态缓存1分钟
proxy_cache_valid any 1m; 其余状态缓存1分钟
access_log /var/log/nginx/192.168.0.1.log;
}
}
}