0

ingress-nginx在 Kubernetes 上使用。我需要将传入连接重定向到/托管在webflow上的博客并执行基于路径的路由。

Webflow 提供了一个类似website123.webflow.com. 我想在不执行重定向的情况下为博客提供服务。我想屏蔽 webflow 域并使用默认值。

到目前为止,这是我带来的:

---
apiVersion: v1
kind: Service
metadata:
  name: homepage
spec:
  externalName: website123.webflow.io
  type: ExternalName
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    external-dns.alpha.kubernetes.io/hostname: my.custom.domain.com
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/load-balance: ewma
    nginx.ingress.kubernetes.io/proxy-body-size: 4G
    nginx.ingress.kubernetes.io/upstream-vhost: website123.webflow.io
    service.beta.kubernetes.io/do-loadbalancer-hostname: my.custom.domain.com
  labels:
    source: github
  name: http
  namespace: panattt1
spec:
  rules:
  - host: my.custom.domain.com
    http:
      paths:
      - path: /api
        backend:
          serviceName: http
          servicePort: 80
      - path: /images
        backend:
          serviceName: http
          servicePort: 80
      - path: /app
        backend:
          serviceName: http
          servicePort: 80
      - path: /game
        backend:
          serviceName: http
          servicePort: 80
      - path: /mapmaker
        backend:
          serviceName: http
          servicePort: 80
      - path: /dashboard
        backend:
          serviceName: http
          servicePort: 80
      - path: /
        backend:
          serviceName: homepage
          servicePort: 80
  tls:
  - hosts:
    - my.custom.domain.com

上述解决方案无法按我的意愿工作。浏览器中的 URL 从my.custom.domain.com变为website123.webflow.io,这不是我想要的。

我相信主机头到达的路径/不是理想的。尚未测试。

如果删除nginx.ingress.kubernetes.io/upstream-vhost,我会从 webflow 的 CDN 中收到错误,因为$host标头使用的域不可用。添加自定义域会产生相同的错误。

如果我可以优雅地处理这种情况,有什么想法ingress-nginx吗?

4

1 回答 1

1

这对我有用,没有上游虚拟主机等注释。

kind: Service
metadata:
  name: blog-service
  namespace: panattt1
spec:
  externalName: website123.webflow.io
  ports:
  - port: 8001
    protocol: TCP
    targetPort: 443
  type: ExternalName

---

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    ingress.kubernetes.io/force-ssl-redirect: "true"
    ingress.kubernetes.io/ssl-redirect: "true"
    kubernetes.io/ingress.class: nginx
    kubernetes.io/tls-acme: "true"
  name: blog-ingress
  namespace: panattt1
spec:
  rules:
  - host: my.custom.domain.com
    http:
      paths:
      - backend:
          serviceName: blog-service
          servicePort: 8001
        path: /
  tls:
  - hosts:
    - my.custom.domain.com
于 2021-07-06T18:14:49.590 回答