Hector
Hector

Reputation: 121

nginx keepalive and dns resolver

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

Upvotes: 12

Views: 2579

Answers (1)

luckydonald
luckydonald

Reputation: 6886

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;
        }
    }
}

Upvotes: 1

Related Questions