一. 代理apahce:nginx
1.先配置nginx配置文件:apache
[root@centos7 conf.d]# vim /opt/app/nginx/conf.d/wordpress.confvim
server {centos
listen 80;app
server_name localhost;ide
location / {wordpress
proxy_pass http://192.168.1.204;centos7
proxy_set_header X-Real-IP $remote_addr;代理
}日誌
}
2.若apache須要看到客戶端真是IP,須要修改配置文件.
vim /etc/httpd/conf/httpd.conf
LogFormat "%{X-Real-IP}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
原來的%h改爲{X-Real-IP}i ,這裏日誌裏就客戶端訪問IP了.
二.nginx方面.
簡單方便.深刻的須要看官方文檔.
[root@centos7 conf.d]# cat /opt/app/nginx/conf.d/wordpress.conf
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://192.168.1.204;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}