<p>I have setup an angular docker application (with nginx to serve it) in a Kubernetes cluster. In Kubernetes I have an ingress controller (the one from the kubernetes community) which shall route the traffic from the following domains:</p>

<p>a) <a href="https://app.somedomain.com" rel="nofollow noreferrer">https://app.somedomain.com</a>
and
b) <a href="https://saas-customer.somedomain.com/app" rel="nofollow noreferrer">https://saas-customer.somedomain.com/app</a></p>

<p>to the same angular container. The idea is that individual users can use a) and company users/customers can use b). I have setup the following ingress for a):</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: frontend-ingress
  annotations:  
    kubernetes.io/ingress.class: nginx
spec:
  tls:
  - hosts:
    - app.somedomain.io
    secretName: tls-secret
  rules:
  - host: app.somedomain.io
    http:
      paths:
      - backend:
          serviceName: frontend-service
          servicePort: 80
</code></pre>

<p>and this for b)</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: frontend-ingress-wild
  annotations:  
    kubernetes.io/ingress.class: nginx
spec:
  tls:
  - hosts:
    - somedomain.io
    - '*.somedomain.io'
    secretName: tls-secret
  rules:
  - host: '*.somedomain.io'
    http:
      paths:
      - path: /app
        backend:
          serviceName: frontend-service
          servicePort: 80
</code></pre>

<p>a) is working as intended. With b) the problem is that the index.html is served, but it references assets from '/'. base href is set to / in angular. </p>

<pre><code>src="polyfills.7037a817a5bb670ed2ca.js"
</code></pre>

<p>But i can not change the base href because in one case it should be '/' and in the other '/app' but still all assets should be served from one location. I do not know If i need to add specific route to angular for this to work or try to fiddle on the ingress/nginx side to solve this challenge.</p>

Masiar Ighani
<p>You want to serve your assets like *.js files from "/"? You can do it using following annotation in second ingress:</p>

<pre><code>nginx.ingress.kubernetes.io/configuration-snippet: |
  rewrite ^/app/(.*\.js)$ /$1 break;
</code></pre>

<p>This way you app will be served from /app directory and your js files - from root like this:</p>

<pre><code>/app/index.html -&gt; /app/index.html
/app/index.js -&gt; /index.js
</code></pre>

<p>Is this what you want to achieve?</p>
