Notification server behind caddy

i’m running seafile 11.0.5 behind a caddy webserver. i’m having trouble adjusting the notification server configuration to my Caddyfile.

i have this in my seafile.conf:

[notification]
enabled = true
host = 127.0.0.1
port = 8083
log_level = info
jwt_private_key = <private key>

and currently this in my Caddyfile:

seafile.example.com:<port> {
  handle /seafile* {
    reverse_proxy http://127.0.0.1:8000
  }

  handle_path /notification* {
    reverse_proxy http://127.0.0.1:8083
  }

  handle_path /seafhttp* {
    reverse_proxy http://127.0.0.1:8082
  }

  handle_path /seafmedia* {
    rewrite * /media{uri}
    root * /srv/seafile/seafile-server-latest/seahub
    file_server
  }

  handle_path /seafdav* {
    reverse_proxy http://127.0.0.1:8080
  }
}

it all works fine, except for the notification server. all i get is an error that the page could not be found if i requested https://seafile.example.com:<port>/seafile/notification/ping/ or https://seafile.example.com:<port>/notification/ping/.

note that seafile is configured to use both a custom port and a non-root subfolder. i tried prefixing the handle with the subfolder, still no success. has anyone successfully configured this with caddy yet?

i’ve made some progress. i’ve placed the notification section at the beginning, i.e., before handle /seafile*, and it now reads:

  handle_path /seafile/notification/* {
    @websockets {
      header Connection *Upgrade*
      header Upgrade    websocket
    }
    reverse_proxy @websockets http://127.0.0.1:8083
  }

this at least does not throw errors any longer when https://seafile.example.com:<port>/seafile/notification/ping/ is visited. however, i don’t get the {"ret": "pong"} reply that querying http://127.0.0.1:8083/ping locally gives.

Did you ever find a solution @m.eik ?

I just solved this myself. I do not use the caddy from seafile, but my own, because I host multiple services on this machine. Therefore, I translated the caddy labels from the notification-server.yml to Caddyfile syntax. Afterward I deleted the labels from the notification-server.yml and added the notification-server to my reverse proxy network.

services:
  notification-server:
    image: ${NOTIFICATION_SERVER_IMAGE:-seafileltd/notification-server:12.0-latest}
    container_name: notification-server
[...]
    networks:
      - seafile-net
      - reverse-proxy

networks:
  seafile-net:
    external: true
  reverse-proxy:
    external: true

This is my the relevant part of my Caddyfile:

files.{$DOMAIN-MKF} {
    import hsts
    reverse_proxy seafile:80

    @ws {
        header Connection *Upgrade*
        header Upgrade websocket
    }
    reverse_proxy @ws notification-server:8083
    
    handle_path /notification* {
        rewrite * {uri}
        reverse_proxy notification-server:8083
    }
}

This is the URL test:
grafik

And this is the relevant entry from my local Windows Seafile client log file:

[02/09/25 18:14:23] starting seafile client 9.0.11
[02/09/25 18:14:23] client id = 111222333, client_name = Gaming-PC
[02/09/25 18:14:23] rpc server started.
[02/09/25 18:14:24] start to serve on pipe client
[02/09/25 18:14:24] start to serve on pipe client
[02/09/25 18:14:24] start to serve on pipe client
[02/09/25 18:14:24] start to serve on pipe client
[02/09/25 18:14:25] File syncing protocol version on server https://files.home.net is 2. Client file syncing protocol version is 2. Use version 2.
[02/09/25 18:14:25] start to serve on pipe client
[02/09/25 18:14:25] start to serve on pipe client
[02/09/25 18:14:25] start to serve on pipe client
[02/09/25 18:14:25] start to serve on pipe client
[02/09/25 18:14:26] Repo 'Meine Bibliothek' sync state transition from 'synchronized' to 'committing'.
[02/09/25 18:14:26] Notification server is enabled on the remote server https://files.home.net.
[02/09/25 18:14:26] All events are processed for repo 111-3829-4e11-333-444.
[02/09/25 18:14:26] Repo 'Meine Bibliothek' sync state transition from 'committing' to 'initializing'.

Hope this will help somebody!

oh, great! can’t wait to try implementing this :slight_smile:

i’m quite excited that seafile has officially moved to using caddy itself, i hope this will get us better support in the future.

@m.eik Do you mind marking my answer as a solution? This will help others in the future, thank you!

sorry for the late reply, i wasn’t able to try it until today. based on your solution my caddyfile now looks like this and seems to actually work! thanks again :slight_smile:

seafile.example.com:<port> {
  @websockets {
    header Connection *Upgrade*
    header Upgrade    websocket
  }
  reverse_proxy @websockets http://127.0.0.1:8083

  handle_path /seafile/notification* {
    rewrite * {uri}
    reverse_proxy http://127.0.0.1:8083
  }

  handle /seafile* {
    reverse_proxy http://127.0.0.1:8000
  }

  handle_path /seafhttp* {
    reverse_proxy http://127.0.0.1:8082
  }

  handle_path /seafmedia* {
    rewrite * /media{uri}
    root * /srv/seafile/seafile-server-latest/seahub
    file_server
  }

  handle_path /seafdav* {
    reverse_proxy http://127.0.0.1:8080
  }
}