Nginx redirect https://www to https:// non-www without untrusted connection warning

httpsnginxssl

I have a valid SSL certificate for myapp.com, but not for www.myapp.com. Based on this question, it seems to me that it's not possible to immediately redirect from https://www.myapp.com to https://myapp.com without getting another certificate for www.myapp.com.

I'm trying to avoid shelling out more money for another certificate that's only going to be used to redirect to the "correct" site, but I also want to avoid big security warnings when somebody inadvertently accesses the wrong version.

Is it possible to use a self-signed certificate or anything free to get somebody redirected to the right version without buying another certificate?

Best Answer

I think you should have bought the certificate for www.myapp.com, then you would have received a certificate for both myapp.com and www.myapp.com. A wildcard certificate is not necessary.