Kubernetes Ingress needs Reverse Proxy setting

5/24/2019

In my Kubernetes Cluster i have some challenges with the Ingress. As example i installed NodeRed und the Nginx-ingress via Helm. NodeRed is available via

Now i created an Ingress:

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: nr-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  tls:
  - secretName: tls-secret1
    hosts:
    - my.server.name
  rules:
  - host: my.server.name
    http:
      paths:
      - path: /nr
        backend:
          serviceName: my-nodered-node-red
          servicePort: 1880

When i do a Get http://my.server.name/nr i see only parts working, see the screenshot:

enter image description here

It looks to me, that i missed the reverse proxy settings. Normally i would place those things in a reverse proxy setting in the nginx like this. But this is not possible because i am using the Nginx-ingress.

location / {
     proxy_pass http://localhost:1880/;
    }

But i do not know how to do that in Kubernetes ? What do i miss ? kubernetes version is 1.14.1.

-- Mchoeti
kubernetes
kubernetes-helm
nginx-ingress
node-red
reverse-proxy

2 Answers

5/24/2019

It looks like your static content is still using root path prefix, you can verify that using browser developer console. Common applications should have a configuration to understand that they are running on non-root path prefix. You should find that configuration option in your application and configure it properly. Nginx ingress has nothing to do with this error.

-- Vasily Angapov
Source: StackOverflow

6/12/2019

I haven't used it so I'm not sure if it helps, but you might want to try adding an annotation for Proxy redirect.

With the annotations nginx.ingress.kubernetes.io/proxy-redirect-from and nginx.ingress.kubernetes.io/proxy-redirect-to it is possible to set the text that should be changed in the Location and Refresh header fields of a proxied server response

Setting "off" or "default" in the annotation nginx.ingress.kubernetes.io/proxy-redirect-from disables nginx.ingress.kubernetes.io/proxy-redirect-to, otherwise, both annotations must be used in unison. Note that each annotation must be a string without spaces.

By default the value of each annotation is "off".

Also you can use ConfigMap for customizing your Nginx configuration.

kind: ConfigMap
apiVersion: v1
metadata:
  name: nginx-configuration
  namespace: ingress-nginx
  labels:
    app: ingress-nginx
data:

  http-snippet: |
      location = / {       
        proxy_pass http://localhost:1880/;
      }

Or server-snippets annotation for your Ingress:

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: nr-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/server-snippet: |
      location = / {       
        proxy_pass http://localhost:1880/;
      }
spec:
  tls:
  - secretName: tls-secret1
    hosts:
    - my.server.name
  rules:
  - host: my.server.name
    http:
      paths:
      - path: /nr
        backend:
          serviceName: my-nodered-node-red
          servicePort: 1880

I hope this helps.

-- Crou
Source: StackOverflow