nginxinc / kubernetes-ingress

NGINX and NGINX Plus Ingress Controllers for Kubernetes
https://docs.nginx.com/nginx-ingress-controller
Apache License 2.0
4.61k stars 1.96k forks source link

Ingress Controller Path and Rewrites #6017

Open jsebastianmal opened 1 month ago

jsebastianmal commented 1 month ago

I currently have an ingress driver installed on my EKS cluster where it created a Route 53 record with ACM and pointed it to my NLB and it works fine; I have created a deployment (Castlemock) and its service and when I do a portforward it works fine, but I create my ingress resource like the one attached below and it does not work, when I do a portforward castlemock works with localhost:8080/castlemock

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /castlemock
  name: approot
  namespace: sebas
spec:
  ingressClassName: nginx
  rules:
  - host: castlemock.dev.XXXXXX.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: castlemock
            port: 
              number: 80

and I get in the browser ERR_TOO_MANY_REDIRECTS

Thanks everyone for your help

greetings..

github-actions[bot] commented 1 month ago

Hi @jsebastianmal thanks for reporting!

Be sure to check out the docs and the Contributing Guidelines while you wait for a human to take a look at this :slightly_smiling_face:

I've parsed the text of your issue and it looks like you might be mixing up the two Ingress Controllers, please take a look at this page to see the differences between nginxinc/kubernetes-ingress (this repo) and kubernetes/ingress-nginx.

Cheers!

brianehlert commented 1 month ago

If using this project (the implementation from this GitHub repo) please use this annotation for rewrite: nginx.org/rewrites

https://github.com/nginxinc/kubernetes-ingress/tree/v3.6.1/examples/ingress-resources/rewrites

https://docs.nginx.com/nginx-ingress-controller/configuration/ingress-resources/advanced-configuration-with-annotations/#request-uriheader-manipulation

If you are using the NGINX Ingress Controller maintained by the Kubernetes community, that is here: https://github.com/kubernetes/ingress-nginx

vepatel commented 1 month ago

Hi @jsebastianmal , as @brianehlert mentioned please use the annotations matching the project you're using, nginx.ingress.kubernetes.io/rewrite-target: isn't a valid annotation for this project. Also please provide all the detailed asked for in issue template including NIC version, Plus/OSS and platform etc. thanks!