数字海洋Kubernetes上的Traefik v2.2,通配符域证书有效,但端口号无效

如何解决数字海洋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/dashboardhttps://traefik.example.io/apihttps://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(将#修改为@)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?