Apache根据URL路径进行转发
时间:2015-10-07 14:10 来源:linux.it.net.cn 作者:IT
根据URL的路径进行转发,适合没有域名的情况下
根据URL的PATH进行转发,适合没有域名的情况下,例如:
http://127.0.0.1/support 转到 http://192.168.1.251:8008/support
http://127.0.0.1/gdForestry 转到 http://192.168.1.251:9007/gdForestry
首先启用代理模块,去掉httpd.conf中的注释:
1
2
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
然后配置虚拟主机,重启完成(这里用的Apache2.4,语法稍有不同):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<VirtualHost 127.0.0.1:80>
ServerAdmin webmaster@dummy-host.example.com
ServerName 127.0.0.1
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Require all granted
</Proxy>
ProxyPass /support http://192.168.1.251:8008/support ProxyPass /gdForestry http://192.168.1.251:9007/gdForestry ProxyPassReverse /support http://192.168.1.251:8008/support ProxyPassReverse /gdForestry http://192.168.1.251:9007/gdForestry ErrorLog "logs/test.localhost-error_log"
CustomLog "logs/test.localhost-access_log" common
</VirtualHost>
如果不需要配置在虚拟主机,要对全局进行转发,则直接配置在httpd.conf最后添加:
1
2
ProxyPass /cas http://192.168.0.206:9090/cas ProxyPassReverse /cas http://192.168.0.206:9090/cas
(责任编辑:IT)
根据URL的路径进行转发,适合没有域名的情况下
根据URL的PATH进行转发,适合没有域名的情况下,例如: 首先启用代理模块,去掉httpd.conf中的注释:
然后配置虚拟主机,重启完成(这里用的Apache2.4,语法稍有不同):
如果不需要配置在虚拟主机,要对全局进行转发,则直接配置在httpd.conf最后添加:
(责任编辑:IT) |