Read my latest article: 8 things I look for in a Ruby on Rails app (posted Thu, 06 Jul 2017 17:59:00 GMT)

Goodbye Pound, Hello Nginx

Posted by Thu, 01 Feb 2007 19:48:00 GMT

I’ve been using pound for several months and it’s been a good relationship. Except, for some strange reason, I noticed that I was getting development mode errors when it was running in production mode. I thought there might be an issue with my mongrel cluster… but that wasn’t the case.

Let me give you a little background to how we’re encouraging customers to handle their deployment on PLANET ARGON.

Most of our hosting customers1 have three tiers (unless you have your own static IP address), one which we manage, two that you manage.

We handle the main web server/proxy server and proxy to your desired load balancer/proxy/server, which is generally any of the following options… depending on your preference.

Each customer has a unique proxy server port and a range of other ports for their mongrel clusters.

So… the typical setup is…

Apache(external:80) [proxies to]==> Pound(localhost:8050) [proxies to]==> Mongrel::Cluster(localhost:10500-10503)

Well, when a request comes in through Apache, it gets passed off to Pound and each tier has it’s own headers. By the time that it reaches Mongrel, all the requests appear to be coming from localhost.. not the remote address of the person using your application. Notice nothing but localhost requests in your production.log? ...this is the reason.

So, what side-effects does this have? Well, aside from every request looking local… Rails will, by default, output a normal development-mode error message if the request is coming from localhost.


    # found in...
    # actionpack/lib/action_controller/rescure.rb

    # Exception handler called when the performance of an action raises an exception.
    def rescue_action(exception)
      log_error(exception) if logger
      erase_results if performed?

      if consider_all_requests_local || local_request?
        rescue_action_locally(exception)
      else
        rescue_action_in_public(exception)
      end
    end

It seems that this currently causes the exception notification plugin, which we often use, to not work. We noticed this in a staging environment for an application that we’re building for a client about a month ago. After debugging SMTP servers, mongrel configuration… I was baffled.

Nginx to the rescue

After some investigation and attempts to find a workaround in Pound, I decided to redeploy my blog with Nginx. This was a pretty painless process and I was able to use the example posted on the PLANET ARGON Documentation Project.

Nginx allows you to do the following to overwrite the headers being passed to Mongrel.


    proxy_set_header  X-Real-IP  $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;

Problem Solved!

If there is a workaround for this in Pound, I’d love to be able to relay this information to our customers that haven’t made the switch yet.

Thank you, Brian and Timothy for encouraging me to finally switch my blog to Nginx. ;-)

If you have questions related to deploying Rails applications, be sure to check out the Rails Deployment google group.

1 For more information about our hosting, visit http://planetargon.com/hosting.html.

Apache, Typo, and Feedburner

Posted by Fri, 08 Sep 2006 21:51:00 GMT

A few weeks ago, I started using FeedBurner and posted a blog entry about how I configured Lighttpd to handle that so it didn’t disrupt everyone that subscribes to my RSS feed. This was working great… until the other day.. when I upgraded to Typo trunk. When I did this, I decided to start using mongrel::cluster and pound. Two days later… I’m noticing that my subscriber count has dropped over thousand people in a day… was it something that I said?

A ha! I was handling the redirect with Lighttpd and had replaced it with Pound.

So, I am now delegating this to Apache.

  # Redirect typo feeds to FeedBurner
  RewriteCond %{HTTP_USER_AGENT} !^FeedBurner.*$
  RewriteRule /xml/(atom|rss|rss20)/feed.xml$ http://feeds.feedburner.com/RobbyOnRails [R=temp,L]

...and all was well again.

UPDATE

The rewrite condition should be !^FeedBurner.*$ not !^FeedBurner$.

Rails and Mongrel go to the Pound

Posted by Wed, 09 Aug 2006 00:35:00 GMT

2 comments Latest by Robby Russell Wed, 09 Aug 2006 02:31:13 GMT

We’ve been encouraging our Rails hosting customers to give Pound and Mongrel a try for deploying their Ruby on Rails applications. David Gibbons has been adding some recipes for doing this on the PLANET ARGON Documentation Project

Check out:

...and today David posted an article on his blog titled, Why you need multiple mongrel instances with rails!