<p>I've created an nginx ingress controller that is linked to two services. The website works fine but the js and css files are not loaded in the HTML page (404) error. I've created nginx pod using helm, and Included the nginx config in the ingress.yaml. The error is raised when I use nginx, I've I run the docker image locally, it works fine. Also, if I made the services' types as a Load balancer, the applications work fine.</p>

<p><a href="https://i.stack.imgur.com/F256W.png" rel="nofollow noreferrer">![here is the error in the webpage
]<a href="https://i.stack.imgur.com/F256W.png" rel="nofollow noreferrer">1</a></a></p>

<p><a href="https://i.stack.imgur.com/F256W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F256W.png" alt="enter image description here"></a></p>

<p>here is the GKE services:</p>

<p><a href="https://i.stack.imgur.com/HgDvT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HgDvT.png" alt="enter image description here"></a></p>

<p>ingress.yaml:</p>

<pre class="lang-py prettyprint-override"><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  creationTimestamp: 2019-07-08T08:35:52Z
  generation: 1
  name: www
  namespace: default
  resourceVersion: "171166"
  selfLink: /apis/extensions/v1beta1/namespaces/default/ingresses/www
  uid: 659594d6-a15b-11e9-a671-42010a980160
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
  rules:
  - host: twitter.domain.com
    http:
      paths:
      - backend:
          serviceName: twitter
          servicePort: 6020
  - host: events.omarjs.com
    http:
      paths:
      - backend:
          serviceName: events
          servicePort: 6010
  - http:
      paths:
      - backend:
          serviceName: twitter
          servicePort: 6020
        path: /twitter
      - backend:
          serviceName: events
          servicePort: 6010
        path: /events
  tls:
  - secretName: omarjs-ssl
status:
  loadBalancer: {}
</code></pre>

<p>twitter.yaml:</p>

<pre class="lang-py prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  creationTimestamp: 2019-07-07T20:43:49Z
  labels:
    run: twitter
  name: twitter
  namespace: default
  resourceVersion: "27299"
  selfLink: /api/v1/namespaces/default/services/twitter
  uid: ec8920ca-a0f7-11e9-ac47-42010a98008f
spec:
  clusterIP: 10.7.253.177
  externalTrafficPolicy: Cluster
  ports:
  - nodePort: 31066
    port: 6020
    protocol: TCP
    targetPort: 3020
  selector:
    run: twitter
  sessionAffinity: None
  type: NodePort
status:
  loadBalancer: {}
</code></pre>

<pre class="lang-py prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  creationTimestamp: 2019-07-07T20:43:49Z
  labels:
    run: twitter
  name: twitter
  namespace: default
  resourceVersion: "27299"
  selfLink: /api/v1/namespaces/default/services/twitter
  uid: ec8920ca-a0f7-11e9-ac47-42010a98008f
spec:
  clusterIP: 10.7.253.177
  externalTrafficPolicy: Cluster
  ports:
  - nodePort: 31066
    port: 6020
    protocol: TCP
    targetPort: 3020
  selector:
    run: twitter
  sessionAffinity: None
  type: NodePort
status:
  loadBalancer: {}
</code></pre>

omar
<p>You can probably solve your problem by adding additional ingress rules which will route the requests for static files to proper directories. As far as I can see on the attached print screen, your static files are placed in <code>css</code> and <code>js</code> directories respectively, so you need to add 4 additional rules to your <code>ingress.yaml</code>. The final version of this fragment may look like that:</p>

<pre><code>  - http:
      paths:
      - backend:
          serviceName: twitter
          servicePort: 6020
        path: /twitter
      - backend:
          serviceName: twitter
          servicePort: 6020
        path: /css
      - backend:
          serviceName: twitter
          servicePort: 6020
        path: /js
      - backend:
          serviceName: events
          servicePort: 6010
        path: /events
      - backend:
          serviceName: events
          servicePort: 6010
        path: /css
      - backend:
          serviceName: events
          servicePort: 6010
        path: /js
</code></pre>
