After setting up a couple different Ghost blogs recently, I've run into needing to set up SSL multiple time. Ghost helps generate a Let's Encrypt certificate for you if you use the default setup. However, it only sets up the SSL certificate for one domain. If you want your website to work with both www
and non-www
subdoamins then you'll have to make some manual modifications. I've decided that I want the non-www domain to be the default for all users, so a 301 redirect
and enabling SSL on both subdomains is what I want. If that's not what you want, then this probably won't be as helpful. Its possible this will work too, but I haven't tested it.
When setting up your DNS settings, setup the A record
as normal. Have @
point to your server ip
. Then setup a 301 redirect
from www
to your non-www
domain or vice-versa if you prefer having the www subdomain as the default address users should use.
After setting up the Ghost blog as normal using the ghost-cli
, run this command. This adds an additional domain to Let's Encrypt.
Replace {domain}
(twice), {ghost root}
, and {email}
with your information.
sudo /etc/letsencrypt/acme.sh --issue --home /etc/letsencrypt --domain {domain} --domain www.{domain} --webroot {ghost root}/system/nginx-root --reloadcmd "nginx -s reload" --accountemail {email}
The new code is just:
--domain www.{domain}