CentOS9下Apache代理Lucee/Tomcat请求失败(503错误)求助
安装操作步骤
- 下载Lucee的.run安装包完成安装
- 保留apachectl、httpd配置及http模块默认设置(已确认配置正确)
- 将Tomcat设置为默认8888端口运行,可通过外部正常访问
- 安装过程中同意部署Apache连接器
- 安装过程中同意安装mod_cfml
安装阶段报错
安装后置步骤执行脚本时出现以下错误,但安装流程仍正常结束:
Error running /opt/lucee/sys/install_mod_proxy.sh -m install -t 8888 -f /etc/httpd/conf/httpd.conf -c /usr/sbin/apachectl: apachectl: The "-M" option is not supported. apachectl: The "-M" option is not supported.
当前系统状态
- Tomcat运行正常,可通过
domain.com:8888访问 - httpd.conf已添加代理规则:
<IfModule mod_proxy.c> ProxyPreserveHost On ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ http://127.0.0.1:8888/$1$2 ProxyPassMatch ^/(.+\.cfml)(/.*)?$ http://127.0.0.1:8888/$1$2 # optional mappings #ProxyPassMatch ^/flex2gateway/(.*)$ http://127.0.0.1:8888/flex2gateway/$1 #ProxyPassMatch ^/messagebroker/(.*)$ http://127.0.0.1:8888/messagebroker/$1 #ProxyPassMatch ^/flashservices/gateway(.*)$ http://127.0.0.1:8888/flashservices/gateway$1 #ProxyPassMatch ^/openamf/gateway/(.*)$ http://127.0.0.1:8888/openamf/gateway/$1 #ProxyPassMatch ^/rest/(.*)$ http://127.0.0.1:8888/rest/$1 ProxyPassReverse / http://127.0.0.1:8888/ </IfModule>
- httpd.conf已加载mod_cfml模块:
LoadModule modcfml_module modules/mod_cfml.so CFMLHandlers ".cfm .cfc .cfml" ModCFML_SharedKey "{{ shared_key_here }}" LogHeaders false LogHandlers false LogAliases false VDirHeader false
- 已重启Lucee和Apache服务,在
/var/www/html目录创建index.cfm文件,但访问时返回503错误:
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
- Tomcat的
catalina.out日志和Apache的error_logs未提供有效排查线索。
排查方向建议
检查Apache代理模块加载状态
CentOS 9的apachectl不支持-M参数,改用httpd -M命令查看已加载模块,确认mod_proxy、mod_proxy_http、mod_proxy_connect是否已加载。若未加载,需在httpd.conf中添加:LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so LoadModule proxy_connect_module modules/mod_proxy_connect.so添加后重启Apache服务。
验证本地代理连通性
在服务器上执行curl http://127.0.0.1:8888/index.cfm,确认Tomcat能否正常响应本地请求。若返回正常内容,说明问题出在Apache代理配置;若也返回错误,检查Tomcat虚拟主机配置是否正确映射到/var/www/html目录。确认mod_cfml兼容性
检查mod_cfml版本是否适配CentOS 9的Apache 2.4版本。若版本不兼容,尝试下载或编译适配Apache 2.4的mod_cfml模块替换现有文件。简化并调整代理配置
暂时注释ProxyPassReverse / http://127.0.0.1:8888/,仅保留核心ProxyPassMatch规则,重启Apache后测试访问。同时检查conf.d目录下的其他配置文件,确认是否存在冲突的代理设置。开启详细日志排查
在httpd.conf中添加LogLevel debug,重启Apache后重新访问,查看error_logs获取更详细的错误信息。同时检查Tomcat的localhost_access_log.*.txt,确认是否收到Apache转发的请求。
内容的提问来源于stack exchange,提问作者Miguel Pinto

