Solve SSL Issue for Nginx 301 Redirect

Solve SSL Issue for Nginx 301 Redirect

SSL for additional domains

You may wish to have multiple domains that redirect to your site, e.g. to have an extra TLD or to support www. domains. Ghost itself can only ever have one domain pointed at it. This is intentional for SEO purposes, however you can always redirect extra domains to your Ghost install using nginx.

If you want to redirect an HTTPS domain, you must have a certificate for it. If you want to use Ghost-CLI to generate an extra SSL setup, follow this guide:

# Determine your secondary URL
ghost config url
# Get Ghost-CLI to generate an SSL setup for you:
ghost setup nginx ssl
# Change your config back to your canonical domain
ghost config url

# Edit the nginx config files for your second domain to redirect to your canonical domain. In both files replace the content of the first location block with:

return 301$request_uri;
# Get nginx to verify your config
sudo nginx -t
# Reload nginx with your new config
sudo nginx -s reload


(1) Edit both of the .conf files for your second domain. It’s normally located in /var/www/ghost/system/files/

(2) Only remove the first “location” block. The second one, which includes “.well-known”, is used for renewing your certificate(s).

(3) Always use sudo nginx -t to verify your config before reload Nginx.

Copyright statement: Unless otherwise stated, all articles on this blog adopt the CC BY-NC-SA 4.0 license agreement. For non-commercial reprints and citations, please indicate the author: Henry, and original article URL. For commercial reprints, please contact the author for authorization.