seafile-docs

Config Seahub with Nginx

Prepare

Install python-flup library. On Ubuntu:

sudo apt-get install python-flup

Deploy Seahub/FileServer with Nginx

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 using FastCGI, and deploy FileServer with reverse proxy. We assume you are running Seahub using domain '''www.myseafile.com'''.

This is a sample Nginx config file.

server {
    listen 80;
    server_name www.myseafile.com;
    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;

        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/user/haiwen/seafile-server-latest/seahub;
    }
}

Nginx settings "client_max_body_size" is by default 1M. Uploading a file bigger than this limit will give you an error message HTTP error code 413 ("Request Entity Too Large").

You should use 0 to disable this feature or write the same value than for the parameter max_upload_size in section [fileserver] of /seafile/seafile-data/seafile.conf

Modify ccnet.conf and seahub_setting.py

Modify ccnet.conf

You need to modify the value of SERVICE_URL in /data/haiwen/ccnet/ccnet.conf to let Seafile know the domain you choose.

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 (or HTTP_SERVER_ROOT before version 3.1)

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

Start Seafile and Seahub

./seafile.sh start
./seahub.sh start-fastcgi

Notes when Upgrading Seafile Server

When upgrading seafile server, besides the normal steps you should take, there is one extra step to do: '''Update the path of the static files in your nginx/apache configuration'''. For example, assume your are upgrading seafile server 1.3.0 to 1.4.0, then:

    location /media {
        root /home/user/haiwen/seafile-server-1.4.0/seahub;
    }

Tip: You can create a symbolic link seafile-server-latest, and make it point to your current seafile server folder (Since seafile server 2.1.0, the setup-seafile.sh script will do this for your). Then, each time you run a upgrade script, it would update the seafile-server-latest symbolic link to keep it always point to the latest version seafile server folder.

In this case, you can write:

    location /media {
        root /home/user/haiwen/seafile-server-latest/seahub;
    }

This way, you no longer need to update the nginx config file each time you upgrade your seafile server.