How to leverage HTTP upstream features

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


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., and additionally balance requests using http 
reverse proxy, e.g.:

mail {

http {
    upstream backends {

    server {
        listen 8080;

        location /mailauth {
            proxy_pass http://backends;

Maxim Dounin

More information about the nginx mailing list