Nginx反向代理apache及Nginx

一. 代理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;

   }

}

相关文章
相关标签/搜索