-
Notifications
You must be signed in to change notification settings - Fork 2k
Support custom return in the default server #1297
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
Support custom return in the default server #1297
Conversation
Deploy request for nginx-kubernetes-ingress rejected. Rejected with commit 27e662653eef3a3ce4cc88d355cd0f8235dd5cff https://docs.netlify.com/configure-builds/environment-variables/#sensitive-variable-policy |
d81e91f
to
e5c7682
Compare
Hi @030 Thanks for the PR! We'll look into it and get back to you shortly. |
Hi @030 Most of the global configuration that affects the generated NGINX config we implement through the ConfigMap. This allows changing that configuration without re-creating the IC pods and also minimizes the number of cli args (and as a result helm chart parameters). If this feature was implemented through the ConfigMap, I think the following ConfigMap key would be enough: default-server-redirect-url: https://nginx.org At the same time, another way to solve this problem could be through a more general mechanism -- server snippets. We support snippets for Ingress resources via annotations and the ConfigMap. However, we don't support them for the default server. For example, here we configure a redirect: default-server-server-snippets: location / { return 302 https://nginx.org; } More use cases could be supported. Here we tell NGINX to close the connection: default-server-server-snippets: location / { return 444; } Here we tell NGINX to return a static response: default-server-server-snippets: location / { return 200 "welcome from the Ingress Controller!\n"; } The default value would be I wonder what you think about the both ConfigMap approaches? |
1cf4b4d
to
182722c
Compare
@pleshakov Thank you for the feedback. Changes have been applied and the redirect works in conjunction with a configMap as well. Could you review again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @030
Thanks for addressing the feedback.
Because in the implementation default-server-redirect-url
configures the return
directive, could you rename the key to default-server-return
? Note that the supported use cases of the return directive are broader than redirecting. That's why default-server-return
suites better. Could you also make the corresponding changes to the identifiers in the code?
In my original suggestion, I assumed that default-server-redirect-url
would only configures the redirect. For example, return 302 {{.DefaultServerRedirectURL}};
. However, current the implementation with return {{.DefaultServerRedirectURL};
makes sense and covers more use cases. So I think it is better to keep it, although with the mentioned renaming.
There are also a few additional comments below.
docs-web/configuration/global-configuration/configmap-resource.md
Outdated
Show resolved
Hide resolved
docs-web/configuration/global-configuration/configmap-resource.md
Outdated
Show resolved
Hide resolved
By default a 404 is returned if none of the hosts match. One could define default-server-redirect-url in a configMap to redirect to another URL
60bee26
to
332dee1
Compare
@pleshakov Variable has been renamed and the documentation has been moved to the general customization paragraph |
docs-web/configuration/global-configuration/configmap-resource.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @030
This looks good to me 👍 (with this comment applied https://github.com/nginxinc/kubernetes-ingress/pull/1297/files#r560548874 )
If you could also update the commit message, as it still refers to the redirect feature. Also, for consistency, could you remove the [#1295]
from the beginning of a commit message? we typically don't put the issue number in the title -- https://github.com/nginxinc/kubernetes-ingress/commits/master
I will ask for one more approval from our project maintainers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Jodie Putrino <j.putrino@f5.com>
This allows to redirect to another URL instead of returning a 404
Proposed changes
Describe the use case and detail of the change. If this PR addresses an issue on GitHub, make sure to include a link to that issue here in this description (not in the title of the PR).
Checklist
Before creating a PR, run through this checklist and mark each as complete.