Service proxy load balancing configuration |
To improve the load balancing ability of proxy service to improve the concurrent access, you can deploy multiple independent proxy packages. Below shows the specific configuration flow:
upstream proxyserver.com {
server 192.168.120.40:8091;
server 192.168.120.40:8092;
}
server {
listen 8195;
server_name proxyserver.com;
location / {
proxy_pass http://proxyserver.com;
proxy_set_header Host $host:$server_port;
}
<serviceProxy>
<enable>true</enable>
<enableBuiltinProxy>false</enableBuiltinProxy>
<port>8195</port>
<rootUrlPostfix>portalproxy</rootUrlPostfix>
<proxyServerRootUrl>http://proxyserver.com:8195</proxyServerRootUrl>
<httpConnPoolInfo>
<maxTotal>100</maxTotal>
<defaultMaxPerRoute>10</defaultMaxPerRoute>
</httpConnPoolInfo>
</serviceProxy>
In the above configuration:
server {
listen 8195;
server_name proxyserver.com;
location / {
proxy_pass http://proxyserver.com;
proxy_set_header Host $host:$server_port;
add_header backendIP $upstream_addr;
add_header backendCode $upstream_status;
}
then restart Nginx. Access this proxied service address in the debug mode in your browser (enter F12 to enter debug mode). In the list under "Network" tab, click to select the current request, on the right side under "Headers", you can view the backendIp information in "Response Headers" section.
At this point, the load balancing configuration for service proxy is completed.