5

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.

11

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.

  • why would a trailing slash matter? – Geremia Mar 10 '17 at 21:00
  • @Geremia The trailing slash is necessary on the origin-URL because the proxied URL has a trailing slash. – Christopher Schultz Mar 16 '17 at 11:35
  • The slash is all I required. Is there a technical reason to quote the URL pattern and the balancer reference? – Chris Giddings Apr 16 '18 at 14:05
  • 1
    @ChrisGiddings I tend to quote everything that might possibly contain a space. I also tend to script lots of things, so it's very possible NOT quoting something won't be obvious when adding a space to a value that might end up in there. – Christopher Schultz Apr 17 '18 at 14:23
  • @ChristopherSchultz That's entirely reasonable. I also tend to script quite a bit, but I've never done so within a balancer reference. It just caught my attention. :) – Chris Giddings Apr 17 '18 at 15:46
2

In my case, I needed proxy_ajp module.

a2enmod proxy proxy_http proxy_ajp 
  • mod_proxy_ajp is certainly not necessary in order to proxy HTTP. – Christopher Schultz Mar 16 '17 at 11:35
  • Yes, I know my answer was not just exactly for this question. Though sometimes we have to come to these similar questions when we google with the same error message. I don't know stackoverflow allows it or not but I believe it helps some people and me. Sorry. @ChristopherSchultz – kujiy Mar 17 '17 at 12:57
  • 2
    @kujiy a2enmod proxy_http helped me with the same problem, thx :) – RTK Feb 7 '18 at 10:29
0

Same as kujiy i had to add the mod_ajp.

I am using apache4.

My log showed messages as follows:

No protocol handler was valid for the URL /jira. 
If you are using a DSO version of mod_proxy, 
make sure the proxy submodules are included in 
the configuration using LoadModule 

so I added ( I mean uncommented) the following line to my httpd.conf:

LoadModule proxy_ajp_module modules/mod_proxy_ajp.so 

saved, and the restarted the apache server.

  • 1
    A comment to kujiy's reponse could have sufficed , or an upvote... but alas my reputation ( or lack of it ... does not allow me to do that --- so thanks @kujiy – Yogesh Devi Jan 18 '17 at 16:41
  • Enabling mod_proxy_ajp is not useful for this particular application. You are answering a question which was not asked here. – Christopher Schultz Mar 16 '17 at 11:36
  • Your welcome @YogeshDevi. This is a problem about google and stackoverflow. If I and Devi make a new question and answer for proxy_ajp, it won't hit on google and this question will hit for the error message. – kujiy Mar 17 '17 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.