Seafile on Nginx with uWSGI

Admin Seafile

I’ve been using Seafile as my personal cloud storage for quite some time now and it’s working really really well. Since I’ve departed quite a bit from the standard setup instructions for the web frontend (Seahub) I’m going to document the setup a tiny little bit.

For complete Seafile setup instructions that include all components and not only the web frontend please refer to the Seafile Server Manual.

Running Seahub as a WSGI application

The standard setup instructions recommend to run Seahub behind Nginx as a FastCGI application. However internally Seahub is actually a WSGI application which is the standard way to communicate with Python based web-applications. Since I’m using uWSGI for managing and running several other services already I opted to skip the FastCGI wrapper in front of Seahub and let uWSGI start the web application with the correct environment instead. This also means is not used anymore.

The configuration I use for uWSGI and Seafile Server 3.1.6 looks like this:


plugins = python
uid = seafile
gid = seafile

topdir = /srv/seafile
env = CCNET_CONF_DIR=%(topdir)/ccnet
env = SEAFILE_CONF_DIR=%(topdir)/seafile-data
env = SEAHUB_LOG_DIR=%(topdir)/logs

installpath = /srv/seafile/seafile-server-latest
env = PYTHONPATH=%(installpath)/seahub:%(installpath)/seahub/thirdpart: \
env = DJANGO_SETTINGS_MODULE=seahub.settings

module = seahub.wsgi:application

Most environment variables set here are normally set in before starting the Python-based HTTP- or FastCGI-Server. The job of configuring the environment is now done by uWSGI and the above configuration file instead. For Python 2.7 the PYTHONPATH contents obviously need to be adapted.

The only exception in this configuration is DJANGO_SETTINGS_MODULE which is normally set inside seahub/ early on. Unfortunately this did not seem to work when running the application from uWSGI (probably since the app cannot permanently modify the environment) so I had to set this inside the uWSGI configuration file.

Configuring Nginx

For Nginx the configuration is almost identical to the Seafile FastCGI setup documented in the manual. The only change is that the root location element is a lot simpler and uses uwsgi_pass instead of fastcgi_pass.


server {
    listen 80;
    return 301 https://$server_name$request_uri;
server {
    listen 443 ssl;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/var/run/uwsgi/app/seafile/socket;

    location /seafhttp {
        rewrite ^/seafhttp(.*)$ $1 break;
        client_max_body_size 0;

    location /media {
        root /srv/seafile/seafile-server-latest/seahub;