【问题标题】:Can't connect to an AWS container service in Lightsail using it's private domain无法使用其私有域连接到 Lightsail 中的 AWS 容器服务
【发布时间】:2021-04-21 14:21:22
【问题描述】:

我在安装了 nginx (1.18.0) 的 AWS Lightsail 上创建了一个 Ubuntu (20.04 LTS) 实例。我还成功地将 docker 映像发布到 AWS Lightsail 容器服务,当公共端点启用时,它可以正常工作。但是,我不想将此服务公开给公众,而是通过我的 Ubuntu 实例上的反向代理将流量路由到它。

我的问题是,当我尝试从我的 Ubuntu 实例卷曲容器服务的私有域 (.service.local:) 时,我得到了 Could not resolve host servicename.service.local。根据Lightsail docs(“私有域”部分),我的“与您的服务在同一 AWS 区域中的 Lightsail 资源”应该可以访问它。

我对网络还很陌生,因此我非常感谢您提供一些意见。为了从我的实例访问此服务,是否需要配置其他任何内容?

我已验证的内容:

  • 映像已启动并运行,并且在使用公共域连接到它时工作正常
  • 我在同一个区域同时运行实例和容器服务

非常感谢!

【问题讨论】:

    标签: amazon-web-services network-programming docker-image amazon-lightsail


    【解决方案1】:

    我刚刚遇到了同样的问题。我启动了两个实例,一个使用 Amazon Linux 2,一个使用 Ubuntu 20.04。 AL2实例可以通过域名解析和访问容器服务:

    [ec2-user@ip-172-26-0-176 ~]$ host nginx.service.local
    nginx.service.local has address 172.26.17.185
    [ec2-user@ip-172-26-0-176 ~]$ curl http://nginx.service.local/
    <!DOCTYPE html>
    ...
    

    Ubuntu 实例不能。

    删除 Ubuntu 实例上的 /etc/resolv.conf 并将其替换为 AL2 实例中的 /etc/resolv.conf 有什么帮助:

    [ec2-user@ip-172-26-0-176 ~]$ cat /etc/resolv.conf 
    ; generated by /usr/sbin/dhclient-script
    search eu-central-1.compute.internal
    options timeout:2 attempts:5
    nameserver 172.26.0.2
    

    它可以工作,但感觉不是一个特别干净的解决方案,因为它会覆盖 Ubuntu 的 systemd 管理的 resolv.conf。

    【讨论】:

    • 太棒了,它就像一个魅力!这肯定会暂时有效。干杯!
    猜你喜欢
    • 1970-01-01
    • 2021-08-20
    • 2021-05-15
    • 2017-02-28
    • 2021-05-25
    • 2021-12-27
    • 1970-01-01
    • 2021-08-21
    • 2022-12-09
    相关资源
    最近更新 更多