Is there a way to emulate Squid's redirector interface in reverse proxy

Eden Li eden at mojiti.com
Mon Apr 13 19:52:22 MSD 2009


It seems like this is exactly the same as X-Accel-Redirect:
http://wiki.nginx.org/NginxXSendfile

On Sun, Apr 12, 2009 at 6:14 PM, Yusuf Goolamabbas <yusufg at gmail.com> wrote:
> Somewhat bad responding to a very old post of mine
>
> Lighttpd's x-rewrite functionality is what fits the bill here
>
> http://blog.lighttpd.net/articles/2006/07/22/x-sendfiles-new-friend-x-rewrite
>
>
>
> On Mon, Jun 19, 2006 at 9:58 AM, Yusuf Goolamabbas <yusufg at gmail.com> wrote:
>> The functionality I'm looking for is for nginx to call an external
>> process passing it the entire URI on its stdin, the external process
>> returns a complete URI on its stdout which nginx then uses to proxy
>> to.
>>
>> e,g. nginx could send http://one.server.name/ to the external process
>> which could rewrite to to http://some.other.server.name/ and then
>> nginx would proxy the request to that server name. With the external
>> process approach, rewriting might be even done via db/memcached
>> lookups
>>
>> with the squid redirector API, squid starts up a number of external
>> process as specified in the config file and multiplexes URL rewrites
>> amongst it.
>>
>> I guess to some extent this might be similar to a fastcgi model in
>> terms of talking to an external process but instead of getting a
>> complete response back, nginx only has to expect a URI
>>
>>
>> On 6/16/06, Igor Sysoev <is at rambler-co.ru> wrote:
>>>
>>> On Fri, 16 Jun 2006, Aleksandar Lazic wrote:
>>>
>>> > On Fre 16.06.2006 14:09, Igor Sysoev wrote:
>>> >> On Fri, 16 Jun 2006, Yusuf Goolamabbas wrote:
>>> >>
>>> >>> Squid has a mechanism by which incoming URL's can be passed to an
>>> >>> external program to be rewritten and the reverse proxy subsequently
>>> >>> calls out to the rewritten URL
>>> >>>
>>> >>> http://wiki.squid-cache.org/SquidFaq/SquidRedirectors
>>> >>>
>>> >>> Is there a way to emulate this from within nginx
>>> >>
>>> >> No, nginx does not support such rewriting. What exact functionality do
>>> >> you
>>> >> need ?
>>> >
>>> > But how about with the perl-module?
>>>
>>> It's possible:
>>>
>>> ---------
>>> http {
>>>
>>>     perl_set  $new  '
>>>
>>>         sub {
>>>             my $r = shift;
>>>             my $uri = $r->uri;
>>>
>>>             return "/one/" if $uri =~ /1/;
>>>             return "/two/" if $uri =~ /2/;
>>>             return "/three/";
>>>         }
>>>
>>>     ';
>>>
>>>
>>>     server {
>>>         rewrite  ^  $new;
>>>
>>> ---------
>>>
>>> However, currently nginx could change URI only, it could not change
>>> the backend name.
>>>
>>>
>>> Igor Sysoev
>>> http://sysoev.ru/en/
>>>
>>>
>>
>
>





More information about the nginx mailing list