How to leverage HTTP upstream features

Maxim Dounin mdounin at mdounin.ru
Wed Jul 6 12:33:53 UTC 2016


Hello!

On Tue, Jul 05, 2016 at 05:00:03PM -0400, Charles Orth wrote:

> I'm new to nginx...
> I would like to define upstream handler in HTTP without a HTTP server
> listener. From SMTP/POP3/IMAP I would like
> to use the upstream handler for my http endpoint. Thus requiring
> http_upstream initialize, create a request, hand the request off to upstream
> for processing and finally having HTTP upstream handler return the entire
> response to my handler.
> I haven't found any examples or patches where I can leverage HTTP upstream
> from Mail service perspective.
> Does anyone have a suggestion or an example?

This is not something you can do.  Mail and http are different 
modules, and you can't use http module features in the mail 
module.  If you want to use upstreams in mail, you have to 
reimplement them there.

Practical solution is to use one address in mail (e.g., 
127.0.0.1:8080) and additionally balance requests using http 
reverse proxy, e.g.:

mail {
    auth_http 127.0.0.1/mailauth;
    ...
}

http {
    upstream backends {
        server 127.0.0.2:8080;
        ...
    }

    server {
        listen 8080;

        location /mailauth {
            proxy_pass http://backends;
        }
    }
}

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx mailing list