10

I have a nginx instance in AWS that has upstream Application layer.

There are two requirements for nginx
- keepalive
- use resolver to dynamically resolve the upstream

I am able to make either of them work.

Here is the config for making keepalive work:

upstream "backend" {
    server "appserver.example.com:443";
    keepalive 250;
}

server {           
    resolver 10.0.0.2 valid=60s;
    server_name _;
    location / {
                proxy_http_version 1.1;
                proxy_pass https://backend;
    }
}

Here is the config for DNS resolver to work:

 server {           
    resolver 10.0.0.2 valid=60s;
    server_name _;
    set $backend appserver.example.com:443;
    location / {
                proxy_http_version 1.1;
                proxy_pass https://$backend;
    }
}

How can I get both DNS resolver and keepalive to work without using a third-party plugin in open source NGinx

Hector
  • 101
  • 3
  • This can be natively done with using Nginx Plus. I wonder why upstream keep alive is required, is the given upstream server located elsewhere from Nginx and the latency in between high? – Anatoly Aug 08 '17 at 11:29

1 Answers1

1

According to this Nginx wiki page there seems to be the jdomain Plugin

http {
    resolver 8.8.8.8;
    resolver_timeout 10s;

    upstream backend {
        jdomain  www.baidu.com;
        # keepalive 10;
    }
    server {
        listen       8080;

        location / {
            proxy_pass http://backend;
        }
    }
}
luckydonald
  • 5,976
  • 4
  • 38
  • 58