在一些情况下,经常会使用apache的proxy功能,具体含义就是在满足某些情况下apache代替用户进行http的转请求, 网上到处都是的代理功能即是本功能的具体应用。
使用proxy,需要装上mod_proxy的apache的dso,然后在apache中增加类似如下的配置文件
<VirtualHost *:80>
ServerName img.aaa.bbb.com
DocumentRoot /home/share/htdocs/img
ErrorLog logs/apache/img/error
RewriteEngine On
# RewriteLogLevel 4
RewriteLog "logs/yapache/rewritelog_yimg"
RewriteCond /home/share/htdocs/img/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.+)$ http://img01.img.aaa.bbb.com/cn/$1 [QSA,P,L]
</VirtualHost>
使用proxy,需要装上mod_proxy的apache的dso,然后在apache中增加类似如下的配置文件
<VirtualHost *:80>
ServerName img.aaa.bbb.com
DocumentRoot /home/share/htdocs/img
ErrorLog logs/apache/img/error
RewriteEngine On
# RewriteLogLevel 4
RewriteLog "logs/yapache/rewritelog_yimg"
RewriteCond /home/share/htdocs/img/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.+)$ http://img01.img.aaa.bbb.com/cn/$1 [QSA,P,L]
</VirtualHost>
本文介绍了如何使用 Apache 的 mod_proxy 模块实现 HTTP 请求的代理转发功能。通过配置 VirtualHost 和 Rewrite 规则,可以有效地将请求从一个域名重定向到另一个实际提供服务的服务器。
1253

被折叠的 条评论
为什么被折叠?



