This is a new install of ghost, version 2.29.1. I’m running nginx as my ssl layer and proxy. The url is https://blog.sharpsoftware.dev .
My configuration is as follows
{
"url": "https://blog.sharpsoftare.dev/",
"server": {
"port": 2368,
"host": "127.0.0.1"
},
"database": {
"client": "sqlite3",
"connection": {
"filename": "./content/data/ghost.db"
}
},
"mail": {
"transport": "Direct"
},
"logging": {
"transports": [
"file",
"stdout"
]
},
"process": "systemd",
"paths": {
"contentPath": "/home/website/blog/content"
}
}
Nginx configuration is
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl on;
ssl_certificate /root/blog.sharpsoftware.dev/fullchain.cer;
ssl_certificate_key /root/blog.sharpsoftware.dev/blog.sharpsoftware.dev.key;
server_name blog.sharpsoftware.dev;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
location / {
rewrite ^/route/?(.*)$ /$1 break;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:2368;
proxy_redirect off;
}
}
Which works with my other node servers.
The server works if I simply remove the “url” field in the config, but many of the links and images end up broken without that value so I’m trying to figure this out before I try to bring it online for real. I like ghost as I’ve used it before, but this issue has me stumped.
Additionally, there is no 301 redirect if I take down the ghost server and nginx shows the gateway failure as expected. If I connect directly to ghost locally, I still see the 301.
You’re missing the X-Forwarded-Proto header
See the default nginx template:
Running into same problem on Ubuntu 18.04 and 20.04 (containers).
nginx runs on 18.04, and initially I installed ghost on the same container, then I tried creating a fresh container for ghost following your instructions (though I also installed Yarn per the instructions presented after installing node 14). 20.04 does not have local nginx, I changed listen IP in config.production.json from 127.0.0.1 to 0.0.0.0.
location ^~ /~bam {
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://172.22.20.220:2368;
proxy_redirect off;
}
$ sudo -u ghost node /usr/bin/ghost run -V
The `ghost run` command is used by the configured Ghost process manager and for debugging. If you're not running this to debug something, you should run `ghost start` instead.
[2021-08-19 20:19:40] INFO Ghost is running in production...
[2021-08-19 20:19:40] INFO Your site is now available on https://sophiasolutions.org/~bam/
[2021-08-19 20:19:40] INFO Ctrl+C to shut down
[2021-08-19 20:19:40] INFO Ghost server started in 0.267s
[2021-08-19 20:19:41] INFO Database is in a ready state.
[2021-08-19 20:19:41] INFO Ghost database ready in 0.455s
[2021-08-19 20:19:42] INFO Ghost booted in 1.959s
[2021-08-19 20:19:42] INFO Adding offloaded job to the queue
[2021-08-19 20:19:42] INFO Scheduling job update-check at 44 3 22 * * *. Next run on: Thu Aug 19 2021 22:03:44 GMT+0000 (Coordinated Universal Time)
[2021-08-19 20:22:53] INFO "GET /~bam/ghost/" 301 9ms
[2021-08-19 20:22:53] INFO "GET /~bam/ghost/" 301 5ms
[2021-08-19 20:22:53] INFO "GET /~bam/ghost/" 301 1ms
[2021-08-19 20:22:53] INFO "GET /~bam/ghost/" 301 1ms
[2021-08-19 20:22:54] INFO "GET /~bam/ghost/" 301 2ms
[2021-08-19 20:22:54] INFO "GET /~bam/ghost/" 301 3ms
[2021-08-19 20:22:54] INFO "GET /~bam/ghost/" 301 2ms
[2021-08-19 20:22:54] INFO "GET /~bam/ghost/" 301 3ms
[2021-08-19 20:22:54] INFO "GET /~bam/ghost/" 301 2ms
[2021-08-19 20:22:54] INFO "GET /~bam/ghost/" 301 2ms
[2021-08-19 20:22:54] INFO "GET /~bam/ghost/" 301 3ms
[2021-08-19 20:22:54] INFO "GET /~bam/ghost/" 301 2ms
[2021-08-19 20:22:54] INFO "GET /~bam/ghost/" 301 3ms
[2021-08-19 20:22:54] INFO "GET /~bam/ghost/" 301 3ms
[2021-08-19 20:22:54] INFO "GET /~bam/ghost/" 301 2ms
[2021-08-19 20:22:54] INFO "GET /~bam/ghost/" 301 3ms
[2021-08-19 20:22:55] INFO "GET /~bam/ghost/" 301 11ms
[2021-08-19 20:22:55] INFO "GET /~bam/ghost/" 301 2ms
[2021-08-19 20:22:55] INFO "GET /~bam/ghost/" 301 3ms
[2021-08-19 20:22:55] INFO "GET /~bam/ghost/" 301 2ms
[2021-08-19 20:22:55] INFO "GET /~bam/ghost/" 301 1ms
Bash history for new Ubuntu 20.04 container:
$ cat ~/.bash_history
sudo ufw allow 2368
sudo ufw allow 22/tcp
sudo ufw enable
sudo apt update
sudo apt upgrade
sudo apt install mariadb-server
sudo mysql -uroot
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt install nodejs yarn gcc g++ make
sudo npm install ghost-cli@latest -g
sudo mkdir -p /var/ghost/bam
cd /var/ghost/bam
sudo chown ubuntu:ubuntu .
ghost install
ls
vi config.production.json
sudo systemctl restart ghost_sophiasolutions-org.service
Edit:
Edit2: Container host is Ubuntu 20.04. Edit3: My mistake, host is Ubuntu 19.10!
Fresh Ubuntu 20.04.3 on Tyan S8010 with Opteron 4280 and fresh container per above instructions, same result.
Edit: first computer is ThinkCentre M83 with i5 4570
My mistake. Double reverse proxy, so not setting X-* headers on intermediate proxy fixed it.
location ^~ /~bam {
proxy_set_header Host $http_host;
proxy_pass http://172.22.20.220:2368;
proxy_redirect off;
}
Edit: confirmed X-* header passthrough with netcat.