Interesting Limitation with Apache 2 and mod_proxy_ajp

WebDevel.jpg

I was rebuilding a few machines today - web servers, that were using the mod_proxy_ajp now a part of Apache to forward the non-static requests to the co-resident Tomcat instance on the box. As a part of that set-up, we had a custom conf file that we loaded into /etc/httpd/conf.d/ to handle all the configuration of the web server. Well... 99% of it, but still - all the proxy forwarding and virtual hosting is in this one file.

The wrinkle came in with a Redirect line in the VirtualHost section of the file:

  <VirtualHost yummy>
      Redirect /index.html http://localhost:8888/yummy/app
      Redirect /UAT http://slushy.funstuff.com:8888/yummy/app
      ...
  </VirtualHost>

where the primary machine has a DNS entry for yummy and that's how most folks get to the web site. The UAT box is called slushy, and this way, the users can hit the URL http://yummy/UAT and get right to the UAT box. Pretty nice.

Or so I thought.

The problem with Apache and the mod_alias, it seems, is the use of localhost in the redirection of index.html to the local machine. When I try to hit it, I get that the web site is not available - like the URL doesn't point to the right sight.

But when I go directly to http://yummy:8888/yummy/app I see the web site - so I know it's there. Also, if I use wget to grab http://localhost:8888/yummy/app on that box, I get the initial page.

It's as if the Apache mod_alias or the mod_proxy_ajp are somehow not using the standard methods of name-to-IP resolution. For if I change the configuration to:

  <VirtualHost yummy>
      Redirect /index.html http://yummy.funstuff.com:8888/yummy/app
      Redirect /UAT http://slushy.funstuff.com:8888/yummy/app
      ...
  </VirtualHost>

Everything works. I looked at the Apache docs for the Redirect command, and it says it needs a fully qualified URL. I have given it that - and verified with wget that it's working. But something in there isn't working.

What this means is that we need to customize these configuration files for each machine so that they can properly redirect to the host it's on. Odd. Very odd. But it's a work-around for now. If this comes up again and again, I'll look into it to see what I might have to do, but very odd.