<div dir="ltr"><p dir="ltr" style="margin-top:0px;font-family:Arial,sans-serif;font-size:15.008px">What is the best way to route traffic to a backend web front service which uses different relative paths within the web application.</p><p dir="ltr" style="font-family:Arial,sans-serif;font-size:15.008px">As an example, take a standard Jaeger service<code dir="ltr" style="font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace;font-size:1em"> kubectl create -f <a href="https://tinyurl.com/yc52x6q5">https://tinyurl.com/yc52x6q5</a></code>.</p><p dir="ltr" style="font-family:Arial,sans-serif;font-size:15.008px">I would like to expose this service endpoint via an ingress controller, see ingress configuration below</p><pre dir="ltr" style="font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace;font-size:15.008px"><code class="gmail-hljs gmail-yaml" dir="ltr" style="font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace;font-size:1em;overflow:auto;display:block;padding:0.5em;max-height:500px"><span class="gmail-hljs-attr">apiVersion:</span> <span class="gmail-hljs-string"><a href="http://networking.k8s.io/v1">networking.k8s.io/v1</a></span>
<span class="gmail-hljs-attr">kind:</span> <span class="gmail-hljs-string">Ingress</span>
<span class="gmail-hljs-attr">metadata:</span>
  <span class="gmail-hljs-attr">name:</span> <span class="gmail-hljs-string">frontend-ingress</span>
  <span class="gmail-hljs-attr">annotations:</span>
    <span class="gmail-hljs-attr"><a href="http://nginx.ingress.kubernetes.io/rewrite-target">nginx.ingress.kubernetes.io/rewrite-target</a>:</span> <span class="gmail-hljs-string">/$1</span>
    <span class="gmail-hljs-attr"><a href="http://kubernetes.io/ingress.class">kubernetes.io/ingress.class</a>:</span> <span class="gmail-hljs-string">nginx</span>
    <span class="gmail-hljs-attr"><a href="http://nginx.ingress.kubernetes.io/force-ssl-redirect">nginx.ingress.kubernetes.io/force-ssl-redirect</a>:</span> <span class="gmail-hljs-string">"true"</span>
    <span class="gmail-hljs-attr"><a href="http://nginx.ingress.kubernetes.io/add-base-url">nginx.ingress.kubernetes.io/add-base-url</a>:</span> <span class="gmail-hljs-string">"true"</span>
<span class="gmail-hljs-attr">spec:</span>
  <span class="gmail-hljs-attr">rules:</span>
    <span class="gmail-hljs-bullet">-</span> <span class="gmail-hljs-attr">host:</span>
      <span class="gmail-hljs-attr">http:</span>
        <span class="gmail-hljs-attr">paths:</span>
          <span class="gmail-hljs-bullet">-</span> <span class="gmail-hljs-attr">path:</span> <span class="gmail-hljs-string">/</span>
            <span class="gmail-hljs-attr">pathType:</span> <span class="gmail-hljs-string">Prefix</span>
            <span class="gmail-hljs-attr">backend:</span>
              <span class="gmail-hljs-attr">service:</span>
                <span class="gmail-hljs-attr">name:</span> <span class="gmail-hljs-string">frontend</span>
                <span class="gmail-hljs-attr">port:</span>
                  <span class="gmail-hljs-attr">number:</span> <span class="gmail-hljs-number">4444</span>
          <span class="gmail-hljs-bullet">-</span> <span class="gmail-hljs-attr">path:</span> <span class="gmail-hljs-string">/jaeger</span>
            <span class="gmail-hljs-attr">pathType:</span> <span class="gmail-hljs-string">Prefix</span>
            <span class="gmail-hljs-attr">backend:</span>
              <span class="gmail-hljs-attr">service:</span>
                <span class="gmail-hljs-attr">name:</span> <span class="gmail-hljs-string">jaeger-query</span>
                <span class="gmail-hljs-attr">port:</span>
                  <span class="gmail-hljs-attr">number:</span> <span class="gmail-hljs-number">443</span>

  
</code></pre><p dir="ltr" style="font-family:Arial,sans-serif;font-size:15.008px">Using ingress endpoint <code dir="ltr" style="font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace;font-size:1em">https://<host public ip>/jaeger,</code> I am able to successfully invoke the backend service (jaeger-query), however the backend service pages with the relative URLs (like /static and /api) are not getting loaded/rendered on the browser as ingress controller does not have a rule to route that traffic.</p><p dir="ltr" style="font-family:Arial,sans-serif;font-size:15.008px">As a workaround, I added ingress rules for /static and /api to point to the same backend service. configuration.</p><pre dir="ltr" style="font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace;font-size:15.008px"><code class="gmail-hljs gmail-yaml" dir="ltr" style="font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace;font-size:1em;overflow:auto;display:block;padding:0.5em;max-height:500px"><span class="gmail-hljs-attr">apiVersion:</span> <span class="gmail-hljs-string"><a href="http://networking.k8s.io/v1">networking.k8s.io/v1</a></span>
<span class="gmail-hljs-attr">kind:</span> <span class="gmail-hljs-string">Ingress</span>
<span class="gmail-hljs-attr">metadata:</span>
  <span class="gmail-hljs-attr">name:</span> <span class="gmail-hljs-string">frontend-ingress</span>
  <span class="gmail-hljs-attr">annotations:</span>
    <span class="gmail-hljs-attr"><a href="http://nginx.ingress.kubernetes.io/rewrite-target">nginx.ingress.kubernetes.io/rewrite-target</a>:</span> <span class="gmail-hljs-string">/$1</span>
    <span class="gmail-hljs-attr"><a href="http://kubernetes.io/ingress.class">kubernetes.io/ingress.class</a>:</span> <span class="gmail-hljs-string">nginx</span>
    <span class="gmail-hljs-attr"><a href="http://nginx.ingress.kubernetes.io/force-ssl-redirect">nginx.ingress.kubernetes.io/force-ssl-redirect</a>:</span> <span class="gmail-hljs-string">"true"</span>
    <span class="gmail-hljs-attr"><a href="http://nginx.ingress.kubernetes.io/add-base-url">nginx.ingress.kubernetes.io/add-base-url</a>:</span> <span class="gmail-hljs-string">"true"</span>
<span class="gmail-hljs-attr">spec:</span>
  <span class="gmail-hljs-attr">rules:</span>
    <span class="gmail-hljs-bullet">-</span> <span class="gmail-hljs-attr">host:</span>
      <span class="gmail-hljs-attr">http:</span>
        <span class="gmail-hljs-attr">paths:</span>
          <span class="gmail-hljs-bullet">-</span> <span class="gmail-hljs-attr">path:</span> <span class="gmail-hljs-string">/</span>
            <span class="gmail-hljs-attr">pathType:</span> <span class="gmail-hljs-string">Prefix</span>
            <span class="gmail-hljs-attr">backend:</span>
              <span class="gmail-hljs-attr">service:</span>
                <span class="gmail-hljs-attr">name:</span> <span class="gmail-hljs-string">frontend</span>
                <span class="gmail-hljs-attr">port:</span>
                  <span class="gmail-hljs-attr">number:</span> <span class="gmail-hljs-number">4444</span>
          <span class="gmail-hljs-bullet">-</span> <span class="gmail-hljs-attr">path:</span> <span class="gmail-hljs-string">/jaeger</span>
            <span class="gmail-hljs-attr">pathType:</span> <span class="gmail-hljs-string">Prefix</span>
            <span class="gmail-hljs-attr">backend:</span>
              <span class="gmail-hljs-attr">service:</span>
                <span class="gmail-hljs-attr">name:</span> <span class="gmail-hljs-string">jaeger-query</span>
                <span class="gmail-hljs-attr">port:</span>
                  <span class="gmail-hljs-attr">number:</span> <span class="gmail-hljs-number">443</span>
          <span class="gmail-hljs-bullet">-</span> <span class="gmail-hljs-attr">path:</span> <span class="gmail-hljs-string">/search</span>
            <span class="gmail-hljs-attr">pathType:</span> <span class="gmail-hljs-string">Prefix</span>
            <span class="gmail-hljs-attr">backend:</span>
              <span class="gmail-hljs-attr">service:</span>
                <span class="gmail-hljs-attr">name:</span> <span class="gmail-hljs-string">jaeger-query</span>
                <span class="gmail-hljs-attr">port:</span>
                  <span class="gmail-hljs-attr">number:</span> <span class="gmail-hljs-number">443</span>
          <span class="gmail-hljs-bullet">-</span> <span class="gmail-hljs-attr">path:</span> <span class="gmail-hljs-string">/static</span>
            <span class="gmail-hljs-attr">pathType:</span> <span class="gmail-hljs-string">Prefix</span>
            <span class="gmail-hljs-attr">backend:</span>
              <span class="gmail-hljs-attr">service:</span>
                <span class="gmail-hljs-attr">name:</span> <span class="gmail-hljs-string">jaeger-query</span>
                <span class="gmail-hljs-attr">port:</span>
                  <span class="gmail-hljs-attr">number:</span> <span class="gmail-hljs-number">443</span>
          <span class="gmail-hljs-bullet">-</span> <span class="gmail-hljs-attr">path:</span> <span class="gmail-hljs-string">/api</span>
            <span class="gmail-hljs-attr">pathType:</span> <span class="gmail-hljs-string">Prefix</span>
            <span class="gmail-hljs-attr">backend:</span>
              <span class="gmail-hljs-attr">service:</span>
                <span class="gmail-hljs-attr">name:</span> <span class="gmail-hljs-string">jaeger-query</span>
                <span class="gmail-hljs-attr">port:</span>
                  <span class="gmail-hljs-attr">number:</span> <span class="gmail-hljs-number">443</span>
</code></pre><p dir="ltr" style="font-family:Arial,sans-serif;font-size:15.008px">Ideally, I would like one Ingress rule per backend service and the relative paths like /static and /api to automatically adjust to /jaeger/static and /jaeger/api.</p><p dir="ltr" style="font-family:Arial,sans-serif;font-size:15.008px">Do you know how that can be achieved?</p></div>