apache 2.4 AJP代理无法正常工作

时间:2015-10-31 04:04:27

标签: apache tomcat url-rewriting proxy ajp

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

我使用了NameBased VirtualHost和AJP支持。配置文件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,从局域网访问Tomcat,一切正常。但是当我尝试通过Internet请求时,apache 2.4通过AJP调用Tomcat不能正常工作。

Tomcat从apache AJP接收到html request()但是从那时起,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/

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

欢迎任何建议或经验。

祝周末愉快!

1 个答案:

答案 0 :(得分:3)

不要在ProxyPass指令中更改上下文路径。当你这样做时,有许多方法可以用脚射击自己。

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

您有三种选择:

  1. 将您的应用程序重新部署为ROOT Web应用程序并使用
  2.   

    ProxyPass / ajp://127.0.0.1:8009 /

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

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

      1. 花费数天/周的时间尝试配置mod_sed或类似功能,以便动态编辑响应以更正链接。
      2. 我已经看到大型组织花费大量时间和金钱作为选项3而我真的不推荐它。