apache - centOS htaccess 文件上的 Proxypass 和 ProxyPassReverse 复制

标签 apache .htaccess tomcat proxypass

我一直在尝试在我托管在 Hostgator Centos 服务器上的网站上复制 ProxyPass 和 ProxyPassReverse。我有一个在 Amazon ec2 上运行的 tomcat 应用程序,URL 为 http://myec2address.com:8080/portal/

我在 httpd-proxy-html 文件上使用以下配置成功地在本地 Windows 机器上复制了用例。

ProxyPass/portalBI http://{localhost}:8080/poratalBI

ProxyPass/sw-style http://{localhost}:8080/sw-style

ProxyPass/portal-style http://{localhost}:8080/portal-style

ProxyPassReverse/portalBI http://{localhost}:8080/agrometricsBI

ProxyPassReverse/sw-style http://{localhost}:8080/sw-style

ProxyPassReverse/portal-style http://{localhost}:8080/portal-style

由于托管网站位于共享服务器上,我假设我将不得不修改我的 .htaccess 文件。我尝试了很多技巧但没有成功。你能帮忙吗?由于 centOS,我们需要处理特殊字符吗?

谢谢。

最佳答案

您不能在 htaccess 文件中使用 ProxyPassProxyPassReverse。您可以做的最好的事情是使用 mod_rewrite 的 P 标志进行反向代理(相当于 ProxyPass):

RewriteEngine On
RewriteRule ^portalBI(.*)$ http://localhost:8080/poratalBI$1 [L,P]
RewriteRule ^sw-style(.*)$ http://localhost:8080/sw-style$1 [L,P]
RewriteRule ^portal-style(.*)$ http://localhost:8080/portal-style$1 [L,P]

除非您的共享主机加载了 mod_proxy,否则这不会起作用,而且您不会像使用 ProxyPassReverse 那样获得反向位置重写。

关于apache - centOS htaccess 文件上的 Proxypass 和 ProxyPassReverse 复制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23238703/

相关文章:

linux - 在 Apache 中手动创建 301 重定向以将站点的所有 IP 请求重定向到正确的域名

.htaccess 301 重定向将旧网址传递到新网址

.htaccess - mediawiki 从 URL 中删除 index.php

java - Apache OfBiz 可以与现有版本的 Tomcat 一起安装吗

apache - xampp 虚拟主机 - 始终加载 htdocs

apache - 在 Dreamweaver CS4 中配置 Subversion 版本控制

php - Wordpress 子目录给出 404

java - Spring : How to configure tomcat Datasource Programatically in Groovy DAO

java - 为不同于 JVM 的 war 设置语言环境?

regex - Apache 位置匹配通配符 URL