基于IP的nginx反向代理示例            

server {
listen 80 default_server;
root /var/www/html;
server_name 192.168.188.169;

location ~ .* {
proxy_pass http://10.0.5.19;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

}

服务器可以设置多个IP地址,建立多个server,每个地址做对应的反向代理。

如:

server {
listen 192.168.188.168:80 default_server;
root /var/www/html;
server_name 192.168.188.168;

location ~ .* {
proxy_pass http://10.0.5.18;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

}

server {
listen 192.168.188.169:80 default_server;
root /var/www/html;
server_name 192.168.188.169;

location ~ .* {
proxy_pass http://10.0.5.19;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

}