Unable to access app angular + nginx + istio

1/7/2020

I am trying to configure istio service mesh for a project consisting of .net core services with angular 6 as front end.

Funny thing is that if i deploy application with build and run inside docker applications are running fine.

Example: angular serving with prod or qa configuration inside node image.

But application will not work if i use nginx image by copying dist folder content inside html folder.

NOTE: Istio configuration is in place.

I created destination rule, virtual service for the angular with nginx deployment with

  1. Nodeport :

    upstream connect error or disconnect/reset before headers. reset reason: connection failure

  2. ClusterIp:

    Request not reaching service

  3. Loadbalancer

    Request not reaching

Tried overriding default.conf of nginx as mentioned in Envoy not connecting but file is not getting overwritten.

-- Dileep Gagan R
angular
istio
kubernetes
nginx

1 Answer

1/14/2020

I found the solution after doing lot of research.

As mentioned in istio documentation nginx upstream error, i made changes in my nginx.conf as below.

upstream application {
  server 0.0.0.0:[PortNumber];
}

server {
  listen [PortNumber] default_server;

  charset utf-8;

  sendfile on;

  root /usr/share/nginx/html;

  #Caches static assets
  location ~ ^/(assets|bower_components|scripts|styles|views) {
    expires     31d;
    add_header  Cache-Control public;
  }

  #Caches Bundles created by angular cli
  location ~* \.(?:bundle.js|bundle.css)$ {
    expires 1M;
    access_log off;
    add_header Cache-Control "public";
  }

  ##
  # Main file index.html sending not found locations to the main
  ##
  location / {
    proxy_pass http://application;
    proxy_http_version 1.1;
    proxy_set_header Connection "";
    expires -1;
    add_header Pragma "no-cache";
    add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";

    try_files $uri $uri/ /index.html = 404;
  }
}
-- Dileep Gagan R
Source: StackOverflow