Dave Hayes
August 07, 2011 11:58PM
Alexandr Gomoliako <zzz@zzz.org.ua> writes:
> On 8/8/11, Dave Hayes <dave@jetcafe.org> wrote:
>> Greetings nginx gurus. :) Is there a better way to generate a redirect
>> to a named location than this?
>> location ~ \.pl$ {
>> try_files /this_should_never_exist @perl;
>> }
> Another way is to use error_page in conjunction with return.
> But in this case you should just replace try_files with your named
> location's config.

If I have several location blocks in a server block, and I want to use
just one location block that has my fastcgi definitions for perl (hence
@perl), are you recommending I just duplicate all the configuration
in each location block that needs to redirect to perl?

Saying this another way, by example:

location @perl {
# 20 lines of fast cgi defs
}

location /realm_a {
auth_basic "realm_a";
location ~ \.pl$ {
try_files /does_not_exist @perl;
}
}

location /realm_b {
auth_basic "realm_b";
location ~ \.pl$ {
try_files /does_not_exist @perl;
}
}

location /realm_c {
auth_basic "realm_c";
location ~ \.pl$ {
try_files /does_not_exist @perl;
}
}

Your recommendation is to do this:

location /realm_a {
auth_basic "realm_a";
location ~ \.pl$ {
# 20 lines of fast cgi defs
}
}

location /realm_b {
auth_basic "realm_b";
location ~ \.pl$ {
# 20 lines of fast cgi defs
}
}

location /realm_c {
auth_basic "realm_c";
location ~ \.pl$ {
# 20 lines of fast cgi defs
}
}

Did I get that right? :)
--
Dave Hayes - Consultant - Altadena CA, USA - dave@jetcafe.org
>>> The opinions expressed above are entirely my own <<<

A "No" uttered from deepest conviction is better and greater
than a "Yes" merely uttered to please, or what is worse, to
avoid trouble. -- Mahatma Ghandi


_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Generating redirects to internal named locations

Dave Hayes August 07, 2011 05:20PM

Re: Generating redirects to internal named locations

Alexandr Gomoliako August 07, 2011 06:08PM

Re: Generating redirects to internal named locations

Dave Hayes August 07, 2011 11:58PM

Re: Generating redirects to internal named locations

Alexandr Gomoliako August 08, 2011 12:36PM

Re: Generating redirects to internal named locations

Dave Hayes August 10, 2011 02:30AM

Re: Generating redirects to internal named locations

Paul Findlay August 10, 2011 07:14AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 264
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready