ProxyPassReverse to Tomcat 添加路径到 URL

发布于 2024-12-28 19:48:51 字数 2085 浏览 7 评论 0原文

我在 Tomcat 6.0.32 中运行 Railo 3。 tomcat服务器的前端是Apache 2.2.20。 Tomcat 和 Apache 是 openCSW 预构建的二进制文件。 Railo 只是部署在 tomcat 的 autodeploy 目录 webapps 中的最新构建战争。

当我尝试访问 Tomcat 服务器上的 Railo 和内容时,一切正常。

然而,当tomcat上的railo将我重定向到其自身时,它失败了。大多数情况下,当 cfm 脚本使用 CGI.script_name 时,会返回错误。

在 Apache 方面,内容可在 www.hostname.com 上找到。 Apache 通过 AJP 将用户重定向到 www.hostname.com:8009/railo/content 上的 tomcat。

tomcat 上的脚本(取自开放的 OAuth 示例)位于:

/opt/csw/share/tomcat6/webapps/railo/content/oauth_test/examples/admin_consumers.cfm

当我访问它并尝试执行某些操作时,它会调用它本身带有一些参数,但此时,railo 转储出一个错误,抱怨找不到该文件:

Page /content/railo/content/oauth_test/examples/admin_consumers.cfm [/opt/csw/share/tomcat6/webapps/railo/content/railo/content/oauth_test/examples/admin_consumers.cfm] not found

正如您所看到的,railo 添加了两倍于 tomcat 的相对路径: /railo/content/railo/content

这是我在 Apache 中对虚拟主机的配置:

<VirtualHost *:443>
    ServerName www.hostname.com
    DocumentRoot "/opt/www/hostname/htdocs/"

    ProxyRequests Off
    <proxy *="">
        Order deny,allow
        Allow from all
    </proxy>

    ProxyPass / ajp://www.hostname.com:8009/railo/content/
    ProxyPassReverse / http://www.hostname.com:8888/railo/content/
</VirtualHost>

我尝试了 ProxyPassReverse 指令的几种变体,但到目前为止还没有成功。基于网络上的广泛搜索(ProxyPassReverse 之谜< /a>),我尝试了 proxypassreverse:

    ProxyPassReverse / ajp://www.hostname.com:8009/railo/content/
    ProxyPassReverse / http://www.hostname.com:8888/railo/content/
    ProxyPassReverse / http://localhost:8888/railo/content/
    ProxyPassReverse / https://www.hostname.com

Tomcat 服务器也有一个这样定义的虚拟主机:

 <Host name="www.hostname.com">
    <Context path="" docBase="/opt/csw/share/tomcat6/webapps/railo/content" />
 </Host>

但每次,我总是从 Railo 收到错误。

有没有人见过 Railo 或 CGI 的这个问题,并且知道如何解决它?

I'm running Railo 3 in Tomcat 6.0.32. The tomcat server is fronted by Apache 2.2.20. Tomcat and Apache are pre built binaries from openCSW. Railo is just the latest build war deployed in tomcat's autodeploy dir webapps.

Everything is working fine when I try to access railo and content on the tomcat server.

It fails however, when railo on tomcat redirects me to itself. Mostly, when a cfm script uses the CGI.script_name, it will be returned wrong.

On the Apache side, the content is available on www.hostname.com. Apache redirects the user to tomcat through AJP on www.hostname.com:8009/railo/content.

A script on tomcat (taken from open OAuth example) is available at:

/opt/csw/share/tomcat6/webapps/railo/content/oauth_test/examples/admin_consumers.cfm

When I access it and try to perform some action, it calls itself with a few parameters, but at that point, railo dumps out an error, complaining that the file can not be found:

Page /content/railo/content/oauth_test/examples/admin_consumers.cfm [/opt/csw/share/tomcat6/webapps/railo/content/railo/content/oauth_test/examples/admin_consumers.cfm] not found

As you can see railo added twice the relative path from tomcat: /railo/content/railo/content

This is my configuration for the virtual host in Apache:

<VirtualHost *:443>
    ServerName www.hostname.com
    DocumentRoot "/opt/www/hostname/htdocs/"

    ProxyRequests Off
    <proxy *="">
        Order deny,allow
        Allow from all
    </proxy>

    ProxyPass / ajp://www.hostname.com:8009/railo/content/
    ProxyPassReverse / http://www.hostname.com:8888/railo/content/
</VirtualHost>

I tried several variant for the ProxyPassReverse directive, but with no luck so far. Based on extensive searches on the web (The Mystery of ProxyPassReverse), I tried this for the proxypassreverse:

    ProxyPassReverse / ajp://www.hostname.com:8009/railo/content/
    ProxyPassReverse / http://www.hostname.com:8888/railo/content/
    ProxyPassReverse / http://localhost:8888/railo/content/
    ProxyPassReverse / https://www.hostname.com

The tomcat server also has a virtual host defined like this:

 <Host name="www.hostname.com">
    <Context path="" docBase="/opt/csw/share/tomcat6/webapps/railo/content" />
 </Host>

But everytime, I always get the error from Railo.

Has anyone ever seen this problem with Railo, or CGI, and has an idea how to fix it?

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

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

发布评论

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

评论(1

眉目亦如画i 2025-01-04 19:48:51

您指定了两次“/railo/content”。一次在您的“docBase”属性中,然后再次在您的代理属性中。因此,通过 Apache 代理的请求将在其请求路径中出现两次“railo/content/”,因为您已将其列出两次:一次在 Apache 中,另一次在 Tomcat 中。

尝试在 ProxyPassReverse 属性中删除 /railo/content/:

ProxyPassReverse / http://www.hostname.com: 8888/

这将使 Tomcat 配置自行添加 /railo/content/ 位。

You are specifying "/railo/content" twice. Once in your "docBase" attribute and again in your Proxy attributes. So, requests being proxied through Apache are going to have "railo/content/" twice in their request paths because you have it listed twice: once in Apache, another time in Tomcat.

Try leaving off the /railo/content/ in your ProxyPassReverse attribute:

ProxyPassReverse / http://www.hostname.com:8888/

This will let the Tomcat config add the /railo/content/ bit all by itself.

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