標籤:style blog http io ar color os sp on
正向 Proxy和反向 Proxy是從資料流方向命名的,正向 Proxy,代理的使用者請求;反向 Proxy,替代伺服器接受請求
正向 Proxy: 使用者 -》 Proxy 伺服器 -》 www 使用者的請求資料給發Proxy 伺服器,Proxy 伺服器協助使用者去www請求資料,然後再返回給使用者
作用:配置Proxy 伺服器,用戶端做代理設定後可以訪問facebook,Twitter
如何配置:
<VirtualHost *:80> DocumentRoot /home/web ServerName www.xxx.com ServerAlias xxx.com ErrorLog "logs/zx_xxx.com-error.log" CustomLog "logs/zx_xxx.com-access.log" common <Directory "/home/web"> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> ProxyRequests On ProxyVia On <Proxy *> Order deny,allow Allow from all </Proxy></VirtualHost>
先建立一個虛擬機器主機,然後在裡面配置標紅的指令,標紅指令就是配置正向 Proxy指令
ProxyRequests On 代表開啟正向 Proxy
ProxyVia On 修改header資料頭,做標識
反向 Proxy: 使用者 《- Proxy 伺服器 《- www.xxx.xxx xxx網站根伺服器不是直接接收使用者的請求,而是通過自己的Proxy 伺服器接收請求,然後再轉寄給自己。
作用:如果你用自己的網域名稱www.xxx.xxx配置了www.baidu.com 的反向 Proxy,那麼你訪問www.xxx.xxx就相當於訪問www.baidu.com (google需要配置ssl代理)
配置:
############反向 Proxy<VirtualHost *:80> DocumentRoot "D:/www/test" ServerName www.xxx.com ServerAlias xxx.com ErrorLog "logs/fx_xxx.com-error.log" CustomLog "logs/fx_quduoqi.com-access.log" common <Directory "D:/www/test"> Options FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> #反向 Proxy設定 ProxyPass / http://www.baidu.com/ ProxyPassReverse / http://www.baidu.com/</VirtualHost>
同正向 Proxy也是先配置一個虛擬機器主機,然後配置反向 Proxy指令
ProxyPass / http://www.baidu.com/ 代表到www.xxx.com/的請求都轉給 www.baidu.com
ProxyPassReverse / http://www.baidu.com/ 替換返回頁面中的url 如果頁面中有www.baidu.com/xx/xx都替換成www.xxx.xxx/xx/xx
我的apache是2.4.6 僅供參考
參考:
http://www.cnblogs.com/zemliu/archive/2012/04/18/2454655.html
http://baike.baidu.com/view/1165595.htm
http://baike.baidu.com/view/751.htm
apache 配置Proxy 伺服器(正向 Proxy,反向 Proxy)