代理 tomcat url 将主机请求映射到路径

发布于 2024-09-18 14:26:35 字数 448 浏览 3 评论 0原文

如果可能的话,如何将主机名请求重定向到已部署应用程序之一的特定子目录?

例如,我希望转发

http://host.com 

http://host.com/app/path

但是可以重定向到 tomcat 上的特定应用程序,例如,

    <Host name="host.com" appBase="webapps">
        <Context path="/" docBase="webapps/app" debug="6"/>
    </Host>

但我从未设法将其重定向到应用程序的子路径。我想要一种仅使用 tomcat 的方法,而不是使用带有 apache2 的外部 mod_proxy 来实现此目的。

how, if possible, can I redirect a request for a hostname to a specific subdirectory of one of the deployed apps?

E.g., I wish to forward

http://host.com 

to

http://host.com/app/path

It is however possible to redirect to a specific application on tomcat, e.g.,

    <Host name="host.com" appBase="webapps">
        <Context path="/" docBase="webapps/app" debug="6"/>
    </Host>

But I've never managed to redirect it to a subpath of an application. I'd fancy a tomcat-only approach over using an external mod_proxy with apache2 to achieve this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

紫瑟鸿黎 2024-09-25 14:26:35

通过将路径更改为 "" (即使其成为主机的默认 Web 应用程序),这对我有用。

<Host name="host.com" appBase="webapps">
            <Context path="" docBase="webapps/app" debug="6"/>
        </Host>

它可以正确提供静态文件,但我的 JSTL 现在失败了。

无论如何,你能尝试一下吗?

This worked for me by changing path to "" (i.e. making it default web app for the Host)

<Host name="host.com" appBase="webapps">
            <Context path="" docBase="webapps/app" debug="6"/>
        </Host>

It serves static files correctly, but my JSTL fails now.

Anyways, can you try?

梦开始←不甜 2024-09-25 14:26:35

这似乎不可能。最终的解决方案是使用Apache2的mod_proxy来代理请求。

This does not seem possible. Final solution was to use mod_proxy of Apache2 to proxy the request.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文