环境
反向代理服务器 | 192.168.76.4 |
web1 | 192.168.76.5 |
web2 | 192.168.76.6 |
先给web1和web2安装nginx web基本配置
- 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;
-
- }
-
- }
如果web服务器是nginx部署的话,直接在反向代理服务器中nginx配置文件中添加
在web服务器的日志文件中就可以看到ip
要是web服务器是用apache部署的话,修改vim /etc/httpd/conf/httpd.conf
在%h后添加即可