Reverse Proxy Fix plugin

Posted by Brian in Products, Rails (May 10th, 2006)

Updated March 16th, 2009:
This plugin now supports Rails 2.3, 2.2, 2.1, 2.0, 1.2x, and 1.1.

I’ve been working for the last few months on methods to place Rails applications behind Microsoft’s IIS web server. It’s not the easiest thing to do. One of the biggest hurdles is the fact that when Rails generates URLs with the built-in methods like link_to and url_for, they could end up exposing the internal URLs instead of the ones you want your users to go through.

I’ve developed a plugin that will handle the rewriting for you. All you have to do is install the plugin, provide the appropriate base URL to the config file, select the version of Rails you’re using, and then launch your application in production mode.

ruby script\plugin install

Documentation is available online at

21 Responses to ' Reverse Proxy Fix plugin '

Subscribe to comments with RSS or TrackBack to ' Reverse Proxy Fix plugin '.

  1. DGM said,
    on May 11th, 2006 at 8:49 am

    This really needs to go into the core. I hope the core rails team looks at it.

  2. Scott Burton said,
    on July 9th, 2006 at 8:27 pm

    Actually the correct command to run is ruby script/plugin install

    The code above will launch webrick :)

  3. Brian said,
    on September 7th, 2006 at 7:25 pm


  4. Bart Braem said,
    on September 23rd, 2006 at 8:58 am

    I wonder, how is this different from setting relative_url_root?

  5. Brian said,
    on September 25th, 2006 at 1:01 pm


    I used relative_uri_root originally and discovered that it left a few things out. It’s been so long that I cannot remember exactly what the issues were. Thanks for giving me something to revisit.

  6. Detlef Werner said,
    on October 17th, 2006 at 10:18 pm

    we tried this plugin, however only with partial success. While stylesheets via stylesheet_link_tag in layout are corrected, the normal link_to in views remains uncorrected. Is link_to not supported?

  7. Brian said,
    on November 13th, 2006 at 6:12 am


    Not sure how you installed it, but all methods that use url_for are supported by this plugin. That includes link_to, link_to_unless_current, and others. However, you have to use the url_for method of constructing your links.

    link_to “something”, :controller =>”foo”, :action=>”bar”, :id=>”1″ will work.

    link_to “something”, “/foo/bar” probably will not.

  8. Eric Young said,
    on March 7th, 2008 at 1:42 am

    I’ve just been playing with remapping redmine and a couple of the named routes,
    map.signin ‘login’, :controller => ‘account’, :action => ‘login’
    map.signout ‘logout’, :controller => ‘account’, :action => ‘logout’
    are not being remapped by reverse_proxy_fix. Everything else seems to work fine, just the named routes do not. Any ideas? I’m on rails 2.0 I believe.

  9. Brian said,
    on March 7th, 2008 at 4:10 pm


    You are correct. Name routing doesn’t work with Reverse Proxy Fix in Rails 2.0 because they don’t make named routes go through the same process. I have a fix and will get it out to the repository tonight.

    Thanks for pointing this out.

  10. Stefano Palma said,
    on September 8th, 2008 at 4:18 am

    I’ve installed your fix for Rails 2.0, but I’m using Rails 2.1 and it seems it doesn’t work. Any suggestions?

  11. Stefano Palma said,
    on September 9th, 2008 at 6:15 am

    I’ve installed your fix for Rails 2.0, but I’m using Rails 2.1 and it seems it doesn’t work. Any suggestions?

  12. Hatem said,
    on September 16th, 2008 at 12:23 am

    Hi, I have a question about Ruby on Rails sessions.

    I’m planning to use a reverse proxy on production. When I use Firebug to watch the response headers, I see that a header of “Set-Cookie” is set with the same session id on every request.

    Now, with every request from the same user, the reverse proxy will always think it is a new session and hence prevent caching and affect the performance.

    Can you help me to fix this?
    Thank you.

  13. Brian said,
    on September 29th, 2008 at 11:12 am

    I’d need to know more about your situation. Hit up the support form on the site (under “contact and support”) and give me some more details. I have about 10 Rails 2.1 sites that are using the plugin without issue.

  14. Dmitry said,
    on November 26th, 2008 at 12:35 am

    On Windows XP, ruby-1.86.26:
    c:\myApp> ruby script/plugin install
    Plugin not found: [“”]
    I use direct internet connection, there is no firewall. “” can be opened in my brouser.

  15. Brian said,
    on November 26th, 2008 at 8:32 am


    I just tested it and it seemed to work without issue. What version of Rails are you using?

  16. AHE said,
    on March 12th, 2009 at 3:36 pm

    It seems that you have to replace AbstractRequest by Request in the source code of the plugin if you are using Rails 2.3

  17. Brian said,
    on March 16th, 2009 at 8:12 am


    Yup, just waiting for the final release of Rails 2.3. If you grab the plugin today it will now give a fourth installation option

  18. JEVE said,
    on April 1st, 2009 at 5:15 am

    Hi, do you know if the server is available right now? We have been trying to install this plugin for two days but it keeps saying Plugin not found :???:
    Is there an alternate source to download it?
    Thanks in advance.

  19. Cédric said,
    on April 8th, 2009 at 12:08 am

    The repos is down

  20. Stephane said,
    on April 8th, 2009 at 12:31 am

    Your is down. Is there another way I can download this?

  21. Brian said,
    on April 11th, 2009 at 3:02 pm

    We had some DNS issues apparently and we managed to get them worked out. I hope everyone is able to get the files they need now. Thanks for the feedback.

Leave a reply

:mrgreen: :neutral: :twisted: :shock: :smile: :???: :cool: :evil: :grin: :oops: :razz: :roll: :wink: :cry: :eek: :lol: :mad: :sad: