-
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
[nginx] whitelist-source-range doesn’t work on ssl port #727
Comments
@cheungpat this is fixed in master. Please use the image |
@aledbf Thanks for the quick reply! It is also nice to know that there is a image that is frequently updated. : ) I updated the ingress controller to use the image The same error is printed in the log:
Perhaps it is my config that is causing problem? Here is my ingress controller deployment and configmap: # deployment
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
k8s-app: nginx-ingress-lb
name: nginx-ingress-controller
namespace: kube-system
spec:
selector:
matchLabels:
k8s-app: nginx-ingress-lb
template:
metadata:
labels:
k8s-app: nginx-ingress-lb
spec:
containers:
- args:
- /nginx-ingress-controller
- --default-backend-service=$(POD_NAMESPACE)/default-http-backend
- --default-ssl-certificate=$(POD_NAMESPACE)/ssl-cert
- --configmap=$(POD_NAMESPACE)/nginx-configmap
- --publish-service=$(POD_NAMESPACE)/nginx-ingress-controller
env:
- name: POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
image: quay.io/aledbf/nginx-ingress-controller:0.116
imagePullPolicy: IfNotPresent
name: nginx-ingress-lb
ports:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
---
# configmap
apiVersion: v1
data:
body-size: 50m
hsts: "false"
kind: ConfigMap
metadata:
name: nginx-configmap
namespace: kube-system |
@cheungpat please publish the service |
The behavior of the In short, the load balancer will only forward traffic to the node that has the pod running in order to preserve source IP. The service manifest looks like this: apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/external-traffic: OnlyLocal
service.beta.kubernetes.io/healthcheck-nodeport: "31557"
name: nginx-ingress-controller
namespace: kube-system
spec:
clusterIP: 10.7.241.1
ports:
- name: http
nodePort: 30427
port: 80
protocol: TCP
targetPort: 80
- name: https
nodePort: 30077
port: 443
protocol: TCP
targetPort: 443
selector:
k8s-app: nginx-ingress-lb
sessionAffinity: None
type: LoadBalancer |
The issue is the forward from 443 to 442 that sees the source IP as "127.0.0.1". This was solved in beta3 (by not enabling that forward if there is no specific rule that requires it and keeping 443 as SSL) and now it is broken again (just tested beta.4 and there is no way to disable the 443->442 thing. Here's the commit that broke it again: |
@sigxcpu76 right and that is why I am refactoring the template to use the real IP address (that you can see in the log) and not the configured by set_real_ip_from where is not possible to reflect the redirect between ports Edit: I am sorry for the troubles this issue introduces but the ssl passthrough feature is something we really need and make it work in all the different use cases is not an easy task. |
So this means anything above beta.3 is not working? The issue is that appRoot is a nice feature and it is not in beta.3 |
I am speculating that the nginx config is set to Perhaps we can set |
@cheungpat is not possible to set the value in real_ip_header, what I am testing is the use of a nginx map. |
@cheungpat @sigxcpu76 please check if the image |
@aledbf It works! |
It appears that the setting
whitelist-source-range
on an ingress does not work as expected on the 443 port but it does work on the 80 port.The ingress controller is running in GKE with Kubernetes 1.6.2. The ingress service has the
service.beta.kubernetes.io/external-traffic
annotation set toOnlyLocal
.I have an ingress that looks like this:
curl https://www.example.com
(https) doesn't work no matter the source IP is in the white-listed range or not. (My IP is1.2.3.4
here)Note that the client IP address becomes the
127.0.0.1
, which is not expected.curl http://www.example.com
(http) works as expected. If outside the white-listed range, nginx is able to identify the client IP address:I am not sure why nginx is able to identify the correct client IP address in the request log, but it doesn’t use this client IP to determine if the request should be allowed.
I think this is related to #614
The text was updated successfully, but these errors were encountered: