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

来源:互联网 发布:域名dns解析服务器 编辑:程序博客网 时间:2024/04/29 21:24

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

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

配置

(1)安装proxy组件

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>    ...     ProxyPass /test/ http://127.0.0.1:3000/       ProxyPassReverse /test/ http://127.0.0.1:3000/  ...</VirtualHost>  

重启服务:

sudo service apache2 restart

测试一下试试:

cd ~/wwwroot/testecho hello>index.htmlpython -m SimpleHTTPServer 3000

打开浏览器测试一下吧:)
http://localhost/test

0 0