<p>I have deployed my application in a baremetal kubernetes cluster using nginx as ingress controller. I have deployed several ui applications with <code>&lt;my-hostname&gt;/&lt;module-name&gt;</code> (I cannot change this due to client's requirements). I have written following ingress rules to access my APIs and modules.</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
    kubernetes.io/tls-acme: &quot;true&quot;
    nginx.ingress.kubernetes.io/proxy-body-size: 100m
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/ssl-passthrough: &quot;true&quot;
    nginx.ingress.kubernetes.io/ssl-redirect: &quot;false&quot;
    nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;
    nginx.org/proxy-connect-timeout: 60s
    nginx.org/proxy-read-timeout: 60s
  name: test-ingress
  namespace: csi-dev
spec:
  rules:
  - host: 'my.host.name'
    http:
      paths:
      - backend:
          serviceName: security-servicename
          servicePort: 80
        path: (/&lt;api-pattern&gt;/iam/)(.*)
      - backend:
          serviceName: api-gateway-servicename
          servicePort: 80
        path: (/&lt;api-pattern&gt;/)(.*)
      - backend:
          serviceName: ui-config-server-servicename
          servicePort: 80
        path: (/&lt;ui-config-server-pattern&gt;/)(.*)
      - backend:
          serviceName: ui-module1-servicename
          servicePort: 80
        path: /(ui-module1)/?(.*)
      - backend:
          serviceName: ui-module1-servicename
          servicePort: 80
        path: /(ui-module2)/?(.*)
      - backend:
          serviceName: ui-module1-servicename
          servicePort: 80
        path: /(ui-module3)/?(.*)
</code></pre>
<p>When I apply this Ingress controller, Kubernetes give me following errors.</p>
<pre><code>* spec.rules[0].http.paths[0].path: Invalid value: &quot;(.*/&lt;api-pattern&gt;/iam/)(.*)&quot;: must be an absolute path
* spec.rules[0].http.paths[1].path: Invalid value: &quot;(.*/&lt;api-pattern&gt;/)(.*)&quot;: must be an absolute path
* spec.rules[0].http.paths[2].path: Invalid value: &quot;(.*/&lt;ui-config-server&gt;/)(.*)&quot;: must be an absolute path
</code></pre>
<p>But when I use <code>*.host.name</code> instead of <code>my.host.name</code> this works without error.
I need to restrict my hostname also.</p>
<p>Do anyone have a solution?</p>

<p>Found an answer on <a href="https://gitlab.cncf.ci/kubernetes/kubernetes/blob/60f4fbf4f25764dbd94b7f8146d927ddc684514d/pkg/apis/extensions/validation/validation.go#L417-418" rel="nofollow noreferrer">this</a></p>
<p>Kubernetes API validates whether <code>spec.rules[n].http.paths[m].path</code> has a <code>/</code> when hostname does not have a wildcard. Hence rewrote <code>Path</code> as follows.</p>
<p><code>/(.*&lt;api-pattern&gt;/iam/)(.*)</code></p>
