Unable to use WEB UI in 6.2.5 when switching from fastcgi to wsgi

I upgraded to 6.2.5 the last days which worked fine. Now I try to switch to wsgi from fastcgi as suggested but the UI doesn’t work.

My config:
raspbian stretch, nginx, sqlite

I changed the nginx seafile config as suggested in the manual and removed fastcgi from starting seahub.
When I try to login with https://seafileHostName:seafilePort which works with fastcgi after some time I get a timeout and notice the url in he browser changed to https://seafileHostName/accounts/login?next=/

Actually that’s incorrect because it has to be https://seafileHostName:seafilePort/api2/accounts/login?next=/ When I call this updated REST endpoint via curl I get a reply.

Looks like there is some nginx forwarding issue :disappointed_relieved: Does somebody have an idea or hint what may be wrong?

My nginx config:

server {
    listen <seafilePort>; # <--------------------------------------- NGINX PORT
    ssl on; # <-------------------------------------------- SSL
    ssl_certificate /etc/nginx/ssl/ssl-bundle.crt; # <--------- SSL
    ssl_certificate_key /etc/nginx/ssl/seafile.key; # <----- SSL
    server_name <seafileHostName>; # <----------------- CHANGE THIS
    error_page 497  https://$host:$server_port$request_uri;
    proxy_set_header X-Forwarded-For $remote_addr;         # added 4/10/16
    add_header Strict-Transport-Security "max-age=31536000; includeSubdomains"; # added 4/10/16

    server_tokens off;  # added 4/27/16

 location / {
    proxy_pass    ;
    proxy_set_header        Host $host;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        X-Forwarded-Host $server_name; 
    proxy_read_timeout      1200s;

    client_max_body_size    0;

    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;
    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_connect_timeout  36000s;
    proxy_read_timeout  36000s;
    proxy_send_timeout  36000s;

    send_timeout  36000s;

 location /seafdav {
    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;

    client_max_body_size 0;
    proxy_read_timeout 1200;

    access_log      /var/log/nginx/seafdav.access.log;
    error_log       /var/log/nginx/seafdav.error.log;

location /media {
    root /home/seafile/seafile-server-latest/seahub; # <-- change: 2014-07-11
    # include /etc/nginx/mime.types; # <--- UNCOMMENT THIS IF CSS FILES AREN'T LOADED


You have to disable SeafDAV in your nginx config and in your seahub_settings.py

:+1: Thank you very much for four quick reply. But does this mean it’s not possible to use seafdav with wsgi any more? If yes I have to stick with fastcgi because I need seafdav

@bionade24 I just disabled seafdav in ngnix and the UI now works perfectly with wsgi :grinning:

Then I found Seafdav does not work (seafdav.pid problem) and in there is another link to Tutorial: Seafdav with WSGI behind Nginx. I followed the tuturial and now both ui and dav are running with wsgi.

Looks like the manual is outdated :confused: But I found following statement about seafdav from @DerDanilo

WSGI works just fine. CE manual contains the config.

Does somebody know where this CE manual is located? Looks like this manual is more current than this manual.

Please send me a pm. I don’t want to make it public yet.

This manual can be updated at https://github.com/haiwen/seafile-docs

I just detected the UI doesn’t work any more with WSGI and spent some time to find the root cause why it deosn’t work any more.

  1. If you flip between WSGI and FCGI mode on the server you have to clean your browser cache. That’s why I thought UI works with WSGI. When I switched from FCGI to WSGI the UI worked. When I cleared the browser cache it didn’t work any more :frowning:
  2. WSGI usage for seafdav works perfectly if you follow the doc and change nginx according the tutorial. It didn’t work because I screwed up the configs when switching between UI and seafdav WSGI/FCGI mode back and forth

So now my server still runs FCGI for UI and WSGI for seafdav using nginx port <> 80.

Then I changed my non standard nginx port to 80, configured WSGI for UI and everythings works fine (I also cleared the browser cache :smile:)

This proved my previous guess is right:
"When I try to login with https://seafileHostName:nginxPort which works with fastcgi after some time I get a timeout and notice the url in the browser changed to https://seafileHostName/accounts/login?next=/
Actually that’s incorrect because it has to be https://seafileHostName:nginxPort/accounts/login?next=/ which I get when I use FCGI. The nginx portnumber is lost "

Actually it seems to be either a missing config statement or a coding issue because the redirection to the login page looses the port number. I’m not familiar with nginx but tried different config changes to make sure port is not lost but failed :frowning:

Does somebody know what I have to change in the nginx config or should I open an issue for this?

@shoeper I frankly wasn’t aware this doc can/should be updated by the community. Regarding the seafdav and WSGI it’s missing the nginx changes mentioned in the tutorial. Looks like @res80 also didn’t know about this :slight_smile:

@DerDanilo Thank you very much for the link. I’m going to provide feedback the next days via PM

1 Like

This should make it working.

Thank you very much for the interesting link. Actually I already tried to use the hard coded port in the host statement which didn’t work and the variable also doesn’t work :frowning:

But … the original thread for this doc update request (in German) helped me to find the root cause for the issue:

I used “SITE_BASE=‘http://mySeafileURL’” in seahub_settings.py all the time and it worked fine with FCGI. But for WSGI I have to change it into “SITE_BASE=‘http://mySeafileURL:myPort’”.

Now I can use WGSI for UI and seafdav successfully :slight_smile:

There are multiple places you have to update when you want to use a non standard port but unfortunately I forgot one. I checked the doc but I failed to find any description how to use a non standard port. I also didn’t find the update with $server_port in WSGI mode :hushed: I don’t know nginx in detail but as far as I understand $server_port in host can be used all the time - whether port 80 or a non standard port ist used.

Thank you very much @all helping me to solve this ugly issue with WSGI.

1 Like

Thanks for the hint to @framp and @shoeper, I really didn’t know that.
I started this tutorial actually as a question, then answered it myself by playing around with nginx and changed the title to tutorial afterwards, hoping that the devs would include it in the manual.


Summary of what worked for me from my thread, WSGI Mode Setup Question

My setup: Debian 8, Nginx, MySQL, standard ports, 80 rewrite to 443

After upgrading to 6.2.5 in order to get WSGI to work I had to use the following in the nginx config.

Updated proxy_set_header Host $host; to proxy_set_header Host $host:$server_port;

.+ I needed the following line added…

proxy_set_header X-Forwarded-Proto https;

In my seahub_settings.py:
SITE_BASE = ‘https://xxx.xxxxxx.net’ , (Use your domain name.)
File_Server_Root = ‘https://xxx.xxxxxx.net/seafhttp’ , (Use your domain name)

I also upgraded nginx from 1.6 to 1.10.3 using the jesse backports. Note: Keep your config files when prompted.

Then did the normal troubleshooting restart of everything…

Shut down Seahub and Seafile
Cleared Seahub Cache
Cleared Browser Cache
Service Nginx Stop and then Start
Started Seafile and Seahub

For me it worked. YMMV some do not need the ->>> proxy_set_header X-Forwarded-Proto https;

In my case I did.