1.反向代理多个虚拟主机节点服务器

环境

反向代理服务器192.168.76.4web1            192.168.76.5 web2192.168.76.6

先给web1和web2安装nginx web基本配置

web1:    echo

"`hostname -I `www"

>/usr/share/nginx/html/index.html

web2:    echo

"`hostname -I `bbs"

>/usr/share/nginx/html/index.html

然后在反向代理服务器中写好dns解析。

最后在nginx配置文件或者子配置文件夹中填写以下内容。

upstream wwwServerPools {

server 192.168.76.3:80 weight=1;

server 192.168.76.5:80 weight=1;

}

server {

listen 80;

server_name yunjisuan.com;

location / {

proxy_pass http://wwwServerPools;

proxy_set_header Host $host;

#proxy_set_header X-Forwarded-For $remote_addr;

}

}

server {

listen 80;

server_name wangluoanquan.com;

location / {

proxy_pass http://wwwServerPools;

proxy_set_header Host $host;

#proxy_set_header X-Forwarded-For $remote_addr;

}

}

2.经过反向代理后的节点服务器记录用户ip

如果web服务器是nginx部署的话,直接在反向代理服务器中nginx配置文件中添加

 在web服务器的日志文件中就可以看到ip

 要是web服务器是用apache部署的话,修改vim /etc/httpd/conf/httpd.conf

 在%h后添加即可

好文阅读

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: