directory based virtual host proxy.

Brandon Hoult bhoult at gmail.com
Fri Feb 22 02:18:11 MSK 2008


I would like to have several rails applications behind the same domain name.

For example:
my.domain.com/application_1
my.domain.com/application_2
my.domain.com/application_3

These then need to be directed to the appropriate mongrel server.  My
current config below would work fine if I had application1.domain.com,
application2.domain.com etc.  But I can't seem to find an example of how to
use the same domain with different apps.

Any hints would be appreciated.

My curent config:
-------------------------------------------------------------------------------
upstream rails {
   server 127.0.0.1:8050;
   server 127.0.0.1:8051;
}

#Rails App here
server {
    listen 80;
    server_name rails.softwyre.com;
    root /var/www/rails/user_management/current/;
    index index.html index.htm;
    client_max_body_size 50M;

    access_log  /var/log/nginx/localhost.access.log;

    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded_for $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect false;
    proxy_max_temp_file_size 0;

    location / {
        if (-f $request_filename) {
           break;
        }
        if (-f $request_filename/index.html) {
           rewrite (.*) $1/index.html break;
        }
        if (-f $request_filename.html) {
           rewrite (.*) $1.html break;
        }
        if (!-f $request_filename) {
           proxy_pass http://rails;
           break;
        }
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /500.html;
    location = /500.html {
        root  /var/www/rails/user_management/current/public;
    }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20080221/84fc78de/attachment.html>


More information about the nginx mailing list