Blog: 使用 nginx 实现后端 HTTP 服务器的故障转移(failover): nginx.conf

File nginx.conf, 645 bytes (added by thinkbase, 2 years ago)
Line 
1# START: nginx -c `pwd`/nginx.conf
2# STOP : nginx -c `pwd`/nginx.conf -s quit
3
4worker_processes 1;
5
6events {
7    worker_connections 1024;
8}
9
10http {
11    default_type  application/octet-stream;
12    client_max_body_size 4m;
13   
14    keepalive_timeout 65;
15    upstream backend_servers {
16            server localhost:7001 max_fails=3 fail_timeout=30s;
17            server localhost:7002 max_fails=3 fail_timeout=30s backup weight=2000000000;
18            server localhost:7003 max_fails=3 fail_timeout=30s backup weight=1;
19    }
20
21    server {
22        listen 8001;
23        server_name example.com;
24
25            location / {
26                    proxy_pass http://backend_servers;
27            }
28    }
29}
30