directory based virtual host proxy.

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

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

For example:

These then need to be directed to the appropriate mongrel server.  My
current config below would work fine if I had, 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 {

#Rails App here
server {
    listen 80;
    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) {
        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;

    # 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: <>

More information about the nginx mailing list