Creating SSL cert for example.com as well as www.example.com


#1

During the “ghost setup” step, I set up the ssh certs for my domain by entering the domain as https://example.com. However, I noticed that this does not make a certificate for https://www.example.com even though it’s specified in my nginx config.
Thus, I thought maybe I would run “ghost setup” again and put in https://www.example.com as my domain instead and create a new ssl cert. This time, it made https://www.example.com the valid cert, but now going to https://example.com gives me a 502 Bad Gateway.

I attempted to use a standalone installation of Certbot for this as well; unfortunately certbot created an infinite loop that required a rollback and was not an optimal solution. I can not find a way to rollback the ssl cert creation in Ghost; being able to do this would likewise be helpful.

in \etc\nginx\sites-enabled.conf\ i currently have 5 nginx configs; default, example.com.conf, example.com-ssl.conf, www.example.com.conf, and www.example.com-ssl.conf. Should I delete www.example.com.conf and www.example.com-ssl.conf?

tldr i need to expand my existing certificate to add https://www.example.com without changing the domain the blog is running from


#2

That’s OK to get the SSL certificate for www. as well. Of course, let’s hope the devs will add an easier way in future versions.

No need to rollback. It’s good to have the two certificates, for https://example.com and https://www.example.com, even if you then configure redirections.

Good.

No, you just need to adjust your Ghost (/var/www/ghost/config.production.json) and Nginx configurations, and restart. See an example with redirections to https://example.com


#3

ghost setup will only setup (including nginx, ssl, etc) the domain you enter as config. Your idea to use ghost setup a second time was the right path, the exact steps & commands for this are documented here:

https://docs.ghost.org/docs/cli-knowledge-base#section-ssl-for-additional-domains


#4

Thank you. That article solved my issue. I had no idea that the files were symlinked from /var/ghost/system/files, this definitely caused some confusion when I tried setting up letsencrypt outside of the ghost utility!


#7

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.