Sometimes you want your url to show with www, or not. For me I wanted just the root domain.

(e.g. "https://yulyshaiou.com" not "https://www.yulyshaiou.com")

As of the time I write this "How-to", Ghost's documentation is rather confusing if you are not familiar with nginx.


First you need log into your server in via terminal or whatever you are using to get to your web hosting server, then navigate to your ghost folder.

They are usually at /var/www/ghost.

In my scenario, because I first had my domain set with www, then I wanted to change to root domain.

# Determine your secondary URL
ghost config url https://yulyshaiou.com

# Get Ghost-CLI to generate an SSL setup for you:
ghost setup nginx ssl

Then I ran into this

terminal error on getting SSL

Then I went into each

/etc/nginx/sites-available/

/etc/nginx/sites-enabled/

/var/www/ghost/system/files/

Delete all the .conf files that were created

sudo rm /etc/nginx/sites-available/yulyshaiou.com.conf

sudo rm /etc/nginx/sites-enabled/yulyshaiou.com.conf

sudo rm /var/www/ghost/system/files/yulyshaiou.com.conf

This request from let's encrypt failed because your did not set up your cname and A record from your domain hosting registrar, for me, mine was with AWS.

Login to your AWS console and navigate to your Route 53 service and select Hosted zones, find your domain name.

You will need to do both like screenshot below.

aws route 53 hosted zone screenshot

Make sure you wait for a bit, the change doesn't update right a way, otherwise you will run into the same issue.

# Determine your secondary URL
ghost config url https://yulyshaiou.com

# Get Ghost-CLI to generate an SSL setup for you:
ghost setup nginx ssl

Upon success, you should have message like mine below.

terminal ssl request success for yulyshaiou.com

Next you will need to configure your nginx file. I configured both www.yulyshaiou.com.conf and www.yulyshaiou.com-ssl.conf in the /etc/nginx/ folder.

cd /etc/nginx/

vim www.yulyshaiou.com.conf
# 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 https://yulyshaiou.com$request_uri;

e.g.

server {
    listen 80;
    listen [::]:80;

    server_name www.yulyshaiou.com;
    root /var/www/ghost/system/nginx-root; # Used for acme.sh SSL verification (https://acme.sh)

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:2369;
        
        return 301 https://yulyshaiou.com$request_uri;
    }

    location ~ /.well-known {
        allow all;
    }

    client_max_body_size 50m;
}
:wq!
#to save and exit

Update another config that is in SSL.

vim www.yulyshaiou.com-ssl.conf
# 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 https://yulyshaiou.com$request_uri;
:wq!
#to save and exit

Then you need to refresh your nginx.

# Get nginx to verify your config, upon success you will have a message saying it is good
sudo nginx -t

# Reload nginx with your new config
sudo nginx -s reload

# restart ghost
ghost restart

Finally you are done. Each time when you enter the domain with www or without www, your site will display your preferred url.

I hope this information has helped you. Thanks for coming, godspeed.