Hosting Software News & Commentary Hosting Software News & Commentary Hosting Software News & Commentary

Well, finally switched to Mongrel cluster behind Apache 2.2 with mod_proxy_balancer. Let me tell you, it was extremely simple….until I got to a problem that apparently no one else has ever had. At least, if the documentation and google are to be believed.

After getting Mongrel cluster up and running, then proxying traffic to it through my Apache server, all of my IP logging scripts were receiving IP addresses of 127.0.0.1. Some of them were using which apparently will always be set to the IP of the proxy server. No big deal and a simple fix. Replace with request.remote_ip.

Except, it didn’t work. I was still getting the loopback IP. The proxy was setting properly, but remote_ip was not reading it for some reason. I found some blog posts from a user who found that if the HTTP_X_FORWARDED_FOR was set to an internal IP, remote_ip would ignore it. However, that wasn’t the case here. All the forwarded IP’s were public addresses. No matter what I did, remote_ip refused to work. Apparently in the FreeBSD port of Rails 1.2.6, remote_ip is somehow broken. Yay.

So, I did a cheap hack. My application controller now has a before_filter that executes the following code:

if request.remote_ip != nil and != nil
end

Voila! IP logging works once more!

  1. No user reviews yet.


Leave a Reply





Blogroll