You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用mod_proxy与mod_proxy_ajp时Apache和Tomcat出现503服务不可用错误

问题:AJP反向代理返回503服务不可用,HTTP代理正常

在Apache的000-default.conf中配置反向代理后,/cars应用(基于HTTP协议)可正常访问,但使用AJP协议的/supercars应用返回503服务不可用错误。


相关配置文件

1. 000-default.conf 配置

<VirtualHost *:80>
   ServerAdmin webmaster@localhost
   DocumentRoot /var/www/html

   ErrorLog ${APACHE_LOG_DIR}/error.log
   CustomLog ${APACHE_LOG_DIR}/access.log combined

   ProxyPass        /cars http://localhost:8080/cars  
   ProxyPassReverse /cars http://localhost:8080/cars  
   <Location /cars>
        Require all granted
   </Location>

   ProxyPass        /supercars ajp://localhost:8009/supercars/
   ProxyPassReverse /supercars ajp://localhost:8009/supercars/

   <Location /supercars>
         Require all granted
   </Location>

</VirtualHost>

2. Tomcat server.xml 配置

<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000" 
               URIEncoding="UTF-8" redirectPort="8443" 
               proxyPort ="80" />

    <Connector port="8009"
               protocol="AJP/1.3" 
               redirectPort="8443"
               address="172.10.10.1" 
               secretRequired="false"
    />

3. proxy.conf 配置

ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
     AddDefaultCharset off
     Require all granted
</Proxy>

错误提示

Service Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Apache/2.4.57 (Debian) Server at 172.10.10.1 Port 80


已尝试的无效操作

  • 在Apache的ports.conf中开放8009端口
  • 创建端口为8009的虚拟主机

解决方法

将AJP端口从8009更换为8010,修改以下两处配置后重启Apache和Tomcat:

  1. 000-default.conf中的AJP代理地址改为 ajp://localhost:8010/supercars/
  2. Tomcat server.xml中的AJP Connector端口改为 8010

修改完成后,/supercars应用可正常访问。

内容的提问来源于stack exchange,提问作者SebitoNoobie

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 02:25:10