无法使用私有域连接到 Lightsail 中的 AWS 容器服务 [英] Can't connect to an AWS container service in Lightsail using it's private domain

查看:23
本文介绍了无法使用私有域连接到 Lightsail 中的 AWS 容器服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've created an Ubuntu (20.04 LTS) instance on AWS Lightsail on which I have installed nginx (1.18.0). I've also successfully published a docker image to an AWS Lightsail Container Service that, when the public endpoint is enabled, works fine. However, I don't want to expose this service to the public but instead route traffic to it through a reverse proxy on my Ubuntu instance.

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

My problem is when I try and curl the container service's private domain (<ServiceName>.service.local:<PortNumber>) from my Ubuntu instance I get Could not resolve host servicename.service.local. According to the Lightsail docs (section "Private domain") this should be accessible to my "Lightsail resources in the same AWS Region as your service".

我对网络还很陌生,所以我非常感谢您提供一些意见.为了从我的实例访问此服务,还有什么需要配置的吗?

I'm pretty new to networking so I would greatly appreciate some input. Is there anything else that needs to be configured in order to reach this service from my instance?

我验证过的事情:

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

非常感谢!

推荐答案

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

I just ran into the same problem. I spun up two instances, one with Amazon Linux 2, one with Ubuntu 20.04. The AL2 instance can resolve and access a container service by domain name:

[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 实例不能.

The Ubuntu instance cannot.

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

What did help was removing the /etc/resolv.conf on the Ubuntu instance, and replacing it with the one from the AL2 instance:

[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.

It works, but doesn't feel like a particularly clean solution, since this overwrites Ubuntu's systemd-managed resolv.conf.

这篇关于无法使用私有域连接到 Lightsail 中的 AWS 容器服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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