user www www;

worker_processes 16;

#error_log logs/error.log;

#error_log logs/error.log notice;

#error_log /var/log/nginx.error.log info;

pid logs/nginx.pid;

worker_rlimit_nofile 204800;

events {

worker_connections 204800;

}

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"';

# access_log logs/access.log main;

send_timeout 60;

access_log /dev/null;

error_log /dev/null;

server_names_hash_bucket_size 128;

client_header_buffer_size 128k;

large_client_header_buffers 4 128k;

# client_max_body_size 8m;

tcp_nopush on;

sendfile off;

server_tokens off;

keepalive_timeout 60;

fastcgi_intercept_errors on;

client_body_buffer_size 512k;

proxy_connect_timeout 300;

proxy_read_timeout 300;

proxy_send_timeout 300;

proxy_buffer_size 256k;

proxy_buffers 4 256k;

proxy_busy_buffers_size 256k;

proxy_temp_file_write_size 256k;

gzip on;

gzip_min_length 1k;

gzip_buffers 4 16k;

gzip_http_version 1.0;

gzip_comp_level 2;

gzip_types text/plain application/x-javascript text/css application/xml;

gzip_vary on;

proxy_temp_path /tmp/proxy_temp_dir;

proxy_cache_path /tmp/proxy_cache_dir levels=1:2 keys_zone=cache_one:200m inactive=3d max_size=10g;

upstream backend_server {

server 10.0.1.141:8080 weight=1 max_fails=2 fail_timeout=30s;

server 10.0.1.142:8080 weight=1 max_fails=2 fail_timeout=30s;

server 10.0.1.147:8080 weight=1 max_fails=2 fail_timeout=30s;

server 10.0.1.148:8080 weight=1 max_fails=2 fail_timeout=30s;

}

server {

listen 80;

server_name xxx.static.com;

location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|asf|avi|fla|flv|mp3|mp4|rm|rmi|rmvb|wav|wma|wmv|7z|aiff|bmp|csv|doc|docx|gz|gzip|mid|xml|zip|mov|mpc|mepg|mpg|ods|odt|pdf|ppt|pptx|pxd|qt|ram|rar|rtf|sdc|sitd|swf|sxc|sxw|tar|tgz|tif|tiff|txt|vsd|xls|xlsx)$ {

index index.html index.htm;

proxy_next_upstream http_502 http_504 error timeout invalid_header;

proxy_cache cache_one; #//根keys_zone后的内容对应

proxy_cache_valid 200 304 301 302 10d; # //哪些状态缓存多长时间

proxy_cache_valid any 1d; # //其他的缓存多长时间

proxy_cache_key $host$uri$is_args$args; # //通过key来hash,定义KEY的值

proxy_pass http://backend_server;

proxy_redirect off;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

access_log off;

expires 30d;

}

}

# HTTPS server

#

#server {

# listen 443;

# server_name localhost;

# ssl on;

# ssl_certificate cert.pem;

# ssl_certificate_key cert.key;

# ssl_session_timeout 5m;

# ssl_protocols SSLv2 SSLv3 TLSv1;

# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;

# ssl_prefer_server_ciphers on;

# location / {

# root html;

# index index.html index.htm;

# }

#}

}