apache 配置Proxy 伺服器(正向 Proxy,反向 Proxy)

來源:互聯網
上載者:User

標籤: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)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.