<p>I am trying to setup a nginx ingress controller; here is the yaml of the ingress:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-rules
  namespace: default
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
    nginx.ingress.kubernetes.io/force-ssl-redirect: "false"

spec:
  rules:
  - host: 
    http:
      paths:
      - path: /discover-service
        backend:
          serviceName: discover-service
          servicePort: discover-port
</code></pre>

<p>When I hit <a href="http://IP/discover-service" rel="nofollow noreferrer">http://IP/discover-service</a> it shows an HTML without CSS and JS. As I can see, they are looked under <a href="http://IP/eureka/css/file.css" rel="nofollow noreferrer">http://IP/eureka/css/file.css</a> instead of <a href="http://IP/discover-service/css/file.css" rel="nofollow noreferrer">http://IP/discover-service/css/file.css</a>. </p>

<p>How can I preserve the original url in this case? </p>

<p><strong>UPDATE #1</strong></p>

<p>Now I can serve the static files by creating two ingresses like:</p>

<pre><code>ingress-rules-discover-root.yaml

[..]
metadata:
  name: ingress-rules-discover-root

  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
    [...]

spec:
  rules:
  - host: 
    http:
      paths:

      - path: /discover-service
        backend:
          serviceName: discover-service
          servicePort: discover-port
</code></pre>

<p>and another one </p>

<pre><code>[...]
metadata:
  name: ingress-rules-discover-path
  namespace: default
  annotations:
    kubernetes.io/ingress.class: nginx
    [...]

spec:
  rules:
  - host: 
    http:
      paths:
      - path: /eureka
        backend:
          serviceName: discover-service
          servicePort: discover-port
</code></pre>

Justin
<p>I believe in this case you need to remove the annotation:</p>

<pre><code>nginx.ingress.kubernetes.io/rewrite-target: /
</code></pre>

<p>This annotation makes the ingress rewrite <code>http://IP/discover-service/css/file.css</code> to <code>http://IP/eureka/css/file.css</code></p>
