directory based virtual host proxy.

Brandon Hoult bhoult at gmail.com
Sat Feb 23 00:04:53 MSK 2008


I figured this out... you have to use the prefix option for mongrel which
can be called on the command line of included in the .yaml file in
/etc/mongrel (if you have it configured that way)

See: http://mongrel.rubyforge.org/wiki/FAQ

On Fri, Feb 22, 2008 at 11:44 AM, Brandon Hoult <bhoult at gmail.com> wrote:

> I posted the below earlier, but nobody has replied.  I think I found the
> solution to part of my problem but my solution introduces a new issue.
>
> I added the following directive to pass
> http://my.domain.com/user_management/ to the correct mongrel cluster.
>
> location /user_management_dev/ {
>         root /var/www/rails/user_management/current/;
>         rewrite /user_management_dev(.*) $1;
>         proxy_pass http://user_management_prod;
>         break;
> }
>
> The problem is that now the application sees it's url as being
> http://my.domain.com so all the links inside the rails application don't
> go anywhere.  Is there a way to tell the proxied application that it needs
> to add "/user_management" to the end of it's host name?
>
> -----------------------------------
>
>
> On Thu, Feb 21, 2008 at 5:18 PM, Brandon Hoult <bhoult at gmail.com> wrote:
>
> > 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/20080222/c5f53b88/attachment.html>


More information about the nginx mailing list