Setup ghost on raspberry - Caddy Reverse Proxy

I’m trying to host a ghost blog on a raspberry pi
I currently have ports 80 & 443 being forwarded to my server
Caddy is running on my server, and doing reverse proxy on a bunch of different services on my server

I tried setting up ghost with nginx and telling caddy to reverse proxy traffic to example.com through to the raspberry pi’s IP address and the ghost port, but that didn’t work

I’ve tried so many options I’ve started to forget what I’m actually trying to achieve
So I’d like to start from scratch with a clean ghost install, and a fresh caddy directive
How do I need to install and config ghost & associated things to work in this way?
I know it has something to do with my caddy server because all my web traffic is being forwarded to the server, so I need to send traffic from my server across to the raspberry pi

Hey @Ruskie

I can’t help you with configuring Caddy, but I can tell you that you’ll want to translate these nginx directives to Caddy:

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:<%= port %>;

Actually, I’m using caddy (v2) with just the directive:

reverse_proxy localhost:2378

According to caddy docs, it automatically adds/augments the X-Forwarded-For header, sets the X-Forwarded-Proto header, and passes the Host header unmodified.

@vikaspotluri123 - is there any reason to also set the X-Real-IP header? Do you know if/how that header is used by Ghost?

Note that if using any CDN like cloudflare, the $remote_addr will anyway not be of the actual user requesting the content, but the X-Forwarded-For header will contain the whole chain of forwards, including the original IP address.

According to caddy docs, it automatically adds/augments the X-Forwarded-For header, sets the X-Forwarded-Proto header, and passes the Host header unmodified.

The most important header is X-Forwarded-Proto! I just pulled all the headers that are used in the Ghost CLI + NGINX template. X-Real-IP might be used for Ghost’s request logging, but I’m not entirely sure

1 Like