1:修改 httpd.conf 文件中:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
可能在您系统这几个so文件位置有异,请自行检查变更
2:全域代理
<VirtualHost 111.111.111.111>
ServerName www1.xxx.com
ProxyPass / http://172.16.1.101/
ProxyPassReverse / http://172.16.1.101/
</VirtualHost>
3:虚拟文件夹
在 httpd.conf 文件中,添加:
ProxyPass /Test http://127.0.0.1:8080/
ProxyPassReverse /Test http://127.0.0.1:8080
<proxy http://127.0.0.1:8080>
AllowOverride None
Order Deny,Allow
Allow from all
</proxy>
关于2,补充:
<VirtualHost 111.111.111.111:80>
ProxyRequests On
ProxyVia On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyRequests Off
ServerName www.scdlt.com
ProxyPass / http://www.scdlt_old.com:8080/ retry=1 acquire=3000 timeout=600 Keepalive=On
ProxyPassReverse / http://www.scdlt_old.com:8080/
</VirtualHost>
基于Apache mod_proxy的反向代理缓存加速实现
Apache包含了mod_proxy模块,可以用来实现代理服务器,针对后台服务器的反向加速
安装apache 1.3.x 编译时:
–enable-shared=max –enable-module=most
注:Apache 2.x中mod_proxy已经被分离成mod_proxy和mod_cache:同时mod_cache有基于文件和基于内存的不同实现
创建/var/www/proxy,设置apache服务所用户可写
mod_proxy配置样例:反相代理缓存+缓存
架设前台的www.example.com反向代理后台的www.backend.com的8080端口服务。
修改:httpd.conf
<VirtualHost *>
ServerName www.example.com
ServerAdmin admin@example.com
# reverse proxy setting
ProxyPass / http://www.backend.com:8080/
ProxyPassReverse / http://www.backend.com:8080/
# cache dir root
CacheRoot "/var/www/proxy"
# max cache storage
CacheSize 50000000
# hour: every 4 hour
CacheGcInterval 4
# max page expire time: hour
CacheMaxExpire 240
# Expire time = (now – last_modified) * CacheLastModifiedFactor
CacheLastModifiedFactor 0.1
# defalt expire tag: hour
CacheDefaultExpire 1
# force complete after precent of content retrived: 60-90%
CacheForceCompletion 80
CustomLog /usr/local/apache/logs/dev_access_log combined
</VirtualHost>