-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Support multiple domains using a wildcard TLS certificate #1008
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 multiple domains using a wildcard TLS certificate #1008
Conversation
Signed-off-by: Lewis Marshall <lewis@lmars.net>
Previous to this change, each TLS domain would be written to nginx.conf using the nginx.ssl.conf template (lines 69-73) but with an empty "server_name" directive (because NOSSL_SERVER_NAME was not set). This would then become irrelevant because nginx.conf would get truncated on line 88, and a single parsing of the template would then be written to nginx.conf on line 89, meaning only the last TLS domain would be set up to actually use TLS. This patch changes this behaviour so that all TLS domains get added to nginx.conf using the nginx.ssl.conf template (which includes redirecting HTTP -> HTTPS), and all non-TLS domains get added using the nginx.conf template, so do not get redirected to a TLS domain. Signed-off-by: Lewis Marshall <lewis@lmars.net>
|
First off, thanks for taking the time to contribute. I've banged around on this a little bit and need some clarification. Here are my scenarios:
Scenario 1 works as expected. Scenario 2 redirects as expected but So we need to decide if non-wildcard redirects should behave differently or modify |
|
Should |
|
In scenario 2, yes. As the cert doesn't contain |
|
Yeah, so I guess |
|
@lmars feel like taking a stab at |
Yes this is the redirect behaviour I want, but your example is actually incorrect. A CN of This is broken on master and I think should be handled in a separate issue / PR.
Again this is broken on master and I think should be fixed separately: The problem I am trying to solve in this PR is that valid wildcard domains should redirect to their https equivalent, not to the last configured SSL domain, which is what happens on master: |
|
Oh yeah good catch there. I've been ignoring the SSL warnings since I'm using a self signed cert. The SSL stuff could be a lot better. @josegonzalez: it would be great get the nginx-vhosts functionality fully documented with how it is supposed to work and then ensure our test suite backs that up. 😄 |
|
@michaelshobbs ok, so is there anything you want me to do before potentially merging this? |
|
I'd personally like to see |
As mentioned earlier, the changes in this PR do not affect |
|
I see where you are coming from and obviously this PR does not actively change how |
|
Ha! Never mind that last bit. Just saw the other PR. 😄 Thanks! |
|
Tested this combined with #1013 and I think we're pretty close. One thing I noticed was that domains that partially match the cert CN, get SSLd and redirected in the nginx config. (Same errant case you pointed out originally.) Thoughts on fixing that here? Other than that, I think this one is good to go. |
As per RFC 2818 [0], a CN of *.dokku.me will only match direct subdomains of dokku.me, not sub-subdomains like www.test.dokku.me, but Dokku currently enables TLS for subdomains of all levels. I have changed the regex from .*\.dokku\.me to [^.]*\.dokku\.me so TLS is only enabled for direct subdomains. [0] - http://tools.ietf.org/html/rfc2818#section-3.1 Signed-off-by: Lewis Marshall <lewis@lmars.net>
|
@michaelshobbs I have fixed the sub-subdomain match issue: 9202f11 |
|
thanks! |
Support multiple domains using a wildcard TLS certificate
I deploy a Rails app using Dokku which uses subdomain based routing, so requests for
admin.example.comandapi.example.comget handled differently.I was previously handling this by deploying multiple apps, each with a single domain and TLS cert, but I now have to push to 3 remotes to deploy the same app.
The change here fixes what looks like intended behaviour to support multiple domains using a wildcard certificate (see comments in a4d79e2 for further explanation of the change).