【问题标题】:referring to tomcat URLs via multiple aliases in an apache web server + tomcat setup通过 apache web 服务器 + tomcat 设置中的多个别名引用 tomcat URL
【发布时间】:2021-06-23 12:41:04
【问题描述】:

我有一个 apache web 服务器,它充当基本 url 的负载平衡器/网关,比如http://example.com

反过来,Apache Web 服务器中有路由逻辑将请求通过路径http://example.com/app1http://example.com/app2 转发到各个 tomcat 服务器,例如 app1、app2。

这里,app1 和 app2 是独立的 tomcat 实例,它们是独立的 webapp。

现在需要将http://example.com/app1也称为http://example.com/alias1,即/app1和/alias1都必须路由到app1对应的tomcat服务器,只安装一个app1(即alias1不是单独的tomcat实例)

任何指向以这种方式为 tomcat webapp 设置别名的文档的指针将不胜感激。

【问题讨论】:

    标签: apache tomcat


    【解决方案1】:

    您可以使用 apahce ReverseProxy 技术根据 url 将请求“路由”到不同的 tomcat:https://httpd.apache.org/docs/current/mod/mod_proxy.html

    你可以这样开始:

    ProxyPass "/foo/" "http://foo.tamcat.lan:8080/foo/"
    ProxyPassReverse "/foo/" "http://foo.tomcat.lan:8080/foo/"
    
    ProxyPass "/bar/" "http://192.168.254.30:8080/"
    ProxyPassReverse "/bar/" "http://192.168.254.30:8080/"
    

    如果它正常工作,您可以为别名添加一个规则(可以是另一个 proxyPass、一个带有代理标志的 rewriteRule 或任何您需要/喜欢的)。

    即使不是最优方案,如果你有多个tomcat servin同一个应用,你也可以负载均衡流量:https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html

    【讨论】:

      猜你喜欢
      • 2015-07-29
      • 2010-11-10
      • 2012-07-22
      • 2019-11-04
      • 2018-09-09
      • 2015-11-23
      • 2010-12-09
      • 1970-01-01
      • 2014-07-28
      相关资源
      最近更新 更多