Browse files

Add documentation for using Rails with a reverse proxy

  • Loading branch information...
1 parent 3acf287 commit a3b297f6480c84da495fd79e939ae6c8441ff205 @zzak zzak committed with zzak Feb 9, 2014
Showing with 38 additions and 4 deletions.
  1. +38 −4 guides/source/
@@ -729,13 +729,47 @@ Rails will now prepend "/app1" when generating links.
#### Using Passenger
-Passenger makes it easy to run your application in a subdirectory. You can find
-the relevant configuration in the
-[passenger manual](
+Passenger makes it easy to run your application in a subdirectory. You can find the relevant configuration in the [passenger manual](
#### Using a Reverse Proxy
+Deploying your application using a reverse proxy has definite advantages over traditional deploys. They allow you to have more control over your server by layering the components required by your application.
+Many modern web servers can be used as a proxy server to balance third-party elements such as caching servers or application servers.
+One such application server you can use is [Unicorn]( to run behind a reverse proxy.
+In this case, you would need to configure the proxy server (nginx, apache, etc) to accept connections from your application server (Unicorn). By default Unicorn will listen for TCP connections on port 8080, but you can change the port or configure it to use sockets instead.
+You can find more information in the [Unicorn readme]( and understand the [philosophy]( behind it.
+Once you've configured the application server, you must proxy requests to it by configuring your web server appropriately. For example your nginx config may include:
+upstream application_server {
+ server
+server {
+ listen 80;
+ server_name localhost;
+ root /root/path/to/your_app/public;
+ try_files $uri/index.html $uri.html @app;
+ location @app {
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header Host $http_host;
+ proxy_redirect off;
+ proxy_pass http://application_server;
+ }
+ # some other configuration
+Be sure to read the [nginx documentation]( for the most up-to-date information.
#### Considerations when deploying to a subdirectory

0 comments on commit a3b297f

Please sign in to comment.