Nginx Keepalive和DNS解析器 [英] nginx keepalive and dns resolver

查看:93
本文介绍了Nginx Keepalive和DNS解析器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在AWS中有一个nginx实例,该实例具有上游应用程序层.

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

nginx有两个要求
-keepalive
-使用解析器动态解析上游

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

我能够使其中任何一个正常工作.

I am able to make either of them work.

以下是进行Keepalive工作的配置:

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

这是DNS解析器正常工作的配置:

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

如何在不使用开源NGinx中使用第三方插件的情况下使DNS解析器和keepalive正常工作

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

推荐答案

根据此 jdomain插件

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

这篇关于Nginx Keepalive和DNS解析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆