如何解决数字海洋Kubernetes上的Traefik v2.2,通配符域证书有效,但端口号无效
我正在为我们的Digital Ocean Kubernetes集群添加Traefik支持,已经使用dnsChallenge成功地从LetsEncrypt获取通配符SSL域证书。
当我尝试访问具有相同域名的网站时,一切正常:
$ curl -v https://user.example.io
* Trying 159.203.52.215:443...
* TCP_NODELAY set
* Connected to user.example.io (159.203.52.215) port 443 (#0)
* ALPN,offering http/1.1
* successfully set certificate verify locations:
* CAfile: /home/user/anaconda3/ssl/cacert.pem
CApath: none
* TLSv1.3 (OUT),TLS handshake,Client hello (1):
* TLSv1.3 (IN),Server hello (2):
* TLSv1.3 (IN),Encrypted Extensions (8):
* TLSv1.3 (IN),Certificate (11):
* TLSv1.3 (IN),CERT verify (15):
* TLSv1.3 (IN),Finished (20):
* TLSv1.3 (OUT),TLS change cipher,Change cipher spec (1):
* TLSv1.3 (OUT),Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256
* ALPN,server did not agree to a protocol
* Server certificate:
* subject: CN=example.io
* start date: Oct 23 15:49:19 2020 GMT
* expire date: Jan 21 15:49:19 2021 GMT
* subjectAltName: host "user.example.io" matched cert's "user.example.io"
* issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
* SSL certificate verify ok.
> GET / HTTP/1.1
> Host: user.example.io
> User-Agent: curl/7.68.0
> Accept: */*
>
* TLSv1.3 (IN),Newsession Ticket (4):
* TLSv1.3 (IN),Newsession Ticket (4):
* old SSL session ID is stale,removing
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< content-length: 40
< content-type: application/json; charset=utf-8
< date: Sun,25 Oct 2020 03:07:06 GMT
< etag: W/"28-v4XAuYZPRDT3aiocGxlWbac4/oE"
< vary: Accept-Encoding
< x-powered-by: Express
<
* Connection #0 to host user.example.io left intact
{"message":"User microservice"}
但是,如果是带有端口号的站点(例如Traefik仪表板),则将无法使用:
$ curl -v https://traefik.example.io:8080
* Trying 159.203.52.215:8080...
* TCP_NODELAY set
* Connected to traefik.example.io (159.203.52.215) port 8080 (#0)
* ALPN,Certificate (11):
* TLSv1.3 (OUT),TLS alert,unknown CA (560):
* SSL certificate problem: unable to get local issuer certificate
* Closing connection 0
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.haxx.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it,please visit the web page mentioned above.
如果没有端口号8080,将使用通配符域证书,但是我当然会得到“ 404 Not Found”。
$ curl -v https://traefik.example.io
* Trying 159.203.52.215:443...
* TCP_NODELAY set
* Connected to traefik.example.io (159.203.52.215) port 443 (#0)
* ALPN,server did not agree to a protocol
* Server certificate:
* subject: CN=example.io
* start date: Oct 23 15:49:19 2020 GMT
* expire date: Jan 21 15:49:19 2021 GMT
* subjectAltName: host "traefik.example.io" matched cert's "traefik.example.io"
* issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
* SSL certificate verify ok.
> GET / HTTP/1.1
> Host: traefik.example.io
> User-Agent: curl/7.68.0
> Accept: */*
>
* TLSv1.3 (IN),removing
* Mark bundle as not supporting multiuse
< HTTP/1.1 404 Not Found
< content-type: text/plain; charset=utf-8
< x-content-type-options: nosniff
< date: Sun,25 Oct 2020 03:18:38 GMT
< content-length: 19
<
404 page not found
* Connection #0 to host traefik.example.io left intact
顺便说一句,可以使用http成功访问Traefik仪表板。
以下是我的IngressRoute设置,我想这里肯定有一些问题:
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: ingressroutetls
namespace: ingress-traefik
spec:
entryPoints:
- websecure
routes:
- match: Host(`example.io`) && Path('/')
kind: Rule
services:
- name: example-com
port: 443
- match: Host(`traefik.example.io`)
kind: Rule
services:
- name: traefik-example-com
port: 8080
tls:
cetResolver: mlResolver
domains:
- main: example.io
sans:
- '*.example.io'
任何人都可以找出问题所在吗?
****在@Jakub的建议之后IngressRoute发生了变化(但仍然没有运气)****
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: ingressroutetls
namespace: ingress-traefik
spec:
entryPoints:
- websecure
routes:
- match: Host(`traefik.example.io`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))
kind: Rule
services:
- name: api@internal
kind: TraefikService
- match: Host(`example.io`) && Path('/')
kind: Rule
services:
- name: example.io
port: 443
tls:
cetResolver: mlResolver
domains:
- main: example.io
sans:
- '*.example.io'
我尝试卷曲https://traefik.example.io/dashboard
,https://traefik.example.io/api
和https://traefik.example.io
,它们都具有与以前相同的结果。 (我也曾尝试为仪表板创建一个单独的IngressRoute,但结果没有改变)
$ curl -v https://traefik.example.io/dashboard
* Trying 159.203.52.215:443...
* TCP_NODELAY set
* Connected to traefik.example.io (159.203.52.215) port 443 (#0)
* ALPN,server did not agree to a protocol
* Server certificate:
* subject: CN=example.io
* start date: Oct 23 15:49:19 2020 GMT
* expire date: Jan 21 15:49:19 2021 GMT
* subjectAltName: host "traefik.example.io" matched cert's "traefik.example.io"
* issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
* SSL certificate verify ok.
> GET /dashboard HTTP/1.1
> Host: traefik.example.io
> User-Agent: curl/7.68.0
> Accept: */*
>
* TLSv1.3 (IN),removing
* Mark bundle as not supporting multiuse
< HTTP/1.1 404 Not Found
< content-type: text/plain; charset=utf-8
< x-content-type-options: nosniff
< date: Mon,26 Oct 2020 15:44:12 GMT
< content-length: 19
<
404 page not found
* Connection #0 to host traefik.example.io left intact
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com(将#修改为@)