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

Apache2代理Tomcat负载均衡子路径失效:无有效协议处理器

Apache2代理Tomcat负载均衡时URL子路径无法正常工作:无有效协议处理器匹配该URL

问题现象

根URL https://www.myexample.com 可正常访问,但图片、JS/CSS等静态资源无法加载,例如:

  • https://www.myexample.com/images/logo.jpg
  • https://www.myexample.com/css/main.css

Apache错误日志输出:

AH01144: No protocol handler was valid for the URL /images/logo.jpg (scheme 'balancer'). If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule., referer: https://www.myexample.com:443/

当前使用的VirtualHost配置:

<VirtualHost *:443>    
        ServerName www.myexample.com      
        ProxyPreserveHost On

        SSLProxyEngine On
        SSLProxyCheckPeerCN on
        SSLProxyCheckPeerExpire on

        <Proxy "balancer://mycluster">
                BalancerMember "https://localhost:8443" route=node1
        </Proxy>

        ProxyPass        "/" "balancer://mycluster" stickysession=JSESSIONID|jsessionid scolonpathdelim=On
        ProxyPassReverse "/" "balancer://mycluster"

        ...
</VirtualHost>

已加载的Apache模块(执行sudo apachectl -M结果):

Loaded Modules:
 core_module (static)
 so_module (static)
 watchdog_module (static)
 http_module (static)
 log_config_module (static)
 logio_module (static)
 version_module (static)
 unixd_module (static)
 access_compat_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 filter_module (shared)
 lbmethod_byrequests_module (shared)
 mime_module (shared)
 mpm_event_module (shared)
 negotiation_module (shared)
 proxy_module (shared)
 proxy_balancer_module (shared)
 proxy_http_module (shared)
 reqtimeout_module (shared)
 setenvif_module (shared)
 slotmem_shm_module (shared)
 socache_shmcb_module (shared)
 ssl_module (shared)
 status_module (shared)

Apache版本信息:

Server version: Apache/2.4.41 (Ubuntu)
Server built:   2022-06-14T13:30:55

问题分析与解决方案

你已经加载了proxy_module、proxy_balancer_module、proxy_http_module等核心代理模块,但缺少proxy_ssl_module——这是导致问题的关键。

因为你的BalancerMember使用的是https://协议,Apache需要proxy_ssl_module来处理负载均衡器到后端HTTPS服务器的SSL通信,没有这个模块,Apache无法正确转发HTTPS请求,从而触发"无有效协议处理器"的错误。

修复步骤

  1. 启用proxy_ssl_module模块:
    sudo a2enmod proxy_ssl
    
  2. 重启Apache服务使配置生效:
    sudo systemctl restart apache2
    

完成上述操作后,静态资源的请求应该能被正确转发到Tomcat后端,解决加载失败的问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.17 12:25:30