How to: Seafile Server(7.0.5) on docker(NAS) behind router (custom port)

Hey there,
i just managed to set up my Seafile Server on docker and i thought: it wasn’t just that straight forward.

So my old Server(Raspi2) refused to resolve DNS after a update… So i wanted to move the Seafile-Server to my NAS which has more power and much more storage. So the journey bagan…
I’ve tried to move my old Server data also to the new Cloud, but that i gave up after a while… Every one had it’s data also on his local drive and missed nothing so everyone could start over with a nice clean account :wink:

i’m not allowed to post links because of that they are cut in pieces…

The setup looks like this:
Internet <-> Router <-> NAS(Seafile)
I also wanted to access my Router from the internet and so i wanted to make the SeafileServer available under MY.DOMAIN. COM:1234

I started with the “deploy seafile with docker” https:// download.seafile. com/ published/seafile-manual/docker/deploy%20seafile%20with%20docker.md

I downloaded the docker-compose.yml and edited it a bit

version: '3.2'
services:
  db:
    image: mariadb:10.1
    container_name: seafile-mysql
    environment:
      - MYSQL_ROOT_PASSWORD=SECRET # Requested, set the root's password of MySQL service.
      - MYSQL_LOG_CONSOLE=true
    volumes:
      - db:/var/lib/mysql
    networks:
      - seafile-net

  memcached:
    image: memcached:1.5.6
    container_name: seafile-memcached
    entrypoint: memcached -m 256
    networks:
      - seafile-net
          
  seafile:
    image: seafileltd/seafile-mc:latest
    container_name: seafile
    ports:
      - "1233:80"
      - "1234:443"  # If https is enabled, cancel the comment.
    volumes:
      - data:/shared   # Requested, specifies the path to Seafile data persistent store.
      - templates:/templates
    environment:
      - DB_HOST=db
      - DB_ROOT_PASSWD=SECRET # Requested, the value shuold be root's password of MySQL service.
      - TIME_ZONE=Etc/UTC  # Optional, default is UTC. Should be uncomment and set to your local time zone.
      - SEAFILE_ADMIN_EMAIL=MyMail@gmail.com # Specifies Seafile admin user, default is 'me@example.com'.
      - SEAFILE_ADMIN_PASSWORD=asecret     # Specifies Seafile admin password, default is 'asecret'.
      - SEAFILE_SERVER_LETSENCRYPT=true   # Whether to use https or not.
      - SEAFILE_SERVER_HOSTNAME=MY.DOMAIN.COM # Specifies your host name if https is enabled.
    depends_on:
      - db
      - memcached
    networks:
      - seafile-net

volumes:
  db:
    external:
      name: seaf-db
  data:
    external:
      name: seaf-data
  templates:
    external:
      name: seaf-templates

networks:
  seafile-net:

I added a few volumes defined at the bottom of the file:
db: for the Maria/MySQL db. db is linked to the external name seaf-db
data: for the data directory of Seafile. data -> seaf-data
templates: for the template dir. templates -> seaf-templates
The templates is neede because every time the server restarts the nginx config is recreated. And so the port which i added there…
Syntax and spaces are in this file important!
you should modify the following lines:

- MYSQL_ROOT_PASSWORD=SECRET

- "1233:80"
- "1234:443"

- DB_ROOT_PASSWD=SECRET
- SEAFILE_ADMIN_EMAIL=MyMail@SomeMail.com
- SEAFILE_SERVER_HOSTNAME=MY.DOMAIN.COM

First things first:
Create the named volumes. I did it with Portainer.
On the commandline it should be something like:

docker volume create seaf-db

Next we need to set up the router, we need Port 80 for lets encrypt and Port 1234.
Port 80 needs to be accessible for Let’s encrypt to get your certificate,
and Port 1234 is your chosen Port at which your server will be accessible.
(About Let’s encrypt: there is mentioned that you can place your own certificate in /opt/seafile-data/ssl but that did not work for me…)

We need to get the templates:
https:// github. com/haiwen/seafile-docker/tree/master/image/seafile/templates

You need both files. Just download both of them.
In seafile.nginx.conf.template you need to make a little tweak:

    location / {
        proxy_pass http://127.0.0.1:8000/;
        proxy_read_timeout 310s;
        proxy_set_header Host $host;

to

    location / {
        proxy_pass http://127.0.0.1:8000/;
        proxy_read_timeout 310s;
        proxy_set_header Host $host:1234;

for that you will need to find the data folder of your previous created seaf-templates volume. Portainer showed it to me…
it will be something like:

/Path/To/docker-ce/docker_lib/volumes/seaf-templates/_data

After that we need to execute this command where we saved the docker-compose.yaml:

docker-compose up -d

After your server has launched you need to modify

vi conf/seahub_settings.py

And change

FILE_SERVER_ROOT = "https://MY.DOMAIN.COM/seafhttp"

to

FILE_SERVER_ROOT = "https://MY.DOMAIN.COM:5627/seafhttp"

vi conf/ccnet.conf
here you need to set URI and the port like:

SERVICE_URL = "https://MY.DOMAIN.COM:5627"

With a

docker-compose restart

should your server be ready :wink:

I hope this short guide will save someones time :wink:

Greetings MadMe86

1 Like

Please submit a merge request to the community manual.

sorry did you mean 1234 instead of 5627? where is 5627 coming from?

I am not sure it makes sense to reopen a thread that is two years ago. The participants probably don’t remember the situation.

its been a long time… but i still remember a bit.
I think 5627 is the standard port of seafile and i just wanted to show that you dont need to use this port… but it seems i forgot change this in the last part…
I also didn’t used this setup very long, because i got myself a real domain and not some of my router. So i could get a subdomain for every service that should be accessible from the internet, instead of ports.
I would now recommend that and a domain itself doesn’t cost very much(<10€/a).
For that i used the letsencrypt proxy companion.

Greetings MadMe