Deploy Seahub at Non-root domain

This documentation will talk about how to deploy Seafile Web using Apache/Nginx at Non-root directory of the website(e.g., Please note that the file server path will still be e.g. (rather than because this path is hardcoded in the clients.

Note: We assume you have read Deploy Seafile with nginx or Deploy Seafile with apache.

Configure Seahub

First, we need to overwrite some variables in

MEDIA_URL = '/seafmedia/'
STATIC_URL = MEDIA_URL + 'assets/'
SITE_ROOT = '/seafile/'
LOGIN_URL = '/seafile/accounts/login/' # NOTE: since version 5.0.4

The webserver will serve static files (js, css, etc), so we just disable SERVE_STATIC.

MEDIA_URL can be anything you like, just make sure a trailing slash is appended at the end.

We deploy Seafile at /seafile/ directory instead of root directory, so we set SITE_ROOT to /seafile/.

Modify ccnet.conf and

Modify ccnet.conf

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


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


You need to add a line in to set the value of FILE_SERVER_ROOT


Note: The file server path MUST be /seafhttp because this path is hardcoded in the clients.

Webserver configuration

Deploy with Nginx

Then, we need to configure the Nginx:

server {
listen 80;
proxy_set_header X-Forwarded-For $remote_addr;
location /seafile {
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 HTTPS on; # enable this line only if https is used
access_log /var/log/nginx/seahub.access.log;
error_log /var/log/nginx/seahub.error.log;
location /seafhttp {
rewrite ^/seafhttp(.*)$ $1 break;
client_max_body_size 0;
location /seafmedia {
rewrite ^/seafmedia(.*)$ /media$1 break;
root /home/user/haiwen/seafile-server-latest/seahub;

Deploy with Apache

Here is the sample configuration:

<VirtualHost *:80>
DocumentRoot /var/www
Alias /seafmedia /home/user/haiwen/seafile-server-latest/seahub/media
<Location /seafmedia>
ProxyPass !
Require all granted
RewriteEngine On
# seafile fileserver
ProxyPass /seafhttp
ProxyPassReverse /seafhttp
RewriteRule ^/seafhttp - [QSA,L]
# seahub
SetEnvIf Request_URI . proxy-fcgi-pathinfo=unescape
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
ProxyPass /seafile fcgi://

We use Alias to let Apache serve static files, please change the second argument to your path.

Clear the cache

By default, Seahub caches some data like the link to the avatar icon in /tmp/seahub_cache/ (unless memcache is used). We suggest to clear the cache after seafile has been stopped:

rm -rf /tmp/seahub_cache/

For memcache users, please purge the cache there instead by restarting your memcached server.

Start Seafile and Seahub

./ start
./ start # or "./ start-fastcgi" if you're using fastcgi