Nginx ingress kubernetes Proxy Pass

12/31/2019

I need configure a proxy pass in a nginx ingress.

The rule must be:

%USER%.test.domain.com to app.test.domain.com/%USER%

*It must be a proxy pass NOT a redirect

I created this Ingress but it does not work

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test02-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    kubernetes.io/tls-acme: 'true'
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/server-snippet: |
      server_name  ~^(?<subdomain>.+)\.test\.domain\.it;

      location = / {       


        proxy_pass https://app.test.domain.it/$subdomain/;
        proxy_set_header Host $subdomain.test.domain.it;

      }
spec:
  rules:
  - host: "*.test.domain.it"
    http:
      paths:
      - path: /
        backend:
          serviceName: test01-svc
          servicePort: 80

``
-- Diego barrientos
kubernetes
kubernetes-ingress
nginx
nginx-reverse-proxy

0 Answers