使用nginx最大的好处就是负载均衡。
#设定负载均衡的服务器列表
upstream service{
server 10.4.29.174:7477;
}
server {
listen 80;
server_name ×××.×××.com;
#access_log /data/logs/access.temp.log all;
access_log off;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /v2 {
proxy_pass http://service; #请求转向service定义的服务器列表
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 100m;
client_body_temp_path /data/client_body_temp;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_temp_path /data/proxy_temp;
}