NGINX + Kubernetes Ingress + Google Cloud Load Balancing

1/28/2018

I'm currently trying to configure a Kubernetes environment.

Currently I have a Docker image which serves my compiled Angular application via Nginx.

The default.conf of the Nginx is:

server {
  listen 80;

   location / {
    root /usr/share/nginx/html;
    index index.html index.htm;
    try_files $uri $uri/ /index.html =404;
  }
}

Ingress configuration (mapped to Google Cloud Load Balancer since I'm using Kubernetes Cluster)

 apiVersion: extensions/v1beta1
 kind: Ingress
 metadata:
   name: fullstack-ingress
   annotations:
     ingress.kubernetes.io/rewrite-target: /
 spec:
   rules:
   - http:
       paths:
       - path: /app
         backend:
           serviceName: frontend-main
           servicePort: 80
       - path: /app/*
         backend:
           serviceName: frontend-main
           servicePort: 80
       - path: /core
         backend:
           serviceName: backend-core
           servicePort: 80

Whenever I request my front-end using http://[loadbalancerip]/app/, all request sent to my angular docker are GET /app/inline.js when they should be GET /inline.js in order to work.

I tried directly in my cluster with curl and the file works. I only need to get rid of the "/app". How can I do that? Is that in the Nginx configuration or in the Ingress file?

I would rather fix it in the Ingress file, since I will probably have the same issue when I will be deploying my back-end which are .NET Core and Kestrel.

-- Dekim
docker
google-cloud-platform
google-kubernetes-engine
kubernetes
nginx

0 Answers