Question: How to define custom location block (e.g. /.ghost/*) via Traefik instead of Caddy?

Hey y’all — excited to be testing the new Ghost Docker setup!

I understand there are happy paths to prioritize so please ignore this unless you happen to know the fix or can point me in a good direction.

Background: I am coming from an existing setup in Coolify which uses Traefik as the reverse proxy (it can do caddy, but I’d like to stick with Traefik if possible). Prior to Traefik + Coolify, I was using nginx to expose Ghost and pass through requests to my selfhosted activitypub service via a custom nginx location block.

I have not yet figured out the magic traefik dynamic configuration file to manually add or traefik labels to apply to my coolify compose file.

Anyone have suggestions or examples on how to set up a path-based route for the proxied request in this new setup in Traefik? For selfhosted activity pub service or the hosted ap.ghost.org?

Thanks in advance!

Figured it out and it works! Added the following labels to my ghost service and cleared my cache in chrome (right-click refresh button).

labels:
      # Local ActivityPub service definition
      - "traefik.http.services.activitypub-local.loadbalancer.server.port=8080"
      
      # Main ActivityPub router - simple passthrough
      - "traefik.http.routers.activitypub-ghost.rule=Host(`$SERVICE_FQDN_GHOST_2368`) && PathPrefix(`/.ghost/activitypub`)"
      - "traefik.http.routers.activitypub-ghost.priority=300"
      - "traefik.http.routers.activitypub-ghost.service=activitypub-local"
      - "traefik.http.routers.activitypub-ghost.entrypoints=https"
      - "traefik.http.routers.activitypub-ghost.tls=true"
      - "traefik.http.routers.activitypub-ghost.tls.certresolver=letsencrypt"
      
      - "traefik.http.routers.activitypub-webfinger.rule=Host(`$SERVICE_FQDN_GHOST_2368`) && Path(`/.well-known/webfinger`)"
      - "traefik.http.routers.activitypub-webfinger.priority=300"
      - "traefik.http.routers.activitypub-webfinger.service=activitypub-local"
      - "traefik.http.routers.activitypub-webfinger.entrypoints=https"
      - "traefik.http.routers.activitypub-webfinger.tls=true"
      - "traefik.http.routers.activitypub-webfinger.tls.certresolver=letsencrypt"
      
      - "traefik.http.routers.activitypub-nodeinfo.rule=Host(`$SERVICE_FQDN_GHOST_2368`) && Path(`/.well-known/nodeinfo`)"
      - "traefik.http.routers.activitypub-nodeinfo.priority=300"
      - "traefik.http.routers.activitypub-nodeinfo.service=activitypub-local"
      - "traefik.http.routers.activitypub-nodeinfo.entrypoints=https"
      - "traefik.http.routers.activitypub-nodeinfo.tls=true"
      - "traefik.http.routers.activitypub-nodeinfo.tls.certresolver=letsencrypt"
2 Likes

Ok so the above worked well for my demo site + new selfhosted activitypub service.

Also confirmed this works pointed to ap.ghost.org. To do this in coolify I added the following dynamic config to traefik proxy as a file named activitypub.yaml

http:
  routers:
    activitypub-ghost:
      rule: 'Host(`example-ghost-site.com`) && PathPrefix(`/.ghost/activitypub`)'
      service: ap-ghost-external
      entryPoints:
        - https
      priority: 500
      tls:
        certResolver: letsencrypt
    activitypub-webfinger:
      rule: 'Host(`example-ghost-site.com`) && Path(`/.well-known/webfinger`)'
      service: ap-ghost-external
      entryPoints:
        - https
      priority: 500
      tls:
        certResolver: letsencrypt
    activitypub-nodeinfo:
      rule: 'Host(`example-ghost-site.com`) && Path(`/.well-known/nodeinfo`)'
      service: ap-ghost-external
      entryPoints:
        - https
      priority: 500
      tls:
        certResolver: letsencrypt
  services:
    ap-ghost-external:
      loadBalancer:
        servers:
          -
            url: 'https://ap.ghost.org'
        passHostHeader: true

And finally, I attached the dynamic config to my existing ghost server:

labels:
  - "traefik.http.routers.ghost.middlewares=activitypub@file"

Notes:

  • The activitypub table had to be manually created, migration wouldn’t work prior to that.
    • If I did selfhost, I’d probably setup activitypub as a separate instance with either it’s own mysql or the one serving my ghost sites.
2 Likes

Nice! Glad you could get this working. Did you have any other issues getting Traefik going for AP?

I’m not sure we’ll officially support it at this stage but good to know its working.

No issues, so far so good :+1:

This is for the activity pub hosted by ghost right?

Do you know what needs to change when you also self-host the activity pub instance?

Just found a blog post showing the traefik labels for the self hosted and ghost hosted activity pub version: