Help, I need write a nginx module

Igor Sysoev is at rambler-co.ru
Fri Sep 25 12:46:51 MSD 2009


On Fri, Sep 25, 2009 at 02:35:37AM -0400, fuji246 wrote:

> I need to write a nginx module to enhance the performance of our service.The following is what our service doing, 
> 
>     1. When getting the http request from the client,  our service send http request to another server to validate the identification of the client.
> 
>     2. If the validation passed, then send http request to another server to get the metainfo of the file requested by the client.
> 
>     3. If the metainfo is retrieved,  use the metainfo to pull file data from backend stroage using http GET.
> 
>     I've read the guide of nginx module developement, but that's not enough, these days, I've been reading the code of nginx. It's a hard job, i confess.
>     I think, I should write a handler module, and using upstream to interact with other services, as far as i know , upstream send the response directly to the client,  the only thing I can do is defining an "input_filter" of upstream, I'm wondering whether "input_filter" can be used to initiate another upstream request.

It's not easy task.
However, you may try to use X-Accel-Redirect:

    location / {
        proxy_pass   http://auth;
        # it returns "X-Accel-Redirect: /meta/..." for valid users
    }

    location /meta/ {
        proxy_pass   http://meta;
        # it returns "X-Accel-Redirect: /storage/..."
    }

    location /storage/ {
        proxy_pass   http://storage;
    }


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list