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

Doubling of SITE_ROOT for non-root setup #1790

Closed irstevenson closed 7 years ago

irstevenson commented 7 years ago

I have seafile 6.0.4 setup behind NGINX with HTTPS as a non-root setup as per:

Everything basically works - especially with the desktop client - however I have some issues with the Web UI with links that seems to have SITE_ROOT doubled. For example, when I first attempt to access my site by going to https://censored/seafile/ I get redirected to the login page but at the following URL (note the next param):

https://censored/seafile/accounts/login/?next=/seafile/seafile/

So if I login successfully with that page, I get a message saying the page could not be found as I've arrived at:

https://censored/seafile/seafile/

If I manually chop that down to

https://censored/seafile/

Then everything works as expected. Except for:

AFAIK they're the only links with issues - everything else works. And from the fact it's like that, I've pretty well ruled out an issue with NGINX config.

I've also rm -rf /tmp/seahub_cache but with no joy.

Below are my configuration files. I hope you can help.

seahub_settings.py

FILE_SERVER_ROOT = 'https://censored/seafhttp'

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

SECRET_KEY = "censored"

EMAIL_BACKEND = 'django_smtp_ssl.SSLEmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'censored'
EMAIL_HOST_USER = 'censored'
EMAIL_HOST_PASSWORD = 'censored'
EMAIL_PORT = 465
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
SERVER_EMAIL = EMAIL_HOST_USER

seafile.conf

[fileserver]
port=8082

ccnet.conf

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

[Client]
PORT = 13419

NGINX site config

server {
        listen      80 default_server;
        server_name censored;
        return      301 https://$server_name$request_uri;
}

server {
        # SSL configuration
        #
        listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        ssl_certificate     /etc/ssl/nginx/cacert.pem;    # path to your cacert.pem
        ssl_certificate_key /etc/ssl/nginx/privkey.pem;   # path to your privkey.pem

        root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name censored;

        proxy_set_header X-Forwarded-For $remote_addr;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

        location /seafile {
                include /etc/nginx/fastcgi_params;
                fastcgi_param   HTTPS               on;
                fastcgi_param   HTTP_SCHEME         https;
                fastcgi_param   SCRIPT_FILENAME     $document_root$fastcgi_script_name;
                fastcgi_param   PATH_INFO           $fastcgi_script_name;

                fastcgi_pass 127.0.0.1:8000;
                fastcgi_read_timeout 36000;
        }

        location /seafile/media {
                rewrite ^/seafile/media(.*)$ $1 break;
                root /opt/seafile/seafile-server-latest/seahub/media;
        }

        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;
        }
}
LouisKottmann commented 7 years ago

I'm having a similar issue where I am now redirected to:

https://censored/accounts/login/?next=/seafile

Instead of:

https://censored/seafile/accounts/login/?next=/seafile
niflostancu commented 7 years ago

Hi, I have the same problem, seahub seemingly appends the new URL to the current path. E.g.:

<a href="/seafile/seafile/home/wiki/">...</a>

Even the login captcha has wrong URL:

https://mydomain.com/seafile/accounts/login/seafile/captcha/image/CENSORED_CAPTCHA_ID/
niflostancu commented 7 years ago

I discovered the cause of this problem: the include fastcgi_params line. Replace it with manual fastcgi_param list like in the manual page and it will work. It seems there's something seahub doesn't like in that file...

L.E. / idea: you should add a warning in the manual not to do this. For engineers that try to prematurely optimize for code / configuration file size, like us ;)

irstevenson commented 7 years ago

Wow! Thanks @niflostancu , that has indeed sorted my issues. I wasted so much time on this. :(

Oh well, it's looking ship shape now. Thanks!