Nginx根據IP將請求分配到不同的後端伺服器
阿新 • • 發佈:2018-12-27
server { listen 3333; server_name localhost; large_client_header_buffers 4 16k; client_max_body_size 300m; client_body_buffer_size 128k; proxy_connect_timeout 600; proxy_read_timeout 600; proxy_send_timeout 600; proxy_buffer_size 64k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; location / { root html; index index.html index.htm; } location /project { proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 10m; if ($remote_addr ~ "100.200.10.6") { proxy_pass http://project1.serverpool.com; break; } proxy_pass http://project2.serverpool.com; } error_page 502 /502.html; location = /502.html { root html; } }