haiwen / seafile

High performance file syncing and sharing, with also Markdown WYSIWYG editing, Wiki, file label and other knowledge management features.
http://seafile.com/
Other
12.25k stars 1.54k forks source link

Seafile cache problem after moving from root folder to subfolder with nginx #1527

Closed dannykorpan closed 8 years ago

dannykorpan commented 8 years ago

Hi,

after moving from web root folder "/" to a web subfolder "/seafile" in nginx there are errors (not found 404) with the cache folder. result is, that the website is displayed without images/css etc. but its fully functional. I'm using debian 8 jessie, seafile server 5.0.4 64bit with nginx 1.9.10 as proxy, memcached/python-memcached, https, http2 and followed the documentation http://manual.seafile.com/deploy/deploy_seahub_at_non-root_domain.html to move my working seafile-installation to a sub folder. there is no /tmp/seahub_cache/ folder for cleaning because of using python-memcached. if im moving back to the root folder, seafile is displaying all images like it should.

seahub_settings.py

SECRET_KEY = "XXX"

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'seahub-db',
        'USER': 'XXX',
        'PASSWORD': 'XXX',
        'HOST': '127.0.0.1',
        'PORT': '3306',
        'OPTIONS': {
            'init_command': 'SET storage_engine=INNODB',
        }
    }
}

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION': '127.0.0.1:11211',
    }
}

FILE_SERVER_ROOT = 'https://XXX/seafhttp'

SERVE_STATIC = False
MEDIA_URL = '/seafmedia/'
COMPRESS_URL = MEDIA_URL
STATIC_URL = MEDIA_URL + 'assets/'
SITE_ROOT = '/seafile/'
LOGIN_URL = '/seafile/accounts/login/'

nginx seafile.conf

server {
    listen 443 http2;
    server_name XXX;

        ssl on;
        ssl_certificate /XXX/fullchain.pem;
        ssl_certificate_key /XXX/privkey.pem;
        ssl_session_cache    shared:SSL:10m;
        ssl_session_timeout  10m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
        ssl_dhparam /XXX/dhparam.pem;
        ssl_stapling on;

    proxy_set_header X-Forwarded-For $remote_addr;

        add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";
        server_tokens off;

    location /seafile {
        fastcgi_pass    127.0.0.1:8001;
        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;
        proxy_send_timeout  36000s;
        proxy_request_buffering off;
    }

    location /media {
        root /opt/seafile-server-latest/seahub;
    }

}

ccnet.conf

[General]
USER_NAME = XXX
ID = XXX
NAME = XXX
SERVICE_URL = https://XXX/seafile

[Client]
PORT = 13419

[Database]
ENGINE = mysql
HOST = 127.0.0.1
PORT = 3306
USER = XXX
PASSWD = XXX
DB = ccnet-db
CONNECTION_CHARSET = utf8
xiez commented 8 years ago

try replace /media block to /seafmedia as described in http://manual.seafile.com/deploy/deploy_seahub_at_non-root_domain.html

dannykorpan commented 8 years ago

Its working. thank you! i forgot to adjust the /media block!