Nginx 无法解析 DNS - AWS ECS

问题描述 投票:0回答:1

我在 VPC 中的 AWS ECS 中有 2 个服务。我们将它们称为服务 A 和服务 B。服务 A 有一个 nginx 容器,我正在尝试

proxy_pass
连接到服务 B。我正在使用服务连接来连接服务之间的 DNS。

我一直在查看Nginx内部dns解决问题但我仍然有问题。我还拥有对服务 A 容器的完全执行访问权限,以进行故障排除。以下是我的配置

我有一个启用了 DNS 的 VPC

然后我有我的

nginx.conf
,缩写为:

http {

    server {
    listen 80;
    listen 443 ssl;

    resolver 169.254.169.253;
    # I have also tried using the CIDR of VPC + 2 in my case
    # 10.0.0.2
    #I have also set the variable as shown in the SO question above
    #But that cause other errors 

    location / {

        proxy_pass http://service-B:8080;

    }

}

当我运行这一切并发出请求时,我在 nginx 日志中看到

service-B
被解析为
127.255.0.1
。它总是会解决这个问题,然后我就会超时。

当我

exec
进入服务A时,我可以远程登录到服务B并连接。但是当我卷曲时,我收到错误
upstream request timeout

这里缺少什么?

amazon-web-services docker nginx amazon-ecs nginx-reverse-proxy
1个回答
0
投票

检查IP地址169.254.169.253 然后在 nginx 中检查解析器中的 VPN DNS。

proxy_set_header 主机$host; (error_log /path/to/error.log 错误;') 没有防火墙规则 服务B和nginx之间的端口

© www.soinside.com 2019 - 2024. All rights reserved.