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/server-snippet: |
      lua_shared_dict targets 1m;
      init_by_lua_block {
        ngx.shared.targets:set("default", "httpd-service.default.svc.cluster.local");
      }
      rewrite_by_lua_block {
        local method = ngx.req.get_method()
        local backend = ngx.shared.targets:get("default")
        if method == "PUT" then
          backend = "httpd-service.default.svc.cluster.local"  -- Change this if you want different service
        elseif method == "GET" then
          backend = "httpd-service.default.svc.cluster.local"  -- Change this if you want different service
        end
        ngx.var.target_backend = backend
      }
      location / {
        proxy_pass http://$target_backend;
      }
spec:
  ingressClassName: nginx
  rules:
  - http:
      paths:
      - path: /
        pathType: ImplementationSpecific
        backend:
          service:
            name: httpd-service
            port:
              number: 80

Method Based Routing in Nginx Ingress
This is a GitHub Issue
repo:ingress-nginx
owner:kubernetes
Title : Method Based Routing in Nginx Ingress
Issue date:

--- start body ---
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/server-snippet: |
      lua_shared_dict targets 1m;
      init_by_lua_block {
        ngx.shared.targets:set("default", "httpd-service.default.svc.cluster.local");
      }
      rewrite_by_lua_block {
        local method = ngx.req.get_method()
        local backend = ngx.shared.targets:get("default")
        if method == "PUT" then
          backend = "httpd-service.default.svc.cluster.local"  -- Change this if you want different service
        elseif method == "GET" then
          backend = "httpd-service.default.svc.cluster.local"  -- Change this if you want different service
        end
        ngx.var.target_backend = backend
      }
      location / {
        proxy_pass http://$target_backend;
      }
spec:
  ingressClassName: nginx
  rules:
  - http:
      paths:
      - path: /
        pathType: ImplementationSpecific
        backend:
          service:
            name: httpd-service
            port:
              number: 80

--- end body ---
