upstream backend {
server 13.4.2.14:8080 max_fails=2 fail_timeout=30s ;
server 13.4.2.15:8080 max_fails=2 fail_timeout=30s ;
}
server {
listen 80;
server_name www.a.com;
access_log /home/logs/nginx/access_log main;
error_log /home/logs/nginx/error_log;
location / {
proxy_pass http://backend;
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_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_set_header Host $host;
client_max_body_size 10m; #允许客户端请求的最大单文件字节数
client_body_buffer_size 128k; #缓冲区代理缓冲用户端请求的最大字节数,
proxy_connect_timeout 30; #nginx跟后端服务器连接超时时间(代理连接超时)
proxy_send_timeout 30; #后端服务器数据回传时间(代理发送超时)
proxy_read_timeout 30; #连接成功后,后端服务器响应时间(代理接收超时)
proxy_buffer_size 4k; #设置代理服务器(nginx)保存用户头信息的缓冲区大小
proxy_buffers 4 32k; #proxy_buffers缓冲区,网页平均在32k以下的设置
proxy_busy_buffers_size 64k; #高负荷下缓冲大小(proxy_buffers*2)
proxy_temp_file_write_size 64k;
}
}