The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Goodbye Pound, Hello Nginx

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Robby Russell

Posts: 981
Nickname: matchboy
Registered: Apr, 2005

Robby Russell is the Founder & Executive Director PLANET ARGON, a Ruby on Rails development firm
Goodbye Pound, Hello Nginx Posted: Feb 1, 2007 1:35 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Robby Russell.
Original Post: Goodbye Pound, Hello Nginx
Feed Title: Robby on Rails
Feed URL: http://feeds.feedburner.com/RobbyOnRails
Feed Description: Ruby on Rails development, consulting, and hosting from the trenches...
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Robby Russell
Latest Posts From Robby on Rails

Advertisement

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.

Read: Goodbye Pound, Hello Nginx

Topic: Firebrigade: automated, sandboxed testing of RubyGems packages by other developers Previous Topic   Next Topic Topic: tinderbox version 1.0.0 has been released!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use