#user nobody;
worker_processes 4;
events {
worker_connections 65535;
use epoll;
}
http {
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 256;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 58m;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
send_timeout 3m;
keepalive_timeout 65;
#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 text/jsp;
#gzip_vary on;
#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;
proxy_connect_timeout 500;
proxy_send_timeout 500;
proxy_read_timeout 500;
proxy_buffers 32 4k;
proxy_buffering on;
//缓存路径
proxy_temp_path /opt/nginx/nginx_cache/proxy_temp_dir;
proxy_cache_path /opt/nginx/nginx_cache/proxy_cache_dir levels=1:2 keys_zone=cache_one:200m inactive=30m max_size=30g;
#日志格式
log_format new_log ' $upstream_cache_status $host$uri$is_args$args $remote_addr - $args - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log new_log;
//服务池
upstream 192.168.6.61{
server 192.168.6.57:8080 max_fails=2 fail_timeout=15s srun_id=57jvm11;
server 192.168.6.58:9080 max_fails=2 fail_timeout=15s srun_id=58jvm21;
jvm_route $cookie_JSESSIONID|sessionid reverse;
check interval=3000 rise=2 fall=5 timeout=1000;
}
server {
#端口号
listen 80;
#服务名称
server_name 192.168.6.61;
## look nginx status
location /bohaistatus{
stub_status on;
access_log off;
}
#字符集
charset GBK;
location ~^/(WEB-INF)/ {
deny all;
}
location / {
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_cache cache_one;
proxy_cache_valid 200 304 1d;
proxy_cache_valid any 1d;
proxy_cache_key $host$uri$is_args$args;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://192.168.6.61;
proxy_set_header X-Real-IP $remote_addr;
index index.html index.jsp login.jsp index.htm;
#proxy_redirect off;
expires 1d;
}
location ^~ /store/man/pro/ {
proxy_pass http://192.168.6.61;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~ .*\.(htm)?$ {
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_cache cache_one;
proxy_cache_valid 200 10m;
proxy_cache_valid any 1m;
proxy_cache_key $host$uri$is_args$args;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://192.168.6.61;
proxy_set_header X-Real-IP $remote_addr;
}
location ~ .*\.(ftl|jsp|do)?$ {
proxy_pass http://192.168.6.61;
proxy_set_header X-Real-IP $remote_addr;
}
location ~ .*\.(html|gif|jpg|jpeg|png|bmp|swf|flv|xml|htc|ico|doc|zip)$ {
root /opt/www/WebRoot/;
access_log off;
expires 30d;
}
location ~ .*\.(js|css)?$ {
root /opt/www/WebRoot/;
access_log off;
expires 12h;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}