Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method Based Routing in Nginx Ingress #5552

Open
abhijitvikash opened this issue May 15, 2024 · 6 comments
Open

Method Based Routing in Nginx Ingress #5552

abhijitvikash opened this issue May 15, 2024 · 6 comments

Comments

@abhijitvikash
Copy link

Hi Nginx, I want to implement method based routing(GET PUT OPTIONS) in Nginx Ingress. But seems like this is not supported either using :
nginx.ingress.kubernetes.io/configuration-snippet
nginx.ingress.kubernetes.io/server-snippet:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: testing-ingress-01
annotations:
nginx.ingress.kubernetes.io/configuration-snippet: |
set $target_backend "httpd-service.default.svc.cluster.local";
if ($request_method = 'PUT') {
set $target_backend "httpd-service.default.svc.cluster.local"; # Change this to your PUT service if needed
}
if ($request_method = 'GET') {
set $target_backend "httpd-service.default.svc.cluster.local"; # Change this to your GET service if needed
}
proxy_pass http://$target_backend;
spec:
ingressClassName: nginx
rules:

  • http:
    paths:
    • path: /
      pathType: ImplementationSpecific
      backend:
      service:
      name: httpd-service
      port:
      number: 80
Copy link

Hi @abhijitvikash 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 🙂

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
Copy link
Collaborator

Method based routing.
As in, a GET is sent to one service, a PUT to a different service, a POST to yet a different service, and so on.
Did I get that correct?

I am asking because the project offers Method filtering / blocking which might also meet the need.
https://docs.nginx.com/nginx-ingress-controller/configuration/virtualserver-and-virtualserverroute-resources/#match

@vepatel
Copy link
Contributor

vepatel commented May 20, 2024

@brianehlert I think @abhijitvikash is using community project looking at the annotations here.
@abhijitvikash can you please specify which project you're using along with version?

@abhijitvikash
Copy link
Author

@abhijitvikash
Copy link
Author

helm template my-nginx ingress-nginx/ingress-nginx --values values-ext.yaml --namespace ingress-nginx > nginx-ingress-external-manifest.yaml

@jasonwilliams14
Copy link
Contributor

@abhijitvikash Hello there.
That repo you listed is a different NGINX ingress controller project.
This repo is the official NGINX Ingress controller project maintained by NGINX.

You can see our documentation located here:

https://docs.nginx.com/nginx-ingress-controller/

If you are using the ingress resource, you can use snippets:

https://docs.nginx.com/nginx-ingress-controller/configuration/ingress-resources/advanced-configuration-with-snippets/

If you are using our CRD definitions, you can use snippets as well:

https://docs.nginx.com/nginx-ingress-controller/configuration/virtualserver-and-virtualserverroute-resources/#using-snippets

Let us know if that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

4 participants