1.upstream
使用upstream 指定服务器组进行负载均衡
user root; worker_processes 20; error_log logs/error; pid logs/nginx.pid; events { worker_connections 1024; } http { 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; tcp_nopush on; tcp_nodelay on; include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; types_hash_max_size 2048; client_max_body_size 50M; client_body_buffer_size 10m; send_timeout 75; proxy_buffering on; client_header_buffer_size 32k; large_client_header_buffers 8 32k; proxy_buffers 64 32k; proxy_connect_timeout 3600; proxy_read_timeout 3600; proxy_send_timeout 3600; proxy_set_header X-Different-Name "true"; proxy_set_header X-Frame-Options "ALLOWALL"; proxy_set_header X-Request-Start "t=${msec}"; proxy_set_header X-Using-Nginx-Controller "true"; #add_header X-Frame-Options ALLOWALL; #add_header X-Different-Name true; #add_header X-Request-Start t=${msec}; #add_header X-Using-Nginx-Controller true; upstream shuiwu-atf { server 10.12.60.35:30007; server 10.12.60.38:30007; server 10.12.60.39:30007; server 10.12.60.40:30007; server 10.12.60.41:30007; } upstream shuiwu-base { server 10.12.60.35:30003; server 10.12.60.38:30003; server 10.12.60.39:30003; server 10.12.60.40:30003; server 10.12.60.41:30003; } upstream shuiwu-dm { server 10.12.60.35:30004; server 10.12.60.38:30004; server 10.12.60.39:30004; server 10.12.60.40:30004; server 10.12.60.41:30004; } upstream shuiwu-eit { server 10.12.60.35:30005; server 10.12.60.38:30005; server 10.12.60.39:30005; server 10.12.60.40:30005; server 10.12.60.41:30005; } upstream shuiwu-mis { server 10.12.60.35:30010; server 10.12.60.38:30010; server 10.12.60.39:30010; server 10.12.60.40:30010; server 10.12.60.41:30010; } upstream shuiwu-ints { server 10.12.60.35:30016; server 10.12.60.38:30016; server 10.12.60.39:30016; server 10.12.60.40:30016; server 10.12.60.41:30016; } upstream shuiwu-tda { server 10.12.60.35:30011; server 10.12.60.38:30011; server 10.12.60.39:30011; server 10.12.60.40:30011; server 10.12.60.41:30011; } upstream shuiwu-tom { server 10.12.60.35:30015; server 10.12.60.38:30015; server 10.12.60.39:30015; server 10.12.60.40:30015; server 10.12.60.41:30015; } upstream shuiwu-tra { server 10.12.60.35:30012; server 10.12.60.38:30012; server 10.12.60.39:30012; server 10.12.60.40:30012; server 10.12.60.41:30012; } upstream shuiwu-vatrep { server 10.12.60.35:30006; server 10.12.60.38:30006; server 10.12.60.39:30006; server 10.12.60.40:30006; server 10.12.60.41:30006; } upstream shuiwu-xxljob { server 10.12.60.35:30009; server 10.12.60.38:30009; server 10.12.60.39:30009; server 10.12.60.40:30009; server 10.12.60.41:30009; } upstream shuiwu-rpt { server 10.12.60.35:30008; server 10.12.60.38:30008; server 10.12.60.39:30008; server 10.12.60.40:30008; server 10.12.60.41:30008; } server{ listen 443 ssl; server_name localhost; ssl_certificate /data/nginx/conf/cert/goldwind.com.crt; # 修改为上面生成的服务器证书路径 ssl_certificate_key /data/nginx/conf/cert/goldwind.com.key; # 修改为上面生成的私钥路径 location /ATF/ { proxy_pass http://shuiwu-atf/ATF/; proxy_set_header Host $host; proxy_set_header X-Real_IP $remote_addr; proxy_set_header X-Fowarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 600s; proxy_read_timeout 600s; proxy_send_timeout 600s; } location /BASE/ { proxy_pass http://shuiwu-base/BASE/; proxy_set_header Host $host; proxy_set_header X-Real_IP $remote_addr; proxy_set_header X-Fowarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 600s; proxy_read_timeout 600s; proxy_send_timeout 600s; } location /DM/ { proxy_pass http://shuiwu-dm/DM/; proxy_set_header Host $host; proxy_set_header X-Real_IP $remote_addr; proxy_set_header X-Fowarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 600s; proxy_read_timeout 600s; proxy_send_timeout 600s; } location /EIT/ { proxy_pass http://shuiwu-eit/EIT/; proxy_set_header Host $host; proxy_set_header X-Real_IP $remote_addr; proxy_set_header X-Fowarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 600s; proxy_read_timeout 600s; proxy_send_timeout 600s; } location /MIS/ { proxy_pass http://shuiwu-mis/MIS/; proxy_set_header Host $host; proxy_set_header X-Real_IP $remote_addr; proxy_set_header X-Fowarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 600s; proxy_read_timeout 600s; proxy_send_timeout 600s; } location /INTS/ { proxy_pass http://shuiwu-ints/INTS/; proxy_set_header Host $host; proxy_set_header X-Real_IP $remote_addr; proxy_set_header X-Fowarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 600s; proxy_read_timeout 600s; proxy_send_timeout 600s; } location /TDA/ { proxy_pass http://shuiwu-tda/TDA/; proxy_set_header Host $host; proxy_set_header X-Real_IP $remote_addr; proxy_set_header X-Fowarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 600s; proxy_read_timeout 600s; proxy_send_timeout 600s; } location /TOM/ { proxy_pass http://shuiwu-tom/TOM/; proxy_set_header Host $host; proxy_set_header X-Real_IP $remote_addr; proxy_set_header X-Fowarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 600s; proxy_read_timeout 600s; proxy_send_timeout 600s; } location /TRA/ { proxy_pass http://shuiwu-tra/TRA/; proxy_set_header Host $host; proxy_set_header X-Real_IP $remote_addr; proxy_set_header X-Fowarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 600s; proxy_read_timeout 600s; proxy_send_timeout 600s; } location /VATREP/ { proxy_pass http://shuiwu-vatrep/VATREP/; proxy_set_header Host $host; proxy_set_header X-Real_IP $remote_addr; proxy_set_header X-Fowarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 600s; proxy_read_timeout 600s; proxy_send_timeout 600s; } location /xxl-job-admin/ { proxy_pass http://shuiwu-xxljob/xxl-job-admin/; proxy_set_header Host $host; proxy_set_header X-Real_IP $remote_addr; proxy_set_header X-Fowarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 600s; proxy_read_timeout 600s; proxy_send_timeout 600s; } location /rpt/ { proxy_pass http://shuiwu-rpt/rpt/; proxy_set_header Host $host; proxy_set_header X-Real_IP $remote_addr; proxy_set_header X-Fowarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 600s; proxy_read_timeout 600s; proxy_send_timeout 600s; } } }
标签:set,配置文件,header,server,nginx,proxy,timeout,upstream,10.12 From: https://www.cnblogs.com/xiaoxiaomuyuyu/p/17892387.html