Browse the Ruby on Rails Community.

You are here: Browse Railsplugins Reverse Proxy Fix

Reverse Proxy Fix

=REVERSE PROXY PLUGIN Version 1.0.5.1 (March 25th, 2008)

===© 2006-2008 Brian Hogan

  1. #==Introduction
  2. This plugin is designed to allow your Rails application to reside behind a reverse proxy.
  3. When the plugin is configured and the application is running in production mode, any URLs generated
  4. by Rails helpers will automatically be prefixed with the host and path you specify. # #==Example Usage
  5. An organization may be interested in running a Rails application behind a reverse proxy such as Apache. However,
  6. any URLs generated by the Rails appliction would expose the proxy. #
  7. For example, a front-end server http://www.mydomain.com/app1/ might be mapped to http://backend.mydomain.com:3000/ #
  8. The plugin would be configured to prepend http://www.mydomain.com/app1 to all URLs generated by the application. # #==Usage and Configuration
  9. Install via Subversion using the Ruby script/plugin install command. In the root of your Rails application structure
  10. (where you can see the app/ vendor/ and public/ folders)
  11. execute the following command: #
  12. ruby script/plugin install http://svn.napcsweb.com/public/reverse_proxy_fix #
  13. You should be prompted to enter the base url of your front-end server when you install the plugin via script/plugin install. You
  14. should not include the trainling slash! For example:
  15. http://www.mydomain.com/typo #
  16. If that doesn’t work for some reason, you can run the install.rb script in vendor/plugins/reverse_proxy_fix. Or you can manually
  17. edit the file lib/config.rb and uncomment the BASE_URL line. (It should be the only line in the file. Enter the desired base url
  18. that you would like the plugin to prepend to any generated URLs. # #==Versions of Rails #
  19. This plugin supports Rails 1.x, Rails 1.2.x, and Rails 2.0 by using separate files for each Rails version
  20. During the installation you’ll need to tell the plugin which version to use. If this fails for some reason,
  21. simply rename the appropriate file to reverse_proxy_fix.rb
  22. * 116.rb (Rails 1.1.6 or below)
  23. * 123.rb (Rails 1.2.X)
  24. * 20.rb (Rails 2.X) #
  25. Then start your application in Production mode. The plugin is automatically disabled when you run in development mode, so you don’t
  26. need to do any special configurations to develop your application. #
  27. That’s it! #
  28. Limitations #
  29. First, asset hosts are disabled and overruled by this plugin. Your asset host base URL is set to the base url you specify. Modify the plugin to change this behavior. I am open to patches for this. #
  30. Second, in order to get named routes working in Rails 2.0 I took the shortcut and disabled route optimization. #
  31. Revisions #
  32. Version 1.0.5.1
  33. * Updated the readme version and fixed the installation script so it worked for platforms other than Windows (Thanks to Brian Candler for catching this and supplying a patch) #
  34. Version 1.0.5
  35. * Fixed the issue that prevented named routes from not working in Rails 2.0 by disabling named route optimization. #
  36. Version 1.0.4.1
  37. * Fixed the installer script to properly select Rails version. (Joshua Miller) #
  38. Version 1.0.4.0
  39. * Added support for Rails 2.0 – needs more testing #
  40. Version 1.0.3.2
  41. * Unified installer for all Rails versions again. #
  42. Version 1.0.3.1
  43. * Fixed an issue when using RESTful routing – plugin should no longer activate in dev mode. #
  44. Version 1.0.3
  45. * Added a rake task to configure the plugin
  46. * fixed a situation where the installer didn’t work in Rails 1.2.3
  47. * fixed a problem with request.request_uri not setting the base path.
  48. * Overloaded routing mechanism to avoid collisions with the modified request.request_uri
  49. * Tested with acts_as_authenticated #
  50. Version 1.0.2
  51. * Fixed issue where page caching does not work. The URL rewriting can now be turned off by sending t => true to any calls to url_for or link_to. (This is the method that caching uses to build the cached urls) #
  52. Version 1.0.1
  53. * Small bug fix to allow :only_path => false to work correctly when called on link_to and url_for #
  54. Version 1.0
  55. * Initial Release # #==License
  56. Copyright © 2006-2007 Brian Hogan
  57. Permission is hereby granted, free of charge, to any person obtaining
  58. a copy of this software and associated documentation files (the
  59. “Software”), to deal in the Software without restriction, including
  60. without limitation the rights to use, copy, modify, merge, publish,
  61. distribute, sublicense, and/or sell copies of the Software, and to
  62. permit persons to whom the Software is furnished to do so, subject to
  63. the following conditions: #
  64. The above copyright notice and this permission notice shall be
  65. included in all copies or substantial portions of the Software. #
  66. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
  67. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  68. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  69. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  70. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  71. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  72. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

NOTE: This description has been extracted from the Plugin README and so the formatting may need updating to make browser friendly


Homepage: http://www.napcsweb.com/blog/2006/05/10/reverse-proxy-fix-plugin/