title: Kubernetes ingress domain redirect
body: <p>i want to redirect domain in nginx ingress kubernete.</p>
  
  <pre><code>https://test.example.io/preview/qLxiVcDGxCaQ134650121853FTg4
  </code></pre>
  
  <p>if in url <code>preview</code> comes change domain redirect </p>
  
  <pre><code>https://test.app.example.io/preview/qLxiVcDGxCaQ134650121853FTg4
  </code></pre>
  
  <p>what i was trying</p>
  
  <pre><code>apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    annotations:
      certmanager.k8s.io/cluster-issuer: staging
      nginx.ingress.kubernetes.io/rewrite-target: /
      kubernetes.io/ingress.class: nginx
    name: staging-ingress
  spec:
    rules:
    - host: test.example.io
      http:
        paths:
        - path: /
          backend:
            serviceName: service-1
            servicePort: 80
        - path: /preview/*
          backend:
            url: 
            serviceName: service-2
            servicePort: 80
    tls:
    - hosts:
      - test.example.io
      secretName: staging
  </code></pre>
  
  <p>for simple nginx block is like </p>
  
  <pre><code>location ~ /preview
      {
        rewrite /preview https://test.app.example.com$uri permanent;
      }
  </code></pre>