Gabe Rocks!

🖥️ Tech

🤔 Rambling

🐷 Health

Migrating self-hosted Ghost 5 to 6 and getting Activitypub to work

The long awaited Ghost 6.0 is OUT! This version is the much-anticipated update that allows self-hosters to use “the social web” with their Ghost websites. This is pretty good news, but for me it was quite a headache. I had already migrated one of my websites Canadian Cyber Freedom to Ghost in anticipation for this particular update. It seems that Ghost didn’t integrate activitypub support into ghost directly (which seems like an odd choice) but instead requires two new containers (and multiple others for their analytics support).

Unfortunately, none of this is clear when you just upgrade your Ghost container to version 6. Social web support will appear to be on, but it won’t actually work. I immediately checked the documentation and it says you just need to update your environment variables. Which lead me to realizing that I needed to configure additional containers by checking the new docker-compose.yaml file. Counter to the official recommendation I’m running Mariadb instead of mysql, this is a HARD STOP for the activitypub-migrate container, so if you’re doing that too you’ll need to setup a new mysql container just for activitypub support.

I hope people who are stuck on trying to get federation via Ghost might find this post helpful. Once you’re setting this up, it’s important to clear cache & cookies regularly until you’ve confirmed it’s working. If you can load the new parts of Ghost after logging in to an incognito tab, you’ve configured everything correctly.

Changes

Nginx change

You’re going to need to make sure fediverse requests are handled by the activitypub container. The port I chose was arbitrary, but you can configure your own in the compose file.

Here are my settings:

  location ~ /.ghost/activitypub/* {
    proxy_pass http://localhost:2369;
    proxy_set_header X-Forwarded-For $remote_addr;
    add_header Access-Control-Allow-Origin *;
    proxy_set_header Host $host;
  }
 location ~ /.well-known/(webfinger|nodeinfo) {
    proxy_pass http://localhost:2369;
    proxy_set_header X-Forwarded-For $remote_addr;
    add_header Access-Control-Allow-Origin *;
    proxy_set_header Host $host;
  }

Docker-compose changes

You need to add the two new containers to your docker-compose.yaml and configure the correct DB. activitypub-migrate just needs to do its work, so you can just re-launch it with docker-compose up or docker-compose restart activitypub-migrate when needed.

activitypub:
    image: ghcr.io/tryghost/activitypub:edge
    restart: always
    volumes:
      - ./ap_uploads:/opt/activitypub/content
    ports:
      - 2369:2369
    environment:
      PORT: 2369
      NODE_ENV: production
      MYSQL_HOST: mysql
      MYSQL_USER: root
      MYSQL_PASSWORD: YOUR_PASSWORD_HERE
      MYSQL_DATABASE: activitypub
      LOCAL_STORAGE_PATH: /opt/activitypub/content/images/activitypub
      LOCAL_STORAGE_HOSTING_URL: https://YOUR_WEBSITE/content/images/activitypub
    depends_on:
      - mysql
  activitypub-migrate:
    image: ghcr.io/tryghost/activitypub-migrations:edge
    environment:
      MYSQL_DB: mysql://root:YOUR_PASSWORD_HERE@tcp(mysql:3306)/activitypub
    depends_on:
      - mysql

Useful Resources:

Known Instances

Any website served by ghosts hosted service should already be accessible. You can now follow these sites via the fediverse by their @index@example.com handle. But I’m concerned that self-hosted set-ups will run into the issues that I did. I noticed that @sam@sambent.com works great, but @index@www.citationneeded.news

You can test if the self-hosted ghost instance has activitypub configured by going to example.com/.ghost/activitypub/users/index/ and seeing if you get a reply or an error.


Reply to this post

Ghost Fediverse Docker Nginx Self-Hosting
Prev B @ Next