繁体   English   中英

来自子域的apache proxypass

[英]apache proxypass from subdomain

我想将apache2中的proxy从子域传递到其他这样的端口

http://test1.example.com- > http://test1.example.com:6543

无论如何,是否有写配置文件,但该子域不特定,而是所有子域

无论如何,例如http://.*.example.com-> http://.*.example.com:6543

和http://.*.example.com/first/second-> http://.*.example.com:6543 / first / second

这是我的配置

 <VirtualHost *:80> ServerName example.com ProxyPassMatch ^([^.]+)\\.example\\.com(.*) http://$1.example.com:6543/$2 ProxyPassReverse / http://example.com </VirtualHost> 

为此,您将需要mod_rewrite 它可以代理[P] 如下使用它(为了满足语法突出显示而删除了VirtualHost标签):

ServerName example.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com$
RewriteRule ^(.*) http://%1.example.com:6543/$1 [P]

%1是子域,条件匹配, $1是路径,规则匹配。


您也可以不使用RewriteCond来执行此操作,只需使用

RewriteRule ^(.*) http://%{HTTP_HOST}:6543/$1 [P]

我使用了上面的额外步骤来使其更具信息性,例如,在您要使用path中的子域的情况下

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM