Kubernetes ingress does not work on redirection on some path like "/ myapp", but only works for "/"

I have a container running on a URL like http: // localhost: 8000 / ps / app / ui /? Pid = 201 . The container is deployed to kubernetes and exposed to the service as "ps-app-ui: 8000". I want to create an input that can be externally accessible. The Ingress template is like:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ps-ingress
spec:
  rules:
  - http:
      paths:
      - path: /myapp/
        backend:
          serviceName: ps-app-ui
          servicePort: 8000

      

The problem is it doesn't work with this access. I also tried adding "ingress.kubernetes.io/rewrite-target:/" but had no success. Can anyone help me access my application via http: // INGRESS-IP / myapp / ps / app / ui /? Pid = 201 "

We will be very grateful.

+3


source to share


3 answers


I think

- path: /myapp/

      

matches your application http://myapp/myapp/



So, if I have a definition:

  - host: app.example.com
    http:
      paths:
      - path: /myapp

      

It will be http://app.example.com/myapp

0


source


if you want to use http://myapp/ps/app/ui/?pid=201

you need:

  • make sure your operating system is translating myapp

    to the IP where your ingress controller is listening
  • add host

    myapp

    to inbox
  • you can leave the path empty (assuming your application is handling the full path /ps/app/ui/?pid=201

    )

The result is



rules:
  - host: myapp
    http:
      paths:
      - backend:
          serviceName: ps-app-ui
          servicePort: 8000

      

This entry will redirect all host traffic myapp

to your service

0


source


Input version 0.22.0 or higher changed the way the rewrite target works. You will need to remap the path and add it to the rewrite target.

nginx.ingress.kubernetes.io/rewrite-target: /$2
...
...
  rules:
  - host: rewrite.bar.com
    http:
      paths:
      - backend:
          serviceName: http-svc
          servicePort: 80
        path: /something(/|$)(.*)

      

Please refer to the changelog here . How to arrange an article here

0


source







All Articles