<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
ServerName www.b.org
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://127.0.0.1:9000/
ProxyPa***everse / http://127.0.0.1:9000/
</VirtualHost>
二 动态加载
动态加载:编译进一个已经装好了的apache中(编译为dso模块)
已经装好的apache在 /usr/local/apache2
进入apache源码的模块目录进行编译
cd httpd-2.0.63/modules/proxy/
/usr/local/apache2/bin/apxs -c -i -a mod_proxy.c proxy_connect.c proxy_http.c proxy_util.c
从输出里面看到apache的modules目录下已经产生了mod_proxy.so,且已经在httpd.conf中激活了
cd /usr/local/apache2/conf/
ls ../modules/ 看到确实有mod_prxoy.so
编辑配置文件
vi httpd.conf
修改如下
加载模块
LoadModule proxy_module modules/mod_proxy.so (这句是编译激活时产生的)
LoadModule proxy_http_module modules/mod_proxy.so (这句是要手动添加的)
虚拟主机的部分加上
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
ServerName www.a.org
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://192.168.0.115/
ProxyPa***everse / http://192.168.0.115/
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
ServerName www.b.org
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://127.0.0.1:9000/
ProxyPa***everse / http://127.0.0.1:9000/
</VirtualHost>
重启apache生效
注:
如果不加LoadModule proxy_http_module modules/mod_proxy.so,则浏览器页面打不开,页面显示
Forbidden
You don't have permission to access / on this server.
日志acess_log里面显示
192.168.0.28 - - [03/Jun/2009:16:16:27 +0800] "GET /?sessionId=4293567494722637330&rand=1244014624405&CONTEXT=0&page=com.othe
r.AjaxWhoWhatUpdate&xrand=1244016991554&wwRandId=1244014624405&wwBugId=2341&wwType=View HTTP/1.1" 403 315
或者
192.168.0.28 - - [03/Jun/2009:17:10:32 +0800] "GET / HTTP/1.1" 403 315
即403错误
日志error_log里面显示
[Wed Jun 03 17:08:46 2009] [warn] proxy: No protocol handler was valid for the URL /. If you are using a DSO version of mod_p
roxy, make sure the proxy submodules are included in the configuration using LoadModule.