apache 2.4 AJP 代理不工作
apache 2.4 AJP proxy not working
我正在尝试配置我的 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 request () 但从那时起,每个包含 css、javascript 和 html 中的图像与错误请求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 -
我试图从 google 那里寻求帮助并尝试使用
RedirectMatch /StorageWayServer http://www.storageway.com.au/
但我从来没有从请求中删除额外的应用程序上下文 url。
欢迎任何建议或经验。
祝周末愉快!
不要更改 ProxyPass 指令中的上下文路径。当你这样做的时候,有很多很多方法会搬起石头砸自己的脚。
据推测,您网页上的链接是绝对链接,因此它们包含上下文路径。当客户端随后请求这些时,ProxyPass 指令再次添加上下文路径。
你有三个选择:
- 将您的应用程序重新部署为 ROOT 网络应用程序并使用
ProxyPass / ajp://127.0.0.1:8009/
- 使用上下文路径访问您的应用程序并使用
ProxyPass /StorageWayServer/ ajp://127.0.0.1:8009/StorageWayServer/
- 花几天/几周的时间尝试配置 mod_sed 或类似的方法来即时编辑响应以更正链接。
我见过大型组织花费大量时间和金钱选择选项 3,我真的不推荐它。
我正在尝试配置我的 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 request () 但从那时起,每个包含 css、javascript 和 html 中的图像与错误请求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 -
我试图从 google 那里寻求帮助并尝试使用
RedirectMatch /StorageWayServer http://www.storageway.com.au/
但我从来没有从请求中删除额外的应用程序上下文 url。
欢迎任何建议或经验。
祝周末愉快!
不要更改 ProxyPass 指令中的上下文路径。当你这样做的时候,有很多很多方法会搬起石头砸自己的脚。
据推测,您网页上的链接是绝对链接,因此它们包含上下文路径。当客户端随后请求这些时,ProxyPass 指令再次添加上下文路径。
你有三个选择:
- 将您的应用程序重新部署为 ROOT 网络应用程序并使用
ProxyPass / ajp://127.0.0.1:8009/
- 使用上下文路径访问您的应用程序并使用
ProxyPass /StorageWayServer/ ajp://127.0.0.1:8009/StorageWayServer/
- 花几天/几周的时间尝试配置 mod_sed 或类似的方法来即时编辑响应以更正链接。
我见过大型组织花费大量时间和金钱选择选项 3,我真的不推荐它。