一. 代理apahce:
1.先配置nginx配置文件:
[root@centos7 conf.d]# vim /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-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;
}
}