0

I'm using ingress-nginx on kubernetes. I need to redirect incoming connections to / to a blog hosted on webflow and perform path-based routing.

Webflow provides a domain like website123.webflow.com. I would like to serve the blog without performing a redirect. I would like to mask the webflow domain and use the default instead.

Here's what I came with so far:

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

The above solution doesn't work as I'd like to. The URL in the browser changes from my.custom.domain.com to website123.webflow.io, which is not what I want.

I believe the host header reaches paths other than / which is not ideal. Not tested yet.

If remove nginx.ingress.kubernetes.io/upstream-vhost I get an error from webflow's CDN because the $host header uses a domain that is not available. Adding the custom domain produces the same error.

Any ideas if I can handle this situation gracefully using ingress-nginx?

patm
  • 1,420
  • 14
  • 19
  • I believe it's webflow that does the redirection when it detects the URL is different from what it originally is. – Lukman Jul 06 '21 at 22:51

1 Answers1

1

This works for me without annotations like upstream-vhost etc.

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
Rakesh Gupta
  • 3,507
  • 3
  • 18
  • 24