#user nobody; #启动进程,通常设置成和cpu的数量相等 worker_processes 2; #全局错误日志及PID文件 #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; #工作模式及连接数上限 events { #单个后台worker process进程的最大并发链接数 worker_connections 1024; } 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; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; upstream eis.aokang.com { #根据ip计算将请求分配各那个后端tomcat,可以解决session问题; ip_hash; #同一机器在多网情况下,路由切换,ip可能不同; #weigth参数表示权值,权值越高被分配到的几率越大; #server localhost:8080 weight=1; #server localhost:9080 weight=1; server 10.10.165.95:8000 weight=1 max_fails=3 fail_timeout=20s; server 10.10.165.95:8001 weight=1 max_fails=3 fail_timeout=20s; server 10.10.165.95:8002 weight=1 max_fails=3 fail_timeout=20s; server 10.10.165.95:8003 weight=1 max_fails=3 fail_timeout=20s; server 10.10.165.96:8000 weight=1 max_fails=3 fail_timeout=20s; server 10.10.165.96:8001 weight=1 max_fails=3 fail_timeout=20s; server 10.10.165.96:8002 weight=1 max_fails=3 fail_timeout=20s; server 10.10.165.96:8003 weight=1 max_fails=3 fail_timeout=20s; } server { listen 9000; server_name localhost 10.113.0.161; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; proxy_redirect off; #保留用户真实信息; # nigix监听的端口 #proxy_set_header Host $host:$server_port; #服务器名称和端口一起通过代理服务器传递(转发服务器请求后端服务器的端口) proxy_set_header Host $host:$proxy_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-PORT $remote_port; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #允许客户端请求的最大单个文件字节数; client_max_body_size 10m; #缓冲区代理缓冲用户端请求的最大字节数,可以理解为先保存到本地再传给用户; client_body_buffer_size 128k; #跟后端服务器连接超时时间 发起握手等候响应超时时间; proxy_connect_timeout 15; #连接成功后 等待后端服务器响应时间 其实已进入后端的排队之中等候处理; proxy_read_timeout 180; #后端服务器数据回传时间 就是在规定时间内后端服务器必须传完所有数据; proxy_send_timeout 180; #代理请求缓存区 这个缓存区间会保存用户的头信息一共Nginx进行规则处理 一般只要能保存下头信息即可; proxy_buffer_size 4k; #同上 告诉Nginx保存单个用的几个Buffer最大用多大空间; proxy_buffers 4 32k; #如果系统很忙的时候可以申请国内各大的proxy_buffers 官方推荐 *2; proxy_busy_buffers_size 64k; #proxy 缓存临时文件的大小; proxy_temp_file_write_size 64k; proxy_next_upstream error timeout invalid_header http_500 http_503 http_404; proxy_max_temp_file_size 128m; proxy_pass http://eis.aokang.com; } #监控当前回话数 location /nginx_status { stub_status on; access_log off; #allow 172.21.202.105; #deny all; } #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; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} }