Install Ghost blog on AWS lightsail Ubuntu server with CDN enabled

Original link: https://inote.xyz/ubuntu-ghost/

Install Ghost blog on AWS lightsail Ubuntu server with CDN enabled

In the previous article , deploying Ghost blog on Amazon Cloud Lightsail and enabling CDN , we used Bitnami-packaged images to deploy Ghost’s files on Lightsail. This time we use Ghost’s official recommended method to install and deploy Ghost on the AWS Lightsail Ubuntu host and configure the CDN.

  1. Follow the method How to install Ghost on Ubuntu on the Ghost official website to install the Ghost program correctly.
  2. We plan to use AWS to provide ssl certificate. Do you wish to set up SSL? (Y/n) in the SSL configuration link, choose n, skip using Let’s Encrypt certificate.
  3. Set up CDN: Select the instance corresponding to the instance as the data source in the “Networking” on the Lightsail homepage, select the instance corresponding to the instance as the data source, select “Best for WordPress” for the cache behavior (aws problem, advanced cache settings cannot be performed in other modes), and select “Do not cache any content” , first keep the default cache behavior, in the advanced cache settings, edit the “headers I specify”, set two new items X-Forwarded-Proto / X-Forwarded-For . Others remain the same.
  4. After the configuration is complete, use the assigned CDN default domain name to access, we see the nginx default page **Welcome to nginx!. **In order for the CDN to correctly obtain the origin site data, you can delete the nginx configuration file of the nginx default page, and configure the domain name to correspond to the nginx file.

    a. Delete the default file under /etc/nginx/sites-available

 cd /etc/nginx/sites-available sudo rm -rf default

b. Delete the default file under /etc/nginx/sites-enabled

 cd /etc/nginx/sites-enabled sudo rm -rf default

c. Since our nginx service is not directly oriented to end users, but behind the Lightsail CDN, and the ssl certificate is configured on the CDN, nginx cannot correctly obtain the protocol used by the client, resulting in the inability of the client to The protocol used is passed to ghost. Modify the nginx configuration to force the notification service to use the https protocol.

 cd /etc/nginx/sites-enabled sudo vim yourdomain.com.conf
 将`proxy_set_header X-Forwarded-Proto $scheme`修改成`proxy_set_header X-Forwarded-Proto https`
 location / {​ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;​ proxy_set_header X-Forwarded-Proto https;​ proxy_set_header X-Real-IP $remote_addr;​ proxy_set_header Host $http_host;​ proxy_pass http://127.0.0.1:2368; }

restart nginx

 sudo nginx -s reload

d. Modify the URL in the ghost configuration file

 cd /var/www/ghost sudo vim config.production.json
 { "url": "https://yourdomain.xyz", "server": { "port": 2368, "host": "127.0.0.1" },

re Ghost

 ghost restart
  1. Enable the custom domain name in the Lightsail CDN custom domain, resolve the domain name to the CDN in Lightsail CDN, and wait for the DNS resolution to take effect.
  2. Email, article, picture import refer to the previous article.

This article is reprinted from: https://inote.xyz/ubuntu-ghost/
This site is for inclusion only, and the copyright belongs to the original author.