Devise Proxy
devise-proxy is a standalone Rack Middleware application that authenticates a username/password against a devise-powered backend application before forwarding the original HTTP request to a single host of your choosing.
Authentication is done on every request, so it is advisable to use devise-proxy sparingly.
devise-proxy will return a 502 if a network connection to your authentication host cannot be established.
Quick Start
- Create a devise-proxy.yml using the provided .sample.
- Start the proxy server: > rackup config.ru
- Configure you web browser or other client software to use the proxy and set a username (email) and password.
- Enjoy!
Example Configuration
You'll need a config/devise-proxy.yml file to start the application. For example:
authentication:
hostname: localhost
port: 3000
forwarding:
hostname: localhost
port: 3000
Example Deployment on Linux
There is a sample init script in extra/. This script will start the proxy as a daemon on port 6969 as a given user ("tater" in our example). Edit for your environment. Note that you may need to edit the "exec" path. In the sample it points to an rvm wrapper script created using the following command: "rvm wrapper ruby-1.9.3 bootup rackup".
Troubleshooting
Infinite Client Redirects
If your client complains about infinite redirects, you're probably forwarding traffic to a hostname that returns a 302. This may be the case if you request example.com, but the server redirects you to www.example.com. When this occurs, the client will receive the 302 with the preferred hostname try again with a new URL. Since the proxy tosses out the hostname portion of the URL and replaces it with whatever's in the config file, however, the proxy will forward to the same bad hostname, get another 302, and return it to the client, introducing an infinite loop that the browser should eventually catch and stop. This shouldn't be a big deal if you're forwarding to your own well-behaved devise app, but is worth mentioning.
Authors
Preston Lee