ssl - 让我们在 ECS Fargate 上使用 traefick 加密 SSL
问题描述
几天来我一直在尝试解决这个问题,但没有任何运气:
情况:
我在 AWS 上有一个使用 Fargate 的 ECS 集群,该集群包含 Traefick 2.3.4 和其他容器的实例。我使用 Traefick 作为反向代理将请求转发到其他容器。使用 HTTP 一切正常,所以我决定添加到 Traefick 的安全连接。我已经尝试了在 Internet 上可以找到的所有内容,但没有任何效果,当我尝试使用 curl 连接到指定域时,它返回:
curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number
这里有一些我做过的测试:
traefick.yml:
log:
level: DEBUG
api:
dashboard: true
entryPoints:
web:
address: :80
http:
redirections:
entryPoint:
to: websecure
scheme: https
websecure:
address: ":443"
providers:
ecs:
clusters:
- tools-cluster
region: eu-west-2
exposedByDefault: false
certificatesResolvers:
letsencrypt:
acme:
caServer: https://acme-staging-v02.api.letsencrypt.org/directory
email: #########################
storage: acme.json
httpchallenge:
entrypoint: web
标签:
"dockerLabels": {
"traefik.enable": "true",
"traefik.http.services.traefik.loadbalancer.server.port": "8080",
"traefik.http.routers.traefik.rule": "Host(`${host}`)",
"traefik.http.routers.traefik.entrypoints": "websecure",
"traefik.http.routers.traefik.tls.certresolver": "letsencrypt",
"traefik.http.routers.traefik.service": "api@internal"
}
此版本返回此错误:
rror: 400 :: urn:ietf:params:acme:error:connection :: Fetching https://traefik.baaluu.com/.well-known/acme-challenge/td8IdOvJ1_GkigY-jPYaA4YsgeiS5FUiuUS-avbpsuY: Error getting validation data, url
它试图检索该数据,但它不能,因为它被重定向到 https 并且它无法检索,因为 https 不起作用,我也尝试过没有自动重定向,它返回类似的错误,它可以'不检索该数据。
但是按照本指南,它应该可以正常工作。
所以我决定用这个配置转移到 dnsChallenge:Traefick.yml
log:
level: DEBUG
api:
dashboard: true
entryPoints:
web:
address: :80
websecure:
address: ":443"
providers:
ecs:
clusters:
- tools-cluster
region: eu-west-2
exposedByDefault: false
certificatesResolvers:
letsencrypt:
acme:
caServer: https://acme-staging-v02.api.letsencrypt.org/directory
email: ######################
storage: acme.json
dnsChallenge:
provider: route53
delayBeforeCheck: 3
和以前一样的标签:
"dockerLabels": {
"traefik.enable": "true",
"traefik.http.services.traefik.loadbalancer.server.port": "8080",
"traefik.http.routers.traefik.rule": "Host(`${host}`)",
"traefik.http.routers.traefik.entrypoints": "websecure",
"traefik.http.routers.traefik.tls.certresolver": "letsencrypt",
"traefik.http.routers.traefik.service": "api@internal"
}
仍然没有,我在日志中有这个:AuthURL: https://acme-staging-v02.api.letsencrypt.org/acme/authz-v3/170242259"
该网址包含:
{
"type": "urn:ietf:params:acme:error:malformed",
"detail": "Method not allowed",
"status": 405
}
我所做的最新测试是删除暂存 ca 服务器:
log:
level: DEBUG
api:
dashboard: true
entryPoints:
web:
address: :80
websecure:
address: :443
providers:
ecs:
clusters:
- tools-cluster
region: eu-west-2
exposedByDefault: false
certificatesResolvers:
letsencrypt:
acme:
email: ###############
storage: acme.json
dnsChallenge:
provider: route53
delayBeforeCheck: 2
ssl 仍然不起作用,但我在日志中看不到任何错误消息:这是我收到的关于证书的最后一条消息:
Try to challenge certificate for domain [traefik.baaluu.com] found in HostSNI rule" providerName=letsencrypt.acme routerName=traefik@ecs rule="Host(`traefik.baaluu.com`)"
之后就没有更多了:( 我很抱歉这张照片,但我找不到从 ECS 中提取日志的方法)
其他容器仍然可以通过 http 协议访问。
如果我尝试使用 telnet 连接到它,我可以访问该服务:
telnet traefik.baaluu.com 443
Trying 3.8.30.164...
Connected to traefik-1547500306.eu-west-2.elb.amazonaws.com.
Escape character is '^]'.
80也是一样
在日志中看起来更好我也发现了这个
retry due to: acme: error: 400 :: POST :: https://acme-v02.api.letsencrypt.org/acme/chall-v3/9205340157/1Wh0tQ :: urn:ietf:params:acme:error:badNonce :: JWS has an invalid anti-replay nonce: \"0004cbkFTGjCALFGDYOmhruMl6_F_fRSj33cOMvdpx5Xd2M\", url: "
time="2020-12-10T13:08:21Z" level=debug msg="legolog: [INFO] retry due to: acme: error: 400 :: POST :: https://acme-v02.api.letsencrypt.org/acme/chall-v3/9205340157/1Wh0tQ :: urn:ietf:params:acme:error:badNonce :: JWS has an invalid anti-replay nonce: \"0004cbkFTGjCALFGDYOmhruMl6_F_fRSj33cOMvdpx5Xd2M\", url: "
包含此网址:https ://acme-v02.api.letsencrypt.org/acme/chall-v3/9205340157/1Wh0tQ
{
"type": "dns-01",
"status": "valid",
"url": "https://acme-v02.api.letsencrypt.org/acme/chall-v3/9205340157/1Wh0tQ",
"token": "44R4gD4_ZmemiCn5rtkqJyWOcjoj09sEgobUvZLH6yc",
"validationRecord": [
{
"hostname": "traefik.baaluu.com"
}
]
}
所以我认为 ssl 已正确生成,但我不确定。
有什么想法或建议吗?
提前致谢。
H2K
编辑:
我已经从仪表板中删除了 ssl,并将它放在另一个容器上,现在进入仪表板内部我可以看到:
所以我认为 ssl 正在为该域工作,但我仍然无法连接到它。
编辑2:
使用 telnet 如果我在端口 443 上连接到该 url 并且我请求可以看到内容的页面:
telnet xxxxxxxxxxxxxxxxx 443
Trying 3.10.148.201...
Connected to traefik-1547500306.eu-west-2.elb.amazonaws.com.
Escape character is '^]'.
GET /index.html HTTP/1.1
Host: xxxxxxxxxxxxxxxxx
并且页面的内容出现了,所以不是负载均衡问题或路由问题,似乎我可以使用 443 到达容器,只是 ssl 不存在。就像有 2 个 http 端口并且两者的行为方式相同。此刻的 443 就像是一个 80 端口。
解决方案
推荐阅读
- android - 无论如何要控制 Soong 何时选择 Android.bp 何时不选择?
- javascript - 如何在 home.jsp 页面右侧显示 Z ID 以欢迎用户或欢迎 Z ID
- angular - Angular2 反应式表单控件验证取决于表单的外部属性
- hyperledger-fabric - gossip.discovery 关闭与端点的连接?
- linux - 如何在Linux中目录及其子目录中的所有文件中包含字符串“000”的行中添加前缀“#”?
- docker - kibana在启动过程中没有开始出错
- c++ - C++ 二进制兼容性真的在 VS 2015 和 VS 2019 之间有效吗?
- android - 当android智能手表在Android N中进入深度睡眠或打盹模式时,没有收到任何firebase推送通知
- azure - 如何使用 ARM 模板或 terraform 创建多个 Azure RDS 租户?
- android - Xamarin ios 模拟器安装失败