SeafileDocs behind nginx (several other Docker images installed)

seafiledocs

#1

Hi

I am trying to run SeafileDocs via docker.

I am following this manual (which strangley only opens on my iPhone but not on an iPad or Macbook? (30 March 2019)).

https://docs.seafile.com/wikis/seafiledocs-admin-manual-en/home.md

I think my problem is that I do already have other docker container installed on this machine. That means that

  • the ports that SeafileDocs docker image would like to use for the databases and memcached are already in use.
  • HTTPS should not work within the seafile container but I would run it on the “Mother-System” in Nginx.

Using the following docker-compose does not work.
Does the seafile docker image maybe not use the forwarded ports that I chose?
Is there a manual that explains how SeafileDocs Docker image can run behind nginx?

version: '2.0'
services:
  db:
    image: mariadb:10.3
    container_name: seafile-docs-mysql
    ports:
      - 23306:3306
    environment:
      - MYSQL_ROOT_PASSWORD=db_dev  # Set the root's password of MySQL service.
      - MYSQL_LOG_CONSOLE=true
    volumes:
      - /opt/seafiledocs/mysql-data:/var/lib/mysql  # Specify the data directory of MySQL.

  memcached:
    image: memcached:1.4-alpine
    container_name: seafile-docs-memcached
    ports:
      - 11311:11211
          
  seafile:
    image: seafileltd/seafile-docs:latest
    container_name: seafile-docs
    ports:
      - 20080:80
#      - 443:443  # If https is enabled, cancel the comment.
    volumes:
      - /opt/seafiledocs/seafile-data/:/shared/seafile  
    environment:
      - DB_HOST=db
      - DB_ROOT_PASSWD=db_dev
      - SEAFILE_ADMIN_EMAIL=admin@example.com 
      - SEAFILE_ADMIN_PASSWORD=xyz    
      - SEAFILE_SERVER_LETSENCRYPT=false  
      - SEAFILE_SERVER_HOSTNAME=docs.example.com
    depends_on:
      - db
      - memcached 

My Nginx config file looks like this:

server {
  listen 443 ssl http2;
  listen [::]:443 http2 ssl;
  server_name docs.example.com;

  ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
  ssl_certificate /etc/letsencrypt/live/docs.example.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/docs.example.com/privkey.pem;


  proxy_set_header X-Real-IP $remote_addr;

  location / {
    proxy_pass http://localhost:20080;
    proxy_read_timeout 310s;
    proxy_set_header Host $host;
    proxy_set_header Forwarded "for=$remote_addr;proto=$scheme";
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Connection "";
    proxy_http_version 1.1;
  }
}

#2

Should I create a dedicated docker network first to make this work?

It’s probaly not a Seafile issue, but the current manual is not really helpful this way?


#3

Hmmm, I am not moving forward.

I am getting this error message when starting up Seafile.

I changed the port for the Database from 3306:3306 to 3310:3306.
And I changed the ports in the seafile-data folder in ccnet.conf, seafile.conf, seahubsetting.py to 3310.

What else should I do to avoid the error below.

root@mx /opt/seafiledocs/seafile-data # docker-compose restart
Restarting seafile-docs           ... done
Restarting seafile-docs-mysql     ... done
Restarting seafile-docs-memcached ... done
root@mx /opt/seafiledocs/seafile-data # docker-compose stop
Stopping seafile-docs-mysql     ... done
Stopping seafile-docs-memcached ... done
root@mx /opt/seafiledocs/seafile-data # docker-compose up
Starting seafile-docs-mysql     ... done
Starting seafile-docs-memcached ... done
Starting seafile-docs           ... done
Attaching to seafile-docs-memcached, seafile-docs-mysql, seafile-docs
seafile-docs | *** Running /etc/my_init.d/10_syslog-ng.init...
seafile-docs | Apr  5 14:14:09 771539b8e5cb syslog-ng[11]: syslog-ng starting up; version='3.13.2'
seafile-docs | *** Booting runit daemon...
seafile-docs | *** Runit started as PID 17
seafile-docs | *** Running /scripts/start.py...
seafile-docs-mysql | 2019-04-05 14:14:08 0 [Note] mysqld (mysqld 10.3.13-MariaDB-1:10.3.13+maria~bionic) starting as process 1 ...
seafile-docs-mysql | 2019-04-05 14:14:08 0 [Note] InnoDB: Using Linux native AIO
seafile-docs-mysql | 2019-04-05 14:14:08 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
seafile-docs-mysql | 2019-04-05 14:14:08 0 [Note] InnoDB: Uses event mutexes
seafile-docs-mysql | 2019-04-05 14:14:08 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
seafile-docs | Apr  5 14:14:09 771539b8e5cb cron[22]: (CRON) INFO (pidfile fd = 3)
seafile-docs-mysql | 2019-04-05 14:14:08 0 [Note] InnoDB: Number of pools: 1
seafile-docs-mysql | 2019-04-05 14:14:08 0 [Note] InnoDB: Using SSE2 crc32 instructions
seafile-docs | Apr  5 14:14:09 771539b8e5cb cron[22]: (CRON) INFO (Skipping @reboot jobs -- not system startup)
seafile-docs-mysql | 2019-04-05 14:14:08 0 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
seafile-docs-mysql | 2019-04-05 14:14:08 0 [Note] InnoDB: Completed initialization of buffer pool
seafile-docs-mysql | 2019-04-05 14:14:08 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
seafile-docs-mysql | 2019-04-05 14:14:09 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
seafile-docs-mysql | 2019-04-05 14:14:09 0 [Note] InnoDB: Creating shared tablespace for temporary tables
seafile-docs-mysql | 2019-04-05 14:14:09 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
seafile-docs-mysql | 2019-04-05 14:14:09 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
seafile-docs-mysql | 2019-04-05 14:14:09 0 [Note] InnoDB: Waiting for purge to start
seafile-docs-mysql | 2019-04-05 14:14:09 0 [Note] InnoDB: 10.3.13 started; log sequence number 3123162; transaction id 1079
seafile-docs-mysql | 2019-04-05 14:14:09 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
seafile-docs-mysql | 2019-04-05 14:14:09 0 [Note] Plugin 'FEEDBACK' is disabled.
seafile-docs-mysql | 2019-04-05 14:14:09 0 [Note] Server socket created on IP: '::'.
seafile-docs-mysql | 2019-04-05 14:14:09 0 [Warning] 'user' entry 'root@db' ignored in --skip-name-resolve mode.
seafile-docs-mysql | 2019-04-05 14:14:09 0 [Warning] 'proxies_priv' entry '@% root@dbf59b913ac7' ignored in --skip-name-resolve mode.
seafile-docs-mysql | 2019-04-05 14:14:09 0 [Note] Reading of all Master_info entries succeded
seafile-docs-mysql | 2019-04-05 14:14:09 0 [Note] Added new Master_info '' to hash table
seafile-docs-mysql | 2019-04-05 14:14:09 0 [Note] mysqld: ready for connections.
seafile-docs-mysql | Version: '10.3.13-MariaDB-1:10.3.13+maria~bionic'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
seafile-docs | [2019-04-05 14:14:09] Skip running setup-seafile-mysql.py because there is existing seafile-data folder.
seafile-docs | [04/05/2019 14:14:09][upgrade]: The container was recreated, running minor-upgrade.sh to fix the media symlinks
seafile-docs | [04/05/2019 14:14:09][upgrade]: Running script /opt/seafile/seafile-server-1.2.0/upgrade/minor-upgrade.sh
seafile-docs | 
seafile-docs | -------------------------------------------------------------
seafile-docs | This script would do the minor upgrade for you.
seafile-docs | Press [ENTER] to contiune
seafile-docs | -------------------------------------------------------------
seafile-docs | 
seafile-docs | 
seafile-docs | ------------------------------
seafile-docs | migrating avatars ...
seafile-docs | 
seafile-docs | 
seafile-docs | DONE
seafile-docs | ------------------------------
seafile-docs | 
seafile-docs | 
seafile-docs | updating seafile-server-latest symbolic link to /opt/seafile/seafile-server-1.2.0 ...
seafile-docs | 
seafile-docs | DONE
seafile-docs | ------------------------------
seafile-docs | 
seafile-docs | 
seafile-docs | failed to run "ccnet-server -t"
seafile-docs | [04/05/19 14:14:09] ../common/session.c(132): using config file /opt/seafile/conf/ccnet.conf
seafile-docs | [04/05/19 14:14:09] ../common/ccnet-db.c(124): Failed to get database connection: Failed to connect to MySQL: Can't connect to MySQL server on 'db' (111).
seafile-docs | [04/05/19 14:14:09] user-mgr.c(769): Failed to create user db tables.
seafile-docs | Traceback (most recent call last):
seafile-docs |   File "/scripts/start.py", line 86, in <module>
seafile-docs |     main()
seafile-docs |   File "/scripts/start.py", line 71, in main
seafile-docs |     call('{} start'.format(get_script('seafile.sh')))
seafile-docs |   File "/scripts/utils/__init__.py", line 69, in call
seafile-docs |     return subprocess.check_call(*a, **kw)
seafile-docs |   File "/usr/lib/python2.7/subprocess.py", line 190, in check_call
seafile-docs |     raise CalledProcessError(retcode, cmd)
seafile-docs | subprocess.CalledProcessError: Command '/opt/seafile/seafile-server-1.2.0/seafile.sh start' returned non-zero exit status 1
seafile-docs | *** /scripts/start.py exited with status 1.
seafile-docs | *** Shutting down runit daemon (PID 17)...
seafile-docs | *** Running /etc/my_init.post_shutdown.d/10_syslog-ng.shutdown...
seafile-docs | Apr  5 14:14:10 771539b8e5cb syslog-ng[11]: syslog-ng shutting down; version='3.13.2'
seafile-docs-mysql | 2019-04-05 14:14:10 0 [Note] InnoDB: Buffer pool(s) load completed at 190405 14:14:10
seafile-docs | *** Killing all processes...
seafile-docs exited with code 1

#4

Do I have to adjust the fileserver port when I have a normal seafile instance running on the same server?

root@mx /opt/seafiledocs/seafile-data/conf # cat seafile.conf
[fileserver]
port = 8082

[database]
type = mysql
host = db
port = 3310
user = root
password = db_dev
db_name = seafile_db
connection_charset = utf8


#5

You forgot the connection upgrade statement in your nginx config file. Here is the config for my gitlab container, also nginx on top of nginx. Should help you, just look for the map statement in the last few lines.


#6

Thanks for your help, Bionade24.

I added that Upgrade section but the actual fix was that I had to enable the https option in the YML file.
I thought I had to keep it disabled because I already have the SSL certificates ready on the Nginx on “Host system level”.

I am not sure if if the seafile container now also tries to get letsencrypt certificates? But it works now somehow.

A bit more documentation on the Docker installation would be cool! :wink:


#7

Think this is just for the links in the program, you have to letsencrypt in the docker cli

Seafile’s containers aren’t made well.