Sunday, May 16, 2021

Nginx Ingress with rewrite annotation

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: abc-ingress
  namespace : default
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
    nginx.ingress.kubernetes.io/ssl-ciphers: "ALL"
    nginx.ingress.kubernetes.io/ssl-prefer-server-ciphers: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  tls:
  - hosts:
    - abc.com
  rules:
  - host: abc.com
    http:
      paths:
      - path: /something(/|$)(.*)
        backend:
          serviceName: abc-service
          servicePort: 8080
  tls:
  - hosts:
    - abc.com
    secretName: abc-secret

With config above:
  • The request https://abc.com/something will send to backend as  https://abc.com/
  • The request https://abc.com/something/somepath will send to backend as  https://abc.com/somepath 

No comments:

Post a Comment

Install and use xorg-server on macOS via Homebrew

  The instructions to install and use xorg-server on macOS via Homebrew: Install Homebrew (if you haven't already): /bin/bash -c ...