Issues arrising when migrating to another domain

  • my url: https://rbcse.ridvan.org
  • latest version of ghost
  • ghost was installed via the digital ocean marketplace droplet
  • node v16.19.1
  • mysql Ver 8.0.32-0ubuntu0.20.04.2 for Linux on x86_64 ((Ubuntu))
  • Browser, firefox :sunglasses:

So initially I took the following steps to move to a different domain:

  • point the new domain to the server with an a record
  • ghost config url “newurl.com
  • ghost restart

When I did that and visited the new url I get an unsafe warning, so its clear I don’t have an SSL cert for the new domain. So I tried

  • ghost setup ssl

which returns

SSL has already been set up, skipping
ℹ Setting up SSL [skipped]

So I tried to install certbot and generate the certificates that way with:

  • sudo snap install core; sudo snap refresh core
  • sudo snap install --classic certbot
  • sudo ln -s /snap/bin/certbot /usr/bin/certbot
  • sudo certbot --nginx

which errored with:

The requested nginx plugin does not appear to be installed

So I installed certbot with get-apt and then try to run it:

  • sudo apt-get install python3-certbot-nginx
  • sudo certbot --nginx

I get the following error:

Error while running nginx -c /etc/nginx/nginx.conf -t.

nginx: [emerg] cannot load certificate "/etc/letsencrypt/rbc.johnnypaycash.com/fullchain.cer": BIO_new_file() failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/letsencrypt/rbc.johnnypaycash.com/fullchain.cer','r') error:2006D080:BIO routines:BIO_new_file:no such file)
nginx: configuration file /etc/nginx/nginx.conf test failed

The nginx plugin is not working; there may be problems with your existing configuration.
The error was: MisconfigurationError('Error while running nginx -c /etc/nginx/nginx.conf -t.\n\nnginx: [emerg] cannot load certificate "/etc/letsencrypt/rbc.johnnypaycash.com/fullchain.cer": BIO_new_file() failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen(\'/etc/letsencrypt/rbc.johnnypaycash.com/fullchain.cer\',\'r\') error:2006D080:BIO routines:BIO_new_file:no such file)\nnginx: configuration file /etc/nginx/nginx.conf test failed\n')

So I tried to reboot the server, and now ghost is running, but nginx is not serving it properly. Ghost doctor returns:


✔ Checking system Node.js version - found v16.19.1
✔ Checking logged in user
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
System checks failed with message: 'Missing package(s): nginx'
Some features of Ghost-CLI may not work without additional configuration.
For local installs we recommend using `ghost install local` instead.
? Continue anyway? (y/N) 

So I tried reinstalling ghost cli with the following, but still get the same result as above with ghost doctor.

ghost update 5.24.2 --force

When I run sudo nginx I get the following:

nginx: [emerg] cannot load certificate "/etc/letsencrypt/rbc.johnnypaycash.com/fullchain.cer": BIO_new_file() failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/letsencrypt/rbc.johnnypaycash.com/fullchain.cer','r') error:2006D080:BIO routines:BIO_new_file:no such file)

So I tried removing the following files, hoping that they were preventing new ones from being generated:

  • sudo rm rbc.johnnypaycash.com.conf
  • sudo rm rbc.johnnypaycash.com-ssl.conf

No luck.

Can I have some help to either restore the site and move to a new domain?

It also seems like nginx needs to be configured properly to run ghost backup. If thats correct it seems I can’t get the data .json file and get the following error:

+ sudo systemctl is-active ghost_rbcse-ridvan-org
+ sudo mkdir -p /var/www/ghost/backup
✖ Backing up site
An error occurred.
Message: 'connect ECONNREFUSED 161.35.8.173:443'


Debug Information:
    OS: Ubuntu, v20.04.6 LTS
    Node Version: v16.19.1
    Ghost Version: 5.24.2
    Ghost-CLI Version: 1.24.0
    Environment: production
    Command: 'ghost backup'

Additional log info available in: /home/ghost-mgr/.ghost/logs/ghost-cli-debug-2023-04-04T21_02_16_115Z.log

Try running ghost doctor to check your system for known issues.

I also saw this topic:

But my port numbers do match, so I am not having the same issue as that developer.

Now, from running nginx, I’m getting:

nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2023/04/04 21:35:18 [warn] 7181#7181: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
2023/04/04 21:35:18 [emerg] 7181#7181: cannot load certificate key "/etc/letsencrypt/rbcse.ridvan.org/rbcse.ridvan.org.key": BIO_new_file() failed (SSL: error:0200100D:system library:fopen:Permission denied:fopen('/etc/letsencrypt/rbcse.ridvan.org/rbcse.ridvan.org.key','r') error:2006D002:BIO routines:BIO_new_file:system lib)

Alright I deleted two files:

/etc/nginx/sites-available$ sudo rm rbc.johnnypaycash.com.conf

and

ghost-mgr@rbcse:/etc/nginx/sites-available$ sudo rm rbc.johnnypaycash.com-ssl.conf

And I was able to reach the 502 nginx error with the domain, so I restarted ghost and it looks like we are back to original state! :grin: I can access the site from the original domain.

So the question remains, whats the proper work flow for migrating to another domain without a new server?

Hello,

I am new to Ghost but I think you forgot to update the domain in the nginx config after running ghost config url.

After you update the url in the ghost, you need to edit the nginx server config at /etc/nginx/sites-available/domain.com.conf and domain.com-ssl.conf. There change the server_name to the new domain and see if that solves the problem.

BTW, do not forget to change the filenames of domain.com.conf and domain.com-ssl.conf to newdomain.com.conf and newdomain.com-ssl.conf. And do not forget to setup SSL in the config for the new domain.

So then if I understand right steps would be:

  • point the new domain to the server with an a record
  • ghost config url ‘newurl’
  • change server_name to ‘newurl’ in /etc/nginx/sites-available/domain.com.conf and domain.com-ssl.conf
  • change the filenames of domain.com.conf and domain.com-ssl.conf to newdomain.com.conf and newdomain.com-ssl.conf
  • ghost setup ssl
  • ghost restart

If that does work, wouldn’t the expected behavior of ghost config url be to change the nginx config? In other words these steps:

  • change server_name to ‘newurl’ in /etc/nginx/sites-available/domain.com.conf and domain.com-ssl.conf
  • change the filenames of domain.com.conf and domain.com-ssl.conf to newdomain.com.conf and newdomain.com-ssl.conf
  • ghost setup ssl