【问题标题】:Reverse proxy with Apache and static content behind application inside of jetty使用 Apache 的反向代理和码头内应用程序背后的静态内容
【发布时间】:2012-10-09 01:55:24
【问题描述】:

我的应用程序基于 spring 并由 jetty 提供服务。当前设置如下所示。

Apache -> 反向代理 -> Embedded Jetty -> 应用程序

当我在没有反向代理的情况下直接访问应用程序 (http://127.0.0.1:15000) 时,会加载静态资源(css、.js 等),但如果我通过反向代理访问它 (https://127.0.0.1/app/)它不起作用。

这是我的配置。

apache2.conf

ProxyPass /app/ http://127.0.0.1:15000/
ProxyPassReverse /app/ http://127.0.0.1:15000/
SSLProxyEngine on 

RewriteEngine On
RewriteRule /app$ /app/ [R]

spring-servlet.xml

 ...
 <mvc:default-servlet-handler />
 <mvc:resources mapping="/resources/**" location="/resources/" />
 ... 

我希望以两种方式传递静态内容。

【问题讨论】:

  • 最简单的解决方案是使路径匹配,即使用 /app 作为 servlet 上下文路径。

标签: spring apache proxy jetty


【解决方案1】:

我知道这为时已晚。但是对于任何可能最终出现在这里的人来说,将映射添加到您的资源路径将解决问题。

ProxyPass /app/resources http://127.0.0.1:15000/app/resources
ProxyPassReverse /app/resources http://127.0.0.1:15000/app/resources

这应该在您现有的映射之前添加。(首先读取最长的 URL,因为首先读取哪个映射,获胜)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-27
    • 2021-01-31
    • 2017-01-23
    • 2011-09-17
    • 2013-03-20
    • 2017-07-09
    • 2016-04-04
    • 1970-01-01
    相关资源
    最近更新 更多