Seadoc Server Caddy configuration

I’m running Seafile pro 11.04 (manual install on Ubuntu 22.04) with the latest Seadoc version. I had to open port 3306 on ufw, and set the bind_address to 0.0.0.0 in MySQL before Seadoc could connect to my database. I think it would be helpful to include this in the install notes because it took me awhile to figure out why it was unable to connect.

On a side note, I just updated from Ubuntu 20.04 to 22.04 yesterday. Seafile/Seahub worked with Python 3.12.2 on Ubuntu 20.04, but Seahub stopped working after I updated. I now have to set Python 3.10 as my default or Seahub fails to start.

The Seadoc converter works, and I can edit .md files, but whenever I open an sdoc file I get an error that the server has disconnected and I’m unable to do anything (see the below screenshot).

Here are my settings:

docker-compose.yml

services:
  sdoc-server:
    image: seafileltd/sdoc-server:latest
    container_name: sdoc-server
    ports:
      # - 80:80
      # - 443:443
      - 7070:7070
      - 8888:8888
    volumes:
      - '/opt/seafile/sdoc-data/:/shared'
    environment:
      - DB_HOST=127.0.0.1
      - DB_PORT=3306
      - DB_USER=seafile
      - DB_PASSWD=db-password
      - DB_NAME=sdoc-db
       - TIME_ZONE=UTC
       - SDOC_SERVER_LETSENCRYPT=false
       - SDOC_SERVER_HOSTNAME=sdoc.domain.com # ive also tried https://sdoc.domain.com
       - SEAHUB_SERVICE_URL=https://domain.com
     restart: always

caddy (for seadocs)

sdoc.domain.com {
  tls /etc/caddy/certs/*.domain.com/fullchain.cer
/etc/caddy/certs/*.domain.com/*.domain.com.key

  @options {
    method OPTIONS
  }
  header {
    Access-Control-Allow-Origin *
    Access-Control-Allow-Credentials true
    Access-Control-Allow-Methods *
    Access-Control-Allow-Headers *
    defer
  }
  reverse_proxy 127.0.0.1:7070 {
    header_down -Access-Control-Allow-Origin
  }
  respond @options 204

  handle_path /socket.io* {
    reverse_proxy 127.0.0.1:7070
  }
}

caddy (for Seafile)

domain.com {
  tls /etc/caddy/certs/*.domain.com/fullchain.cer
/etc/caddy/certs/*.domain.com/*.domain.com.key

reverse_proxy 127.0.0.1:8000

  handle_path /seafhttp* {
    reverse_proxy 127.0.0.1:8082
  }

  handle_path /media* {
    root *
/opt/seafile/seafile-server-latest/seahub/media

    file_server
  }
}

It is likely the proxy settings for socket.io not work correctly.

I’ve tried everything I can think of but haven’t been able to get it working, such as the following:

  handle_path /socket.io* {

    @websockets {
      header Connection *Upgrade*
      header Upgrade websockets
    }
    reverse_proxy @websockets 127.0.0.1:7070
    reverse_proxy 127.0.0.1:7070

}

I’ll try it with nginx tomorrow and see if it works. If it does, I’ll look for help on the caddy forums.

I was able to get Seadoc to work with nginx, although sdoc files do not work with iOS browsers. You can edit markdown files on your phone, and view sdoc files, but you can’t edit sdoc files.

I was able to get this to work with caddy by changing the socket.io configuration to the following:

  handle_path /socket.io* {
    rewrite * /socket.io{path}
    reverse_proxy localhost:7070
  }

Mobile editing does not supported yet.