Getting the URLs right when proxying to apache and mongrel

Maxim Dounin mdounin at
Sun Sep 2 23:15:30 MSD 2007


On Sun, 2 Sep 2007, Igor Sysoev wrote:

>> 2. The url required to access the rails app fails without the trailing
>> slash. So,
>>   http://mote/rails/
>> works, but the following doesn't
>>   http://mote/rails
> In your configuration, proxied request is "GET  HTTP/1.0".
> What request should go to mongrel for /rails ?

I suppose apropriate change would be

-         location ^~ /rails {
+         location ^~ /rails/ {

BTW, Igor, what about documenting ngx_http_core_loc_conf_t's 
auto_redirect? And probably making it configurable for non-proxied 

Background: I've recently re-wrote by home site conf, and was a bit 
surprised that

     location /blah/ {
         proxy_pass ...;

just works as expected - i.e. produces 301 moved for /blah requests even 
without coresponding directory under document root, while

     location /blah/ {
         rewrite ...;

doesn't. So I was forced to wrote something like this

     location = /mail {
         rewrite ^(.*) https://$server_name$1 redirect;
     location /mail/ {
         rewrite ^(.*) https://$server_name$1 redirect;

just to redirect everything under /mail/ to https.

Maxim Dounin

More information about the nginx mailing list