【发布时间】:2020-12-09 19:48:45
【问题描述】:
在将 Spring boot 的版本从 2.1.4 升级到 2.3.2 后,我的 apache2 无法再(通过 ajp)连接到 Spring boot 的嵌入式 tomcat。
它显示以下错误:
[proxy:error] [pid xxxx ] (111)Connection refused: AH00957: AJP: attempt to connect to 10.0.75.1:8500 (10.0.75.1) failed
[proxy_ajp:error] [pid xxxx ] [client xxx ] AH00896: failed to make connection to backend: 10.0.75.1, referer: http://myapp.develop/home/
我的开发环境是这样设置的:
-
一个 Angular 应用程序(运行在 4200 上的节点服务器)
-
一个 Spring Boot 后端(在端口 8500 上的 tomcat 上设置 ajp 连接器)
-
一个前端 apache2 服务器(在一个 docker 容器上)设置为将请求重定向到两个应用程序:
<VirtualHost *:80> ServerName myapp.develop ProxyPass "/home" "http://10.0.75.1:4200/home" ProxyPassReverse "/home" "http://10.0.75.1:4200/home" ProxyPass "/backend" "ajp://10.0.75.1:8500/backend" ProxyPassReverse "/backend" "ajp://10.0.75.1:8500/backend"
我通过 /etc/hosts 上的域名访问我的网络应用程序:myapp.develop
这是我的spring boot tomcat的配置
Connector connector = new Connector("AJP/1.3");
connector.setScheme("http");
connector.setPort(8500);
connector.setSecure(false);
connector.setAllowTrace(false);
((AbstractAjpProtocol) connector.getProtocolHandler()).setSecretRequired(false);
在 app.properties 中:
tomcat.ajp.port=8500
tomcat.ajp.remoteauthentication=false
tomcat.ajp.enabled=true
这是 tomcat 日志:
o.s.b.w.e.t.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 8500 (http)
o.a.c.h.Http11NioProtocol : Initializing ProtocolHandler ["http-nio-8080"]
o.a.c.a.AjpNioProtocol : Initializing ProtocolHandler ["ajp-nio-127.0.0.1-8500"]
o.a.c.c.StandardService : Starting service [Tomcat]
o.a.c.c.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.37]
我怀疑这种变化:
- 从 8.5.51 开始,AJP 连接器的默认侦听地址更改为环回地址,而不是所有地址。
是什么导致了我这个问题,但我不知道如何解决它。
【问题讨论】:
标签: spring-boot apache tomcat