-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
"kong_upstream" as server_name in SNI for upstream https #2129
Comments
I think I've found what causes it and a quick fix that works in my setup at least. The problem is in nginx-kong.conf (generated from kong/templates/nginx_kong.lua) where the section "upstream kong_upstream" together with the line "proxy_pass $upstream_scheme://kong_upstream;" causes Nginx to use "kong_upstream" as server_name in SNI towards upstream. I solved it by overriding what server name Nginx should use in SSL connection to upstream server by using the proxy_ssl_name directive in nginx-kong.conf (had to change in the template since nginx-kong.conf gets generated when kong starts):
|
Hey, Thank you very much for investigating this. We'll include this fix in an upcoming release. Feel free to propose a PR against release/0.10 or next! |
I found out that my quick fix overriding server name with proxy_ssl_name breaks the certificate lookup process in kong/core/certificate.lua for requests where client does not provide any SNI. |
Can you provide more info as to what does it break exactly? Errors, or return values from the |
I just applied the fix from @konrade and it worked for me, without SSL certificate issues. |
My followup problem with error in certificate lookup process went away once I configured my own default certificate i kong.conf (with config line: ssl_cert = ...). |
Confirming fix from @konrade works with default setup. |
This will be fixed in 0.10.2. Thanks @konrade for the original report and initial patch! |
Summary
Upstream HTTPS request has SNI server_name set to "kong_upstream" when API is configured with upstream_url starting with https:// even if API is configured with preserve_host=true.
This confuses upstream Apache httpd (and probably other web servers too) since it does not match header "Host: " and it returns a 400 and logging:
My setup is (except other domain names):
When I packet sniff the communication I can see that Kong sends a TLS Client Hello with server_name set to "kong_upstream" when I curl https://test.example.com:8443 (which resolves to IP that Kong is listening on).
It feels like the correct behaviour should be that Kong sends the same name in SNI and Host header for upstream requests over HTTPS.
I'm running Kong 0.10.0rc4 (from released dpkg) on Ubuntu 16.04.02 and my /etc/kong/kong.conf looks like this:
The text was updated successfully, but these errors were encountered: