How to Deploy Ghost with Caddy

Ghost is loved by bloggers, writers, and devs alike for its simplicity, clean design, and lightning-fast performance.

· 3 min read
How to Deploy Ghost with Caddy

Ghost is a popular choice for bloggers and developers due to its simplicity, clean design, and fast performance. Why settle for HTTP when you can secure your site with HTTPS? With Caddy, a web server that automatically handles SSL, you won’t have to deal with certificates manually. In this guide, I’ll show you how to deploy Ghost with Caddy using Docker, giving you a secure and scalable blog setup that’s fully optimized for SSL.

💡
Before we get rolling, make sure you install the prerequisits.
  • VPS with Ubuntu 20.04 (or another Linux distro if you prefer)
  • Docker and Docker Compose installed
  • A domain name pointing to your VPS's IP address (for HTTPS)

Step 1: Set Up Your Project Directory

Let's start by setting up a directory to keep things organized. This is where your Docker Compose and Caddy configuration files will live.

Open your terminal and run:

mkdir -p ~/ghost-deployment && cd ~/ghost-deployment


Done? Awesome. Now, all of your project files will stay in one clean, organized place.

Step 2: Create the Docker Compose File

Now let’s create a docker-compose.yml file. This file is the heart of our deployment—it tells Docker how to run Ghost and Caddy together.

Open up a new file called docker-compose.yml in your ghost-deployment folder and paste in this configuration:

services:
  ghost:
    image: ghost:latest
    container_name: ghost
    environment:
      url: https://your-domain.com  # <- Replace this with your domain
    volumes:
      - ./ghost_content:/var/lib/ghost/content
    networks:
      - web
    restart: always

  caddy:
    image: caddy:latest
    container_name: caddy
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
      - caddy_config:/config
    networks:
      - web
    restart: always

networks:
  web:

volumes:
  caddy_data:
  caddy_config:

Let’s break this down quickly:

  • Ghost service: This is your main blogging platform. We tell Ghost to use your-domain.com as its URL (replace that with your actual domain!).
  • Caddy service: Caddy will serve as the reverse proxy for Ghost, and it’ll handle SSL automatically.

Now, let’s set up Caddy’s configuration!

Step 3: Configuring Caddy for HTTPS

In your project directory, create a new file called Caddyfile. This file will tell Caddy how to handle traffic and manage HTTPS.

Inside Caddyfile, add the following:

Replace your-domain.com with your actual domain name. Here’s what’s happening in this file:

  • Caddy will automatically get an SSL certificate for your-domain.com and manage HTTPS for you.
  • The reverse_proxy line directs all traffic from https://your-domain.com to the Ghost service running on port 2368.
  • The encode gzip line compresses the data, making your blog load faster for readers.
💡
Pro tip: Caddy handles SSL certs automatically with Let’s Encrypt, so no need to worry about certificate renewals!

Step 4: Run Docker Compose

Now, it’s time to bring everything to life! Run the following command to start your Docker containers:

The -d flag starts the services in detached mode, so they’ll keep running in the background.

Docker will pull the images for Ghost and Caddy if you don’t already have them, and then it’ll launch the services. After a few seconds, your Ghost blog should be up and running, secured by HTTPS.

Step 5: Verify the Deployment

Let’s make sure everything’s working.

  1. Run docker-compose logs -f to check the logs and verify that both Ghost and Caddy started without any issues.
  2. Open your browser and go to https://your-domain.com.

If all went well, you should see the Ghost setup page!

Step 6: Set Up Ghost

With Ghost running, go through the setup wizard:

  1. Create an admin account – This will be your key to customizing and managing your blog.
  2. Configure your blog settings – Set up the blog title, description, and a custom logo if you have one.
  3. Start publishing!

Wrapping Up

Congratulations! You’ve successfully deployed Ghost with Caddy. Here’s what you’ve accomplished:

  • Deployed Ghost in Docker for a clean, isolated setup.
  • Configured Caddy as a reverse proxy with automatic HTTPS for enhanced security.
  • Got your blog live and ready for readers, without the hassle of SSL management.

This setup is ideal for blogging, but it’s also flexible if you want to expand. You can add more services to your Docker stack, customize your Ghost theme, or explore Caddy’s advanced configurations.

Happy blogging! 🚀