-
Notifications
You must be signed in to change notification settings - Fork 2k
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
allow non-standard listen ports #171
Conversation
@seletskiy Thanks! A few suggestions:
|
Done.
Done: f1b118b#diff-394b0af448cb4ab4c28989f3aecae208L31
This will not work, because |
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.
@seletskiy
Thanks. I've added additional suggestions.
This will not work, because Config is not passed to the nginx.ingress.tmpl, so we can't extract ports from it here:
It be great if we could have ports and ssl ports defined in the Config
, with default values set to [80] and [443]. When parsing the annotations in createConfig
, we could overwrite those default values based on the annotations values, but always making sure that there is at least one port for regular and ssl ports.
server.SSL = true | ||
server.SSLCertificate = pemFile | ||
server.SSLCertificateKey = pemFile | ||
if len(sslPorts) > 1 { |
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.
len(sslPorts) > 1
leads to a bug, as it only enables SSL termination when we have at least 2 SSL ports.- this check is also unnecessary: we should always have at least 1 SSL port if SSL is enabled (
if pemFile, ok := pems[serverName];
)
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.
Yes, you're right, sorry.
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.
That check is simple a safe guard for case when annotation specifies empty value.
} | ||
{{- if $server.HSTS}} | ||
proxy_hide_header Strict-Transport-Security; | ||
add_header Strict-Transport-Security "max-age={{$server.HSTSMaxAge}}; {{if $server.HSTSIncludeSubdomains}}includeSubDomains; {{end}}preload" always;{{end}} | ||
{{- end}} | ||
{{- if $server.RedirectToHTTPS}} | ||
if ($http_x_forwarded_proto = 'http') { | ||
return 301 https://$host$request_uri; | ||
return 301 https://$host:{{index $server.SSLPorts 0}}$request_uri; |
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.
This redirect is for the case when SSL termination is done at a load balancer in front of NGINX. It can be enabled for Ingress resources without SSL termination. Thus, it is a bug and the config generation will fail.
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.
Reverted.
@@ -26,6 +26,7 @@ osx-nginx-ingress | |||
nginx-ingress | |||
osx-nginx-plus-ingress | |||
nginx-plus-ingress | |||
nginx-controller/nginx-controller |
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.
what is this for?
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.
It's to ignore nginx-controller
binary which appears when you run go build
inside nginx-controller
directory.
836dc94
to
1f6eff6
Compare
OK, I've moved default values to |
@seletskiy Thanks so much! |
@pleshakov: I've removed excessive |
@seletskiy Thanks!! |
@pleshakov: Thanks for assistance. Do you plan to release new version of image on the Docker Hub? |
@seletskiy yes, we will release a new version today |
can anyone provide a working example? |
@ChristopherLClark here is an example. instead of 80 and 443, NGINX will listen on 9080 and 9443 apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: cafe-ingress
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.org/listen-ports: "9080"
nginx.org/listen-ports-ssl: "9443"
spec:
. . . Also see https://github.com/nginxinc/kubernetes-ingress/blob/master/docs/configmap-and-annotations.md |
@pleshakov Hmm, this still doesnt quite meet my needs. I need to have kubernetes, in the spec, rules, portion be forwarding routes with ports. So for example:
In local development we can't use dns entries. So I would like to mimic the production cluster with localhost:30000 as the domain and then all requests go through that. |
@ChristopherLClark that should work OK, if you change |
@pleshakov yes I ultimately ended up running kubernetes under port 80, and killed my other processes, but I was looking for a way where I could run kubernetes under a different port. This ended up being easier just switching to 80. |
PR introduces two new annotations:
nginx.org/listen-ports
nginx.org/listen-ports-ssl
When using ingress controller with
hostNetwork: true
it is possible to allowto have non-standard ports (not 80 and 443) served by nginx. It's useful
for dynamic ports in ingress/port-based routing.
Fixes #98.