Method Based Routing in Nginx Ingress #11363
Labels
kind/feature
Categorizes issue or PR as related to a new feature.
needs-priority
needs-triage
Indicates an issue or PR lacks a `triage/foo` label and requires one.
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:
paths:
pathType: ImplementationSpecific
backend:
service:
name: httpd-service
port:
number: 80
The text was updated successfully, but these errors were encountered: