Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added documentation for Rails 3 #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ Matchers can be a regex or a string. If a regex is used, you can use the subcap

Right now if more than one matcher matches any given route, it throws an exception for an ambiguous match. This will probably change later. If no match is found, the call is forwarded to your application.

=== Configuring for a Rack app
Below is an example for configuring the middleware:

require 'rack/reverse_proxy'
@@ -34,6 +35,36 @@ Below is an example for configuring the middleware:
end
run app

=== Configuring for Rails 3
In your application.rb add the middleware configuration as below:

module MyApp
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.

# ...

# add reverse-proxy middleware
# reverse proxy middle ware
require 'rack/reverse_proxy'

config.middleware.use Rack::ReverseProxy do
# Set :preserve_host to true globally (default is true already)
reverse_proxy_options :preserve_host => true

# Forward the path /test* to http://example.com/test*
reverse_proxy '/test', 'http://example.com/'

# Forward the path /foo/* to http://example.com/bar/*
reverse_proxy /^\/foo(\/.*)$/, 'http://example.com/bar$1', :username => 'name', :password => 'basic_auth_secret'
end

end
end

=== Options
reverse_proxy_options sets global options for all reverse proxies. Available options are:
* :preserve_host Set to false to omit Host headers
* :username username for basic auth