“No protocol handler valid for the URL” with httpd mod_proxy_balancer

apache-2.4mod-proxyreverse-proxy

I'm trying to set up failover for a reverse-proxied server with a localhost static copy of resources that would usually be served by a content management system. I've used wget to grab a static copy of the dynamic site for failover purposes.

I've tried to use a configuration similar to Fall-back location for Apache's ProxyPass directive? to get things started, and it's a fairly straightforward, but I'm getting the error in the title.

Here's my (sanitized) proxy configuration:

DocumentRoot /var/www/www.example.com/htdocs

ProxyRequests Off
ProxyPreserveHost On

ProxyPass "/site/" "balancer://cms"
ProxyPassReverse "/site/" "balancer://cms"
ProxyPassReverse "/site/" "http://ip-10-1-1-229.ec2.internal/site/"

<Proxy "balancer://cms">
    #BalancerMember "http://ip-10-1-1-229.ec2.internal/site/" loadfactor=1
    # For localhost services, a backup of the CMS's site
    BalancerMember "http://127.0.0.1/site-backup/www.example.com/site/" loadfactor=10 status=+H
</Proxy>

<Directory "/var/www/www.example.com/htdocs/site-backup">
  Order allow,deny
  Allow from all

  Options Indexes FollowSymlinks
  DirectoryIndex index.html
</Directory>

(Here, I've commented-out the balancer member that goes to the real CMS system — that part is working just fine — so that I can test the local, static copy.)

There is an index.html file in /var/www/www.example.com/site-backup/www.example.com/ and it does get loaded when I try to hit http://www.example.com/site/, but none of the page's other resources (CSS, images, etc.) get loaded. They have URLs in the page like:

I have a file, foo.png at this location:

/var/www/www.example.com/htdocs/site-backup/www.example.com/site/sites/default/files/foo.png

But when that image is loaded by the browser, I get a 500 Internal Server Error response and I see this in httpd's error log:

[proxy:warn] [pid 3182:tid 2838395712] [client 71.127.40.115:38208] AH01144: No protocol handler was valid for the URL /site/site/sites/default/files/foo.png. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule., referer: http://test.example.com/site/

I noticed that the URL shown in the error message has an extra /site/ in the URL, so I figured it was getting doubled because I'm trying to serve a URL space including /site/ from a directory containing /site/ and wget is probably not perfect right now, so I created a symlink from /var/www/www.example.com/site-backups/www.example.com/site/site/sites -> /var/www.www.example.com/site-backups/www.example.com/site/sites. That ought to have fixed any foolishness due to URL confusion.

But that didn't seem to fix anything; mod_proxy is still complaining about the protocol. mod_proxy_http is definitely enabled, as the normal ProxyPass directive to the CMS is working as expected (when enabled).

I'm sure this is a fairly simple thing I'm missing, but I can't seem to figure it out. Any help would be greatly appreciated.

Best Answer

facepalm

It turns out that I was missing a trailing slash on my ProxyPass directive:

ProxyPass "/site/" "balancer://cms"

should have been:

ProxyPass "/site/" "balancer://cms/"

(Note the trailing slash before the close-quote.)

That literally fixed everything.

I'm happy to delete this question and answer if folks want to close it as "simple typographical error", but I'll leave it for now. If I get some up votes on this answer, I'll remove this note and consider it a public service for anyone who might make the same mistake.