Config Seahub with Apache

Important

According to the security advisory published by Django team, we recommend disable GZip compression to mitigate BREACH attack.

This tutorial assumes you run at least Apache 2.4.

Prepare

Install and enable apache modules

On Ubuntu you can use:

  1. sudo a2enmod rewrite
  2. sudo a2enmod proxy_http

Deploy Seahub/FileServer With Apache

Seahub is the web interface of Seafile server. FileServer is used to handle raw file uploading/downloading through browsers. By default, it listens on port 8082 for HTTP request.

Here we deploy Seahub and FileServer with reverse proxy. We assume you are running Seahub using domain ‘’’www.myseafile.com’’’.

Modify Apache config file:
(sites-enabled/000-default) for ubuntu/debian, (vhost.conf) for centos/fedora

  1. <VirtualHost *:80>
  2. ServerName www.myseafile.com
  3. # Use "DocumentRoot /var/www/html" for Centos/Fedora
  4. # Use "DocumentRoot /var/www" for Ubuntu/Debian
  5. DocumentRoot /var/www
  6. Alias /media /home/user/haiwen/seafile-server-latest/seahub/media
  7. RewriteEngine On
  8. <Location /media>
  9. Require all granted
  10. </Location>
  11. #
  12. # seafile fileserver
  13. #
  14. ProxyPass /seafhttp http://127.0.0.1:8082
  15. ProxyPassReverse /seafhttp http://127.0.0.1:8082
  16. RewriteRule ^/seafhttp - [QSA,L]
  17. #
  18. # seahub
  19. #
  20. SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
  21. ProxyPass / http://127.0.0.1:8000/
  22. ProxyPassReverse / http://127.0.0.1:8000/
  23. </VirtualHost>

Modify ccnet.conf and seahub_setting.py

Modify ccnet.conf

You need to modify the value of SERVICE_URL in ccnet.conf
to let Seafile know the domain you choose. You can also modify SERVICE_URL via web UI in “System Admin->Settings”. (Warning: if you set the value both via Web UI and ccnet.conf, the setting via Web UI will take precedence.)

  1. SERVICE_URL = http://www.myseafile.com

Note: If you later change the domain assigned to seahub, you also need to change the value of SERVICE_URL.

Modify seahub_settings.py

You need to add a line in seahub_settings.py to set the value of FILE_SERVER_ROOT. You can also modify FILE_SERVER_ROOT via web UI in “System Admin->Settings”. (Warning: if you set the value both via Web UI and seahub_settings.py, the setting via Web UI will take precedence.)

  1. FILE_SERVER_ROOT = 'http://www.myseafile.com/seafhttp'

Start Seafile and Seahub

  1. sudo service apache2 restart
  2. ./seafile.sh start
  3. ./seahub.sh start

Troubleshooting

Problems with paths and files containing spaces

If there are problems with paths or files containing spaces, make sure to have at least Apache 2.4.12.

References