commit ed662df834be7b9201339926a8d958b55067d181 Author: meliurwen Date: Mon Mar 29 11:21:01 2021 +0200 Fully working with custom nginx conf behind an existing reverse proxy diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..900abce --- /dev/null +++ b/.env.example @@ -0,0 +1,24 @@ +# Global Settings +LOCAL_STACK_DIR=/srv/docker/volumes/seafile + +# Networks +NETWORK= + +# Seafile +SF_IMG= +SF_TAG= +SF_CONTAINER_NAME= +SF_RESTART= + +# Database +DB_IMG= +DB_TAG= +DB_CONTAINER_NAME= +DB_RESTART= +DB_ROOT_PASSWD= + +# Memcached +MC_IMG= +MC_TAG= +MC_CONTAINER_NAME= +MC_RESTART= diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..03bd412 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.env diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..4407f13 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,50 @@ +version: '3' + +services: + db: + image: ${DB_IMG:-mariadb}:${DB_TAG:-latest} + container_name: ${DB_CONTAINER_NAME:-seafile-db} + restart: ${DB_RESTART:-unless-stopped} + environment: + - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWD:-changemeplease} + - MYSQL_LOG_CONSOLE=true + volumes: + - ${LOCAL_STACK_DIR}/db:/var/lib/mysql + networks: + - seafile-net + + memcached: + image: ${MC_IMG:-memcached}:${MC_TAG:-alpine} + container_name: ${MC_CONTAINER_NAME:-seafile-memcached} + restart: ${MC_RESTART:-unless-stopped} + entrypoint: memcached -m 256 + networks: + - seafile-net + + seafile: + image: ${SF_IMG:-seafileltd/seafile-mc}:${SF_TAG:-latest} + container_name: ${SF_CONTAINER_NAME:-seafile} + restart: ${SF_RESTART:-unless-stopped} + expose: + - "80" + volumes: + - ${LOCAL_STACK_DIR}/seafile/data:/shared + - ./seafile.nginx.conf.template:/templates/seafile.nginx.conf.template:ro + environment: + - DB_HOST=db + - DB_ROOT_PASSWD=${DB_ROOT_PASSWD:-changemeplease} + env_file: + - seafile.env + depends_on: + - db + - memcached + networks: + - default + - seafile-net + +networks: + default: + external: + name: ${NETWORK:-webservices} + seafile-net: + internal: true diff --git a/seafile.env.example b/seafile.env.example new file mode 100644 index 0000000..3a265ca --- /dev/null +++ b/seafile.env.example @@ -0,0 +1,11 @@ +TIME_ZONE=Etc/UTC +SEAFILE_ADMIN_EMAIL=me@example.com +SEAFILE_ADMIN_PASSWORD=asecret +SEAFILE_SERVER_LETSENCRYPT=false +#SEAFILE_SERVER_HOSTNAME=docs.seafile.com + +# Reverse-proxy and certbot +VIRTUAL_HOST=domain.tld +VIRTUAL_PORT=80 +LETSENCRYPT_HOST=domain.tld +LETSENCRYPT_EMAIL=user@domain.tld diff --git a/seafile.nginx.conf.template b/seafile.nginx.conf.template new file mode 100644 index 0000000..b46ce71 --- /dev/null +++ b/seafile.nginx.conf.template @@ -0,0 +1,60 @@ +# -*- mode: nginx -*- +# Auto generated at {{ current_timestr }} +server { + listen 80; + server_name {{ domain }}; + + client_max_body_size 10m; + + location / { + proxy_pass http://127.0.0.1:8000/; + proxy_read_timeout 310s; + proxy_set_header Host $host; + proxy_set_header Forwarded "for=$proxy_add_x_forwarded_for;proto=$http_x_forwarded_proto"; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto; + proxy_set_header X-Real-IP $proxy_add_x_forwarded_for; + proxy_set_header Connection ""; + proxy_http_version 1.1; + + client_max_body_size 0; + access_log /var/log/nginx/seahub.access.log seafileformat; + error_log /var/log/nginx/seahub.error.log; + } + + location /seafhttp { + rewrite ^/seafhttp(.*)$ $1 break; + proxy_pass http://127.0.0.1:8082; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + client_max_body_size 0; + proxy_connect_timeout 36000s; + proxy_read_timeout 36000s; + proxy_request_buffering off; + access_log /var/log/nginx/seafhttp.access.log seafileformat; + error_log /var/log/nginx/seafhttp.error.log; + } + + location /seafdav { + proxy_pass http://127.0.0.1:8080; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host $server_name; + proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto; + proxy_read_timeout 1200s; + client_max_body_size 0; + + access_log /var/log/nginx/seafdav.access.log seafileformat; + error_log /var/log/nginx/seafdav.error.log; + } + + location /media { + root /opt/seafile/seafile-server-latest/seahub; + } + + # For letsencrypt + location /.well-known/acme-challenge/ { + alias /var/www/challenges/; + try_files $uri =404; + } +}