nginx keepalive and dns resolver

走远了吗. 提交于 2021-02-07 12:50:24

问题


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


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


来源:https://stackoverflow.com/questions/39421748/nginx-keepalive-and-dns-resolver

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!