0
votes

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.

3

3 Answers

1
votes

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.

1
votes

Maybe too late for the answer, but I had the same problem and solve it:

1-changed httpRoot: '/nr' in node red settings.xml configuration file (in kubernetes, probably defined in a PV) (@vasili-angapov mentions)

2- set ingress:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nodered-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
    - http:
        paths:
          - path: /nr
            pathType: Prefix
            backend:
              service:
                name: nodered
                port:
                  number: 1880
0
votes

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.