nginx四层配置如下,IP:172.16.1.61
stream {
upstream Http {
server 172.16.1.31:80;
}
server {
listen 80;
proxy_pass Http;
proxy_bind $remote_addr transparent;
}
}
nginx七层配置如下,IP:172.16.1.31
# cat /etc/nginx/conf.d/proxy.conf
upstream node {
server 172.16.1.7;
}
server {
listen 80;
server_name test.nginx.com;
location / {
proxy_pass http://node;
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;
}
}
Nginx Web配置如下,IP:172.16.1.7
# cat /etc/nginx/conf.d/test.conf
server {
listen 80;
server_name test.nginx.com;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
}
我的电脑是解析 test.nginx.com至172.16.1.61 四层负载均衡上面的