gpt4 book ai didi

apache 2.4 AJP 代理不工作

转载 作者:行者123 更新时间:2023-11-28 22:07:51 27 4
gpt4 key购买 nike

我正在尝试配置我的 Apache 2.4 以连接到我的后端 Tomcat 8.0.28。在我的 Mac OS X El Capitan 中。

我使用了支持 AJP 的 NameBased VirtualHost。配置文件 apache_serviceproxy.conf 位于:/Library/Server/Web/Config/Proxy

<VirtualHost 10.0.1.100:80>
ProxyPreserveHost On
ServerName www.storageway.com.au
ServerAlias storageway.com.au
ServerAdmin cidy.long@gmail.com
ProxyPass / ajp://127.0.0.1:8009/StorageWayServer/
ProxyPassReverse / ajp://127.0.0.1:8009/StorageWayServer/
</VirtualHost>

Tomcat 应用上下文是:http://localhost:8080/StorageWayServer , 从 LAN 访问 Tomcat,一切正常。但是当我尝试通过 Internet 请求时,apache 2.4 通过 AJP 调用 Tomcat 时效果不佳。

Tomcat 正确地从 apache AJP 接收到 html 请求(),但是从那时起,html 中的每个包含 css、javascript 和图像的请求 url 都是错误的,它是简单的双应用程序上下文名称。

这是我的 Tomcat 访问日志:

148.251.45.185 - - [31/Oct/2015:14:26:07 +1100] "GET /StorageWayServer/ HTTP/1.1" 200 19098
148.251.45.185 - - [31/Oct/2015:14:26:07 +1100] "GET /StorageWayServer/StorageWayServer/dojo-release-1.10.4/dojo/resources/dojo.css HTTP/1.1" 404 1173
148.251.45.185 - - [31/Oct/2015:14:26:08 +1100] "GET /StorageWayServer/StorageWayServer/css/style.css HTTP/1.1" 404 1113
148.251.45.185 - - [31/Oct/2015:14:26:08 +1100] "GET /StorageWayServer/StorageWayServer/dojo-release-1.10.4/dijit/themes/claro/claro.css HTTP/1.1" 404 1183
148.251.45.185 - - [31/Oct/2015:14:26:09 +1100] "GET /StorageWayServer/StorageWayServer/css/dashboard.css HTTP/1.1" 404 1121
148.251.45.185 - - [31/Oct/2015:14:26:09 +1100] "GET /StorageWayServer/StorageWayServer/css/storageway_homeabout.css HTTP/1.1" 404 1143
148.251.45.185 - - [31/Oct/2015:14:26:09 +1100] "GET /StorageWayServer/StorageWayServer/dojo-release-1.10.4/dojo/dojo.js HTTP/1.1" 404 1151
148.251.45.185 - - [31/Oct/2015:14:26:10 +1100] "GET /StorageWayServer/StorageWayServer/images/storageway_logo.png HTTP/1.1" 404 1139
148.251.45.185 - - [31/Oct/2015:14:26:10 +1100] "GET /StorageWayServer/StorageWayServer/images/icons/publish.png HTTP/1.1" 404 1135
148.251.45.185 - - [31/Oct/2015:14:26:10 +1100] "GET /StorageWayServer/StorageWayServer/images/icons/search_engine.png HTTP/1.1" 404 1147
148.251.45.185 - - [31/Oct/2015:14:26:10 +1100] "GET /StorageWayServer/StorageWayServer/images/icons/search33.png HTTP/1.1" 404 1137
148.251.45.185 - - [31/Oct/2015:14:26:10 +1100] "GET /StorageWayServer/StorageWayServer/images/button_hover.gif HTTP/1.1" 404 1133
148.251.45.185 - - [31/Oct/2015:14:26:11 +1100] "GET /StorageWayServer/StorageWayServer/images/button_span_hover.gif HTTP/1.1" 404 1143

如果我通过直接访问 Tomcat 从 LAN 请求它,它工作正常,记录为:

10.0.1.222 - - [31/Oct/2015:14:58:53 +1100] "GET /StorageWayServer/images/icons/publish.png HTTP/1.1" 304 -
10.0.1.222 - - [31/Oct/2015:14:58:53 +1100] "GET /StorageWayServer/images/icons/search_engine.png HTTP/1.1" 304 -
10.0.1.222 - - [31/Oct/2015:14:58:53 +1100] "GET /StorageWayServer/images/icons/search33.png HTTP/1.1" 304 -
10.0.1.222 - - [31/Oct/2015:14:58:53 +1100] "GET /StorageWayServer/dojo-release-1.10.4/dijit/dijit.js HTTP/1.1" 304 -
10.0.1.222 - - [31/Oct/2015:14:58:53 +1100] "GET /StorageWayServer/images/button_span_hover.gif HTTP/1.1" 304 -
10.0.1.222 - - [31/Oct/2015:14:58:53 +1100] "GET /StorageWayServer/images/button_hover.gif HTTP/1.1" 304 -
10.0.1.222 - - [31/Oct/2015:14:58:53 +1100] "GET /StorageWayServer/dojo-release-1.10.4/dijit/themes/claro/images/spriteArrows.png HTTP/1.1" 304 -
10.0.1.222 - - [31/Oct/2015:14:58:53 +1100] "GET /StorageWayServer/dojo-release-1.10.4/dijit/themes/claro/form/images/buttonArrows.png HTTP/1.1" 304 -

我试图从谷歌找到一些帮助并尝试使用

RedirectMatch /StorageWayServer http://www.storageway.com.au/

但我从不从请求 url 中删除额外的应用程序上下文。

欢迎任何建议或经验。

周末愉快!

最佳答案

不要更改 ProxyPass 指令中的上下文路径。当您这样做时,有很多很多方法会搬起石头砸自己的脚。

据推测,您页面上的链接是绝对链接,因此它们包含上下文路径。当客户端随后请求这些时,ProxyPass 指令再次添加上下文路径。

你有三个选择:

  1. 将您的应用重新部署为 ROOT 网络应用并使用

ProxyPass / ajp://127.0.0.1:8009/

  1. 使用上下文路径访问您的应用程序并使用

ProxyPass /StorageWayServer/ ajp://127.0.0.1:8009/StorageWayServer/

  1. 花费数天/数周时间尝试配置 mod_sed 或类似工具以即时编辑响应以更正链接。

我见过大型组织花费大量时间和金钱选择选项 3,我真的不推荐它。

关于apache 2.4 AJP 代理不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33447933/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com