When using Nginx to proxy multiple servers to perform load, how to check which server a request is forwarded to?
upstream demo { server 127.0.0.1:8781;
server 127.0.0.1:8087;
}
Add the following red configuration:
server {
listen 80;
server_name demo.testcas.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
#root html;
#index index.html index.htm;
add_header backendIP $upstream_addr;
add_header backendCode $upstream_status;
proxy_pass http://demo;
}
}
Restart Nginx, re-visit, check the header information of the request with F12 in the browser, and you can see the IP of the current server
https://www.cnblogs.com/notDog/p/5336900.html
https://www.zhihu.com/question/21464666