-
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
Need option to specify location-specific auth-annotations in Ingress-nginx #1893
Comments
@avishnu you can create two Ingress and only add the annotations to the ingress with the path you want to protect. No need to use the |
Thanks a ton @aledbf.
kind: Ingress
kind: Ingress
|
@avishnu I am trying to do the same and have a couple of questions;
|
@bdelsaz
Because ingress controller will auto configure all matched ingress. |
Hi, Thanks for the clarification above. I have a single pod with multiple containers in it. These containers expose different endpoints for users and share a common filesystem. |
Hi I am also having same problem
For the second ingress expected behaviour is only accessible by allowed ips. But getting 403 for all the ips. And am using nginx ingress |
Is this a request for help? (If yes, you should use our troubleshooting guide and community support channels, see https://kubernetes.io/docs/tasks/debug-application-cluster/troubleshooting/.):
What keywords did you search in NGINX Ingress controller issues before filing this one? (If you have found any duplicates, you should instead reply there.):
Is this a BUG REPORT or FEATURE REQUEST? (choose one):
Feature request
NGINX Ingress controller version:
1.13.3
Kubernetes version (use
kubectl version
):Server Version: version.Info{Major:"1", Minor:"7+", GitVersion:"v1.7.8-gke.0", GitCommit:"a7061d4b09b53ab4099e3b5ca3e80fb172e1b018", GitTreeState:"clean", BuildDate:"2017-10-10T18:48:45Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
Environment:
Cloud
uname -a
): Linux nginx-ingress-controller-1998717890-gsllx 4.4.0-1027-gke Remove hardcoded health check from GenericController #27-Ubuntu SMP Thu Aug 10 13:13:08 UTC 2017 x86_64 x86_64 x86_64 GNU/LinuxWhat happened:
What you expected to happen:
I've hosted 3 services (serviceA and serviceB) behind my ingress-nginx. Below is the yaml.
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
annotations:
kubernetes.io/ingress.class: nginx
ingress.kubernetes.io/rewrite-target: /
kubernetes.io/tls-acme: true
name: my-nginx-ingress
spec:
tls:
secretName: mysecret
rules:
http:
paths:
backend:
serviceName: serviceA
servicePort: 8080
backend:
serviceName: serviceB-service
servicePort: 7070
Everything is working great without any issues.
I can access serviceA end-point with https://myhost/ and serviceB with https://myhost/serviceB/ perfectly well.
I've been trying to enable ingress basic-auth on serviceB ONLY. By following the steps https://github.com/kubernetes/contrib/tree/master/ingress/controllers/nginx/examples/auth, I can successfully configure nginx basic-auth. However, the below 3 annotations are getting applied to all the available locations in the translated nginx.conf. I want the auth-specific annotations to get written only inside the location specific to serviceB, which is not happening.
echo "
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-with-auth
annotations:
# type of authentication
ingress.kubernetes.io/auth-type: basic
# name of the secret that contains the user/password definitions
ingress.kubernetes.io/auth-secret: basic-auth
# message to display with an appropiate context why the authentication is required
ingress.kubernetes.io/auth-realm: "Authentication Required - foo"
spec:
rules:
http:
paths:
backend:
serviceName: echoheaders
servicePort: 80
" | kubectl create -f -
I've referred to another source https://github.com/nginxinc/kubernetes-ingress/blob/master/examples/customization/cafe-ingress-with-annotations.yaml which recommends to use nginx-scripting for making my use-case work. This has 2 issues:
ingress.kubernetes.io/configuration-snippet: |
if ($request_uri ~ "serviceB") {
set $auth "auth req";
}
if ($request_uri !~ "serviceB") {
set $auth off;
}
auth_basic $auth;
auth_basic_user_file /etc/ingress-controller/auth/default.passwd;
proxy_set_header Authorization "";
proxy_set_header X-AUTH-USER $remote_user;
The above works but has some limitations. What I'm interested in is the following:
I've tried to search but have not found any solution to my requirement, hence posting a request here.
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know:
The text was updated successfully, but these errors were encountered: