Search code examples
nginxreverse-proxyseafile-server

Seafile file upload does not work, even after setting the "FILE_SERVER_ROOT" variable


I'm trying to get Seafile running behind a nginx reversed proxy. I followed this: http://manual.seafile.com/deploy/deploy_with_nginx.html along with this: http://manual.seafile.com/deploy/https_with_nginx.html.

My configuration is like follows:

  • Nginx running for vhost "cloud.mydomain.tld"
  • Seafile and Seahub (in fastcgi mode) both running on their default ports
  • My seahub_settings.py looks like this:

    HTTP_SERVER_ROOT = 'https://cloud.mydomain.tld/seafhttp' -- I added this to try it
    FILE_SERVER_ROOT = 'https://cloud.mydomain.tld/seafhttp'
    SECRET_KEY = "12345678-1234-1234-1234-1234567890123456"
    
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME': 'seahub-db',
            'USER': 'seafile',
            'PASSWORD': 'mypassword',
            'HOST': '127.0.0.1',
            'PORT': '3306',
            'OPTIONS': {
                'init_command': 'SET storage_engine=INNODB',
            }
        }
    }
    
  • My nginx configuration:

    ### Cloud ###
    
    # No-SSL redirect
    server {
            listen 80;
            server_name cloud.mydomain.tld;
            return 301 https://$server_name$request_uri;
    }
    
    # SSL
    server {
            listen 443 ssl;
    
            server_name cloud.mydomain.tld;
            ssl_certificate /etc/letsencrypt/live/cloud.mydomain.tld/cert.pem;
            ssl_certificate_key /etc/letsencrypt/live/cloud.mydomain.tld/privkey.pem;
    
            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;
                    fastcgi_read_timeout 36000;
            }
    
            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;
                    send_timeout  36000s;
            }
    
            location /media {
                    root /home/cloud/seafile-server-latest/seahub;
            }
    }
    
  • That should be everything important.

So now, when I delete my old seahub_settings.pyc, start seahub (in fastcgi mode, of course), point the browser to my library and try to upload something, I get the following error message in the F12 developer console:

main.ad03aea1e16e.js:215 Mixed Content: The page at 'https://cloud.mydomain.tld/#my-libs/lib/12345678-1234-1234-1234-123456789012' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://cloud.mydomain.tld:8082/upload-aj/12345678-1234-1234-1234-123456789012'. This request has been blocked; the content must be served over HTTPS.
    send @ main.ad03aea1e16e.js:215

This means, that seahub is still trying to connect to the "old" upload service, which of course does not work anymore. Until now, I did not find out any solution for this problem.


Solution

  • I just found your question by having the same problem.

    That's easy : there's a constance_config in seahub-db (with MySQL, same thing apply with sqlite) that records configuration and overwrite the plain config files.

    This configuration can be modified from the admin console (upper right) or you can simply truncate this table to get it re-generated.

    It's a new 'feature' starting from 5.0.0 (http://manual.seafile.com/config/index.html).

    Regards, Julien