<p>I trying to deploy my angular application with kubernates inside a container with nginx.</p>

<p>I create my docker file:</p>

<pre><code>FROM node:10-alpine as builder

COPY package.json package-lock.json ./

RUN npm ci &amp;&amp; mkdir /ng-app &amp;&amp; mv ./node_modules ./ng-app

WORKDIR /ng-app

COPY . .

RUN npm run ng build -- --prod --output-path=dist

FROM nginx:1.14.1-alpine

COPY nginx/default.conf /etc/nginx/conf.d/

RUN rm -rf /usr/share/nginx/html/*

COPY --from=builder /ng-app/dist /usr/share/nginx/html

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
</code></pre>

<p>My nginx config:</p>

<pre><code>server {

  listen 80;

  sendfile on;

  default_type application/octet-stream;


  gzip on;
  gzip_http_version 1.1;
  gzip_disable      "MSIE [1-6]\.";
  gzip_min_length   1100;
  gzip_vary         on;
  gzip_proxied      expired no-cache no-store private auth;
  gzip_types        text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
  gzip_comp_level   9;


  root /usr/share/nginx/html;

  location / {
    try_files $uri $uri/ /index.html =404;
  }

  location /api {
    proxy_pass https://my-api;
  }

}
</code></pre>

<p>If I launch this image locally It works perfectly but when I deploy this container inside a kubernate cluster the site load fine but all api request shows the error <code>ERR_CONNECTION_REFUSED</code>.</p>

<p>I'm trying to deploy in GCP I build the image and then publish my image by GCP dashboard.</p>

<p>Some idea for this <code>ERR_CONNECTION_REFUSED</code>?</p>

<p>I found the solution. The problem was with my requests, I was using <code>localhost</code> at the URL, with that I took the wrong pod IP. I've just changed the request to use straight the service IP and that sort out my problem.</p>
