nginx 负载均衡


worker_processes 1;
events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream a.com {
server localhost:8181;
server 192.168.3.141:8090; #这里要用ip 不能用域名
}
server {
listen 8078;
server_name a.com;
location / {
proxy_pass http://a.com;
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 1; # 不设置的话, 一台机器宕机后会变得很慢
proxy_read_timeout 1;
proxy_send_timeout 1;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

}

}

你可能感兴趣的:(LJ)