-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[NGINIX Ingress Controller] Support for 301 redirects. #1884
Comments
@MaikuMori can you post an Ingress rules as example? |
Could be done with some awkward Ingress rule like this: apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test
namespace: test
annotations:
ingress.kubernetes.io/301-to: "https://domain.com/path"
kubernetes.io/ingress.class: "nginx"
spec:
rules:
- host: foo.bar.com Other option is in the configmap using some sort of format:
In this example split on Personally I would like free-form config map entry like:
Also such custom block set via annotations would be nice for adding custom options to server directives created by Ingress resource. @aledbf what do you think? |
@MaikuMori I think could be useful That said there's a some issues some of the proposals:
that is not possible because it makes impossible the creation of a generic template (please check the current version to see the logic behind
supporting "lists" inside the annotation is not an issue but you are mixing domains and paths that breaks all the logic behind the controller to generate the data for the template.
WDYT of this (just to avoid numbers and provide clarity?): |
Technically NGINX supports multiple http blocks, but it's not exactly best practice and can break stuff. What about
I specifically added paths only to the destination. In my case I needed to redirect all traffic with specific But you're right, it's somewhat complex to define generic options because there are multiple use cases that people could have:
Much better, the examples I gave were just to showcase different ideas. I still feel multiple Ingress rules are clumsy and overall too verbose. |
+1 |
If anyone else may end up here - I found a pretty good way to solve one of my issues using I've had issues with a setup using Basically my ingress worked for Solution was to add a 2nd separate ingress resource with a custom rewrite:
|
+1 |
2 similar comments
+1 |
+1 |
This helped to solve the issue at least with GET requests: /foo works and /foo/ works too but this cannot be said for POST requests. Even with this rewrite rule, the POST request still requires the trailing slash. |
Issues go stale after 90d of inactivity. Prevent issues from auto-closing with an If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
FYI, this is currently supported: https://github.com/kubernetes/ingress-nginx/blob/master/docs/user-guide/annotations.md#permanent-redirect |
Could anyone please show me an example ingress for what @praseodym has posted. How would I redirect |
The updated link for what @praseodym shared is: https://github.com/kubernetes/ingress-nginx/blob/master/docs/user-guide/nginx-configuration/annotations.md#permanent-redirect Thanks 🎉 |
Would be nice to be able to setup 301 redirects. As services come and go, certain things in the cluster get deprecated and require a redirect to a new location.
Two current solutions that I'm aware of now:
The general issue is to be able to add custom configuration sections in global and per ingress controller scope. Otherwise I feel the project will end up slowly implementing each NGINX config option as flag.
I am willing to contributing the redirect code.
The text was updated successfully, but these errors were encountered: