Seafile, a self-hosted Dropbox alternative

Seafile is an open-source alternative to Cloud drive services like Dropbox, OneDrive (formerly Skydrive), Google Drive, etc. However those services often require you to accept their terms and conditions in order to authorize the provider to access your private data… which is why I prefer to host my own solution. Remember when a product is free, it is often because YOU are the product… It is never too late to take control back of your privacy and you can build & manage your own Dropbox-like solution thanks to Seafile !

The desktop client is light and the interface simple. It displays the list of librairies (owned by you or shared by another user), synchonize it automatically and that’s pretty much it. You cannot do much with the client appart from synching libraires which keeps the client easy to use. The advanced features like versioning, sharing, etc are available from Seafile’s server UI. The desktop client is available on Windows, Mac OS X and Linux and there is also a mobile app available on iOS and Android. I have only tested the iOS one which is fine but some users may find annoying the lack of offline synchronization.

Seafile desktop clientIf you feel like testing Seafile before setting up your own server (which is not really complicated) you can always try their free offer here. You can also stay with me a little bit more to get through an overview of Seafile server.

I host my Seafile instance on a dedicated server running on an Intel Atom N2800, 2GB of RAM and a 500 GB hard drive. Its footprint is really small and only consumes a few MB of RAM. You can even host it on a Raspberry Pi as they have a specific package for it. Compressing large file with Seafile is the only CPU-intensive operation I noticed. It took a few minutes on my server to compress a 1 GB file which is acceptable given it relies on a low consumption CPU meant for mobile usage (Intel Atom).

Seafile server’s UI is great. It is simple, minimal and reactive. There is no fancy or useless features and it is easy to understand. After logging in, you will land on the homepage displaying your librairies:

Seafile server

You can notice a small lock under “My secured library” – that’s because it is encrypted. You need the passphrase to open it which is different from your seafile’s password. The data is encrypted on the server side so if someone hacks your server, he won’t be able to access your files easily.

Browsing a librairy is simple, just click on it and the content will be displayed. It is possible to keep an history of the modifications and customize the retention period for each library. If you want to restore a previous version of a file, just click retore and Seafile will list all the versions available:

Seafile file historyOn top of that Seafile’s developpers use an algorithm called Content Defined Chunking to improve storage efficiency. It means activating history on a library may not increase significantly the storage consumed. Even better, I noticed my users are storing a total of 51 GB of data but Seafile uses around 46 GB on my server thanks to their deduplication mechanism.

It is possible to share a library, folders or files with users or groups of users registered on your Seafile server. You can also generate a public link so they can download or upload files without registering. It is a great way to quickly share files with friends who don’t have an account on your server.

I am not going to go through every feature as I have presented the one that are the most usefull to me but Seafile has a lot more to offer. I think a great tool to collaborate (I wish my company was using it…), it is lightwieght, simple and reliable. The development around Seafile is very active and the team brought great enhancements to their product over the last year. They made a great work to keep it simple and full of those little features that make your life easier. They also did a very good job with the documentation and you can find a lot of details on their website. Install Seafile server, create virtualhost for Nginx / Apache, enable https, configure your firewall, tweaking server conf… everything is explained step by step in the manual. If you feel like trying it, just keep reading and follow the tutorial below !

Installation

This tutorial has been created for Debian Wheezy but should work on most Linux distributions.

**1) Install dependencies (as root)

**

apt-get update
apt-get install python2.7 python-setuptools python-imaging sqlite3
**2) Create a user for Seafile, download and install it

**

Visit http://seafile.com/en/download/ to get the link to the latest version.

adduser seafile
su - seafile
wget https://bitbucket.org/haiwen/seafile/downloads/seafile-server_4.0.1_x86-64.tar.gz
tar -xzf seafile-server_*
mkdir installed
mv seafile-server_* installed
cd seafile-server-*
./setup-seafile.sh

Follow the instructions of the install script to complete setup.

**3) Start Seafile server:

**

You will be asked to create an admin account.

./seafile.sh start
./seahub.sh start

You can now access Seafile by browsing to http://your-server-ip:8000.

 

Virtualhost configuration

If you prefer to configure a reverse proxy (Apache or Nginx) to access Seafile using a domain name and a SSL connexion, follow the instructions below (don’t forget to replace seafile.freedif.org with your domain).

**1) Generate self-signed certificates

**

cd /etc/ssl/certs
openssl genrsa -out privkey.pem 2048
openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095
**2) Configure your domain under Seafile (as seafile user)

**

Edit /home/seafile/ccnet/ccnet.conf and modify the value of SERVICE_URL as below (replace seafile.freedif.org with your domain)

SERVICE_URL = http://seafile.freedif.org

Then edit /home/seafile/seahub_settings.py and add the line below (replace seafile.freedif.org with your domain):

FILE_SERVER_ROOT = 'http://seafile.freedif.org/seafhttp'

Finally, restart Seafile and enable fastcgi

cd /home/seafile/seafile-server-*
./seahub.sh stop 
./seafile.sh stop
./seafile.sh start
./seahub.sh start-fastcgi
**3) NGINX configuration

**

Create a virtualhost (e.g. under /etc/nginx/sites-enabled/seafile.freedif.org), copy the following content (replace seafile.freedif.org with your domain), restart Nginx and that’s it !

server {
        listen 80;
        server_name  seafile.freedif.org;
        rewrite ^ https://$http_host$request_uri? permanent;    # force redirect http to https
    }

server {
    listen 443;
        ssl on;
        ssl_certificate /etc/ssl/certs/cacert.pem;    # path to your cacert.pem
        ssl_certificate_key /etc/ssl/certs/privkey.pem;    # path to your privkey.pem
        server_name seafile.freedif.org;
    location / {
        fastcgi_pass    127.0.0.1:8000;
        fastcgi_param   SCRIPT_FILENAME     $document_root$fastcgi_script_name;
        fastcgi_param   PATH_INFO           $fastcgi_script_name;

        fastcgi_param    SERVER_PROTOCOL        $server_protocol;
        fastcgi_param   QUERY_STRING        $query_string;
        fastcgi_param   REQUEST_METHOD      $request_method;
        fastcgi_param   CONTENT_TYPE        $content_type;
        fastcgi_param   CONTENT_LENGTH      $content_length;
        fastcgi_param    SERVER_ADDR         $server_addr;
        fastcgi_param    SERVER_PORT         $server_port;
        fastcgi_param    SERVER_NAME         $server_name;
        fastcgi_param   REMOTE_ADDR         $remote_addr;
        fastcgi_param   HTTPS               on;
        fastcgi_param   HTTP_SCHEME         https;

        access_log      /var/log/nginx/seahub.access.log;
        error_log       /var/log/nginx/seahub.error.log;
    }

    location /seafhttp {
        rewrite ^/seafhttp(.*)$ $1 break;
        proxy_pass http://127.0.0.1:8082;
        client_max_body_size 0;
        proxy_connect_timeout  36000s;
        proxy_read_timeout  36000s;
    }

    location /media {
        root /home/seafile/seafile-server-latest/seahub;
    }
}
**3-bis) Apache configuration

**

If you prefer to use Apache instead of Nginx, follow the instructions below. Install dependencies (as root)

apt-get install python-flup apache2 libapache2-mod-fastcgi

Enable mod_rewrite, mod_fastcgi, apache proxy and ssl.

a2enmod rewrite
a2enmod fastcgi
a2enmod proxy_http
a2enmod ssl

Enable fastcgi in Apache config file under /etc/apache2/apache2.conf:

FastCGIExternalServer /var/www/seahub.fcgi -host 127.0.0.1:8000

This is valid for Apache 2.2. If you are using a different version, please consult Seafile manual for configuration. Create a virtualhost (e.g. under /etc/apache2/sites-enabled/seafile.freedif.org), copy the following content (replace seafile.freedif.org with your domain), restart Apache and that’s it !

<VirtualHost *:443>
    ServerName seafile.freedif.org
    DocumentRoot /var/www
    Alias /media  /home/seafile/seafile-server-latest/seahub/media

    SSLEngine On
    SSLCertificateFile /etc/ssl/certs/cacert.pem
     SSLCertificateKeyFile /etc/ssl/certs/privkey.pem
    
    RewriteEngine On

     <Location /media>
        Order allow,deny
        Allow from all
     </Location>

    #
    # seafile fileserver
    #
    ProxyPass /seafhttp http://127.0.0.1:8082
    ProxyPassReverse /seafhttp http://127.0.0.1:8082
    RewriteRule ^/seafhttp - [QSA,L]

    #
    # seahub
    #
    RewriteRule ^/(media.*)$ /$1 [QSA,L,PT]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /seahub.fcgi$1 [QSA,L,E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</VirtualHost>

0 Comments:

Add a comment