-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Request: Enable Ingress rewrite to direct all non-www to www sudomain #605
Comments
This doesn't seem to be a supported feature of the GCE loadbalancers right now. |
@pieterlange So the alternative is to use NGINX then? |
Yes |
How would one go about redirecting from non www to www using the nginx-ingress controller? Having a hard time trying to figure this out. Not sure if its possible without editing the nginx.tmpl. |
I would love to see the proposed solution by @aledbf in this comment. I think those annotations would cover this case as well. My case it a bit more specific where I need to redirect permanently to an entirely different domain. Currently I use a trick by explicitly adding an NGINX rewrite rule to the Ingress configuration using a Configuration Snippet:
|
+1 |
3 similar comments
+1 |
+1 |
+1 |
Same request but the other way around, we want to redirect www to non-www. |
Closing. Fixed in master. |
@aledbf any link to the PR or documentation on how to use this? |
@montanaflynn today I will open a PR for that |
@montanaflynn here https://github.com/kubernetes/ingress/blob/master/controllers/nginx/configuration.md#redirect-from-to-www |
@aledbf thanks!
How do you specify if it should remove or add the www subdomain? |
If you add the annotation in an ingress for host foo.com it will add a redirect from www.foo.com -> foo.com |
Does this work with kube-lego? I want example.com to redirect to www.example.com. If I list both hosts in tls.hosts and rules then ssl works for both but the redirect does not happen. If I remove one of the hosts then ssl does not work for the host I've removed from the ingress. |
@kyv no because this annotation is just a redirect, there's no content in the server section of nginx.conf |
Ok. Might be worthwhile mentioning in the readme or configuration.md. |
Is there a workaround with kube-lego? I think it's a pretty common setup. |
@fiws The workaround I'm currently using is another nginx service that's doing all www to root or vice versa logic before proxying to web service etc. Would be really nice to get rid of that extra nginx service. |
and redirect. We initially wanted to use [the redirect-from-to-www annotation](https://github.com/kubernetes/ingress-nginx/blob/master/docs/user-guide/annotations.md#redirect-from-to-www), as this is nice and neat, but unfortunately that [isn't able to serve a TLS certificate for the redirected domain](kubernetes/ingress-nginx#605). Until that's fixed, we have to use this solution, [as others are doing](kubernetes/ingress-nginx#605 (comment)). (It would also help to make this more DRY if we were able to [specify multiple hosts in a http rule](kubernetes/kubernetes#43633))
The one suggested here works in our situation but the ff. annotation doesn't work:
|
Hi,
Apologies is this is not the place for this question, but I can't seem to find an answer anywhere else. As the question states, I'm trying to redirect all traffic from
example.com
towww.example.com
using an Ingress resource on Kubernetes. I've tried the Ingress Rewrite Annotation, but I can't get it to work. I'd like to avoid having to use and configure NGINX, since I already use e.g. loadbalancing on GKE and it works great.Here is my Ingress (JSON format):
I can't find a proper example of rewriting all non-www to www subdomain, hence this question.
Hopefully you guys can help me out.
Thanks!
EDIT
Since this is an unsupported feature, I changed the issue into a request.
The text was updated successfully, but these errors were encountered: