Apache虚拟主机redirect到其他服务器

这是情况:

服务器A主机“ http://internal.intranet ”

服务器B托pipe“ http://servernameb.intranet/foo/bar ”上的内部应用程序

服务器A需要将所有传入的httpstream量redirect到服务器B的地址,而用户不会注意到它。

我可以很容易地做到这一点与以下configuration文件:

<VirtualHost 10.0.4.26> ServerName internal.intranet ServerAlias internal RewriteEngine on # Deny TRACE/TRACK request methods RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK) RewriteRule .* - [F] #RewriteRule "^/files(.*)$" "/files$1" [L] # Everything else not matched above needs to go to the servlet container # via HTTP listening on port 8008. The [P] flag (which is required) # implies that our requests will be handled by mod_proxy. RewriteRule "^/(.*)" "http://servernameb.intranet:8080/foo/bar/$1" [P] </VirtualHost> 

但问题是,用户浏览器中显示的url是: http://servernameb.intranet …..而不是http://internal.intranet

我不希望用户与servernameb地址联系。

我知道我可能需要使用ProxyPass和ProxyPassReverse,但我不能得到它的工作。

你应该尝试以下几点:

 <VirtualHost 10.0.4.26> ServerName internal.intranet ServerAlias internal ProxyPass / http://servernameb.intranet/foo/bar/ ProxyPassReverse / http://servernameb.intranet/foo/bar/ </VirtualHost>