Home > Enterprise >  Apache2 proxy tomcat load balancing URL sub-path not working: No protocol handler was valid for the
Apache2 proxy tomcat load balancing URL sub-path not working: No protocol handler was valid for the

Time:10-20

Apache2 tomcat load balancing URL sub-path not working. No protocol handler was valid for the URL.

 <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>

The root URL

 https://www.myexample.com

Works. But resources such as image, js/css could not be loaded. e.g.,

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

Apache error log:

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/

Apache modules loaded

$ 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)

Any other apache modules needed?

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

CodePudding user response:

you should add a "/" at the end of proxy rules:

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

without it the resulting url for:

https://www.myexample.com/images/logo.jpg

is:

balancer://myclusterimages/logo.jpg

so it doesn't find any load balancing rules that match it.

  • Related