<p>I have three issues:</p>
<p>1 - How can I correctly implement regex to match the first part of a path in ingress?</p>
<pre><code>- path: /^search_[0-9A-Z]{9}
    backend:
      serviceName: global-search-service
      servicePort: 5050
</code></pre>
<p>I would like to match any path that begins with <code>/search_</code> e.g <code>/search_model</code> or <code>/search_make</code></p>
<p>2 - How can I access a service with no path just port.</p>
<pre><code> path: 
    pathType: Exact
    backend:
      serviceName: chart-display
      servicePort: 10000
</code></pre>
<p>I am just displaying this service using iframe. How do I access it since I only have the port number?</p>
<p>3 - I am hosting two different react apps, both of them work when I set their path as root <code>/</code> .. how do I implement both of them to work with root path?</p>
<p>Trying issue 3.</p>
<p>So I come up with something like this right?</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: admin-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
      - path: /admin
        backend:
          serviceName: web2-service
          servicePort: 2000

---          

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: normal-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;
spec:
  rules:
  - http:
      paths:
      - path: /
        backend:
          serviceName: web1-service
          servicePort: 1000
</code></pre>
<p>Loading <code>&lt;my-ip&gt;/admin</code> does not go to web2-service, and if i leave them both at <code>/</code> , it automatically goes to web1-service. Kindly advice</p>

Denn
<p>For the first question, you can use regex in your paths without any problem, you just need to annotate the ingress with the use-regex, at least according to the documentation (<a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#use-regex" rel="nofollow noreferrer">https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#use-regex</a>)</p>
<p>Something like:</p>
<pre><code>metadata:
  name: your-name
    annotations:
      nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;
  spec:
    ...
</code></pre>
<p>or as an alternative, if you use the annotation for rewrite target, the regex should also be enforced.</p>
<p>As for the regex to use, in order to match the start of a path, for example all paths starting with <strong>something</strong>, like <strong>something_first</strong> or <strong>something_another</strong>, you could go for the simple:</p>
<pre><code>something_[a-zA-Z0-9]*
</code></pre>
<p>For the second question I'm not sure of what you are asking, exactly. The Ingress is supposed to be used with http or https requests and those should provide a path. If you want to simply expose a service outside at a given port, you could go for a LoadBalancer service.</p>
<p>Internally, the service you want to access with just a port answers in http at the root path? Or does something different? If it answers only at the root path, you could match all paths in the request to the root path.</p>
<p>As for how you could make all paths of the request rewrite to root, you could go with a rewrite annotation, such as:</p>
<pre><code>nginx.ingress.kubernetes.io/rewrite-target: /
</code></pre>
<p>For more info on this annotation, check the documentation because it can do a lot of things (<a href="https://kubernetes.github.io/ingress-nginx/examples/rewrite/" rel="nofollow noreferrer">https://kubernetes.github.io/ingress-nginx/examples/rewrite/</a>)</p>
<p>Also take in mind that if you want to rewrite two services in two different places, you need to split the Ingress into two separate ingresses</p>
