ubuntu之apache正向代理及反向代理(ProxyPass\ProxyPassReverse)

ubuntu之apache正向代理及反向代理(ProxyPass\ProxyPassReverse)

环境是UBUNTU 最新版apache2安装的目录结构有变化网上很多文章都不适用了。

准备

如果你原程序有问题,先清理一下
apt-get --purge remove apache2
apt-get --purge remove apache2.2-common
apt-get autoremove
apt-get --purge remove apache-common
apt-get --purge remove apache
sudo find /etc -name "*apache*" -exec rm -rf {} /;
sudo rm -rf /var/www


安装

apt-get install apache2
service apache2 stop

配置


(1)
a2enmod proxy proxy_ajp proxy_balancer proxy_connect proxy_ftp proxy_http

(2)
修改配置 sudo vim /etc/apache2/mods-enabled/proxy.conf

如果有内容设置则设置如下:
<IfModule mod_proxy.c>
    #turning ProxyRequests on and allowing proxying from all may allow
    #spammers to use your proxy to send email.
ProxyRequests Off
<Proxy *>
    Order deny,allow
    Deny from all
    #Allow from .your_domain.com
</Proxy>

(3)
修改配置 vim /etc/apache2/sites-enabled/default
<VirtualHost *:80>
         ServerName niuyufu.iokokok.cn
         ServerAlias niuyufu.iokokok.cn
         ProxyPass / http://www.baidu.com/
         ProxyPassReverse / http://www.baidu.com/
</VirtualHost>

service apache2 restart
测试一下吧,你现在代理了百度!!!

你可能感兴趣的:(ubuntu之apache正向代理及反向代理(ProxyPass\ProxyPassReverse))