Seafile CE on raspberry pi with nginx, iOS app and web interface not working

Hi all,

I’ve successfully set up a seafile server on a RP3, which totally works locally and from outside when I use my public IP. The server is configured with the service url to be my public ip, which I port forward locally to my RP3. When I’m on my local network, I just change the ip on my clients from the public ip to the local ip and there’s no issue.

However, my goal is to enable https with let’s encrypt, and the first step was to configure nginx. My current configuration allows me to connect to the server with all my clients and the web interface both on my local network and via the public ip when I’m not on my local network. However, only the macOS client (I haven’t tried windows yet) will actually allow me to add or modify files. I can connect to the server with the iOS client and the web interface, and when I connect I am presented with an accurate listing of my libraries and their contents, but I cannot upload files or make folders. With the web interface, I can delete files, but not upload new ones.

After banging my head against the wall for a few hours now, I would love some help as to how I might be able to enable the iOS client and the web interface to have the same abilities as the macOS client. When I changed my configuration to be entirely local (i.e. service_url = localip, file_server_root = localip/seafhttp, and server_name localip;), everything worked fine, but obviously I was unable to access my server from outside my local network.

Here are my configuration files (very sorry about the formatting, still working that out)

/etc/nginx/sites-available/seafile.conf (sym-linked to sites-enabled as per tutorial):

server {
listen 80;
server_name MYPUBLICIP:8000;

proxy_set_header X-Forwarded-For $remote_addr;

location / {
     proxy_pass         http://127.0.0.1:8000;
     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;

     # used for view/edit office file via Office Online Server
     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;
    proxy_pass http://127.0.0.1:8082;
    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 /media {
    root /mnt/seafile_server/seafile-server-latest/seahub;
}

}

/mnt/seafile_server/conf/ccnet.conf:

[General]
USER_NAME = pi_server
ID = MYID
NAME = pi_server
SERVICE_URL = http://MYPUBLICIP:8000

[Client]
PORT = 13419

/mnt/seafile_server/conf/seahub_settings.py:

# -*- coding: utf-8 -*-
SECRET_KEY = MYSECRETKEY
FILE_SERVER_ROOT = ‘http://MYPUBLICIP:8000/seafhttp

You have other values in seahub-db and ccnet-db, you have to change them. For certs you have to use a hostname.

thanks for your suggestions!

I re-configured the mySQL configuration to make sure it reflects the WAN address, but I’m still having the same issue (with identical ccnet.conf, seahub_settings.py, and seafile.conf files as above). The mobile client refuses to download files despite correctly showing them the library; I get “Failed to download file …”.

The macOS client also now only uploads when I start it, and even then intermittently (sometimes files don’t upload at all). With the web interface, I can create folders and delete folders and files, but I cannot upload files. This problem only emerges when I try to use the nginx configuration…any ideas why?

EDIT: It seems that the FILE_SERVER_ROOT parameter is important…changing it to my local ip without :8000, i.e. ‘http://localip/seafhttp’ allows me to download files on the mobile client when it is connected locally. When I change it to FILE_SERVER_ROOT = ‘http://publicip/seafhttp’ though, I can no longer download files from within the local network or outside of it.

Yes, I also saw it right now before reading this post. For WSGI, this have to be the seahub port.

ok, bizarrely enough, if I just comment out FILE_SERVER_ROOT = ‘http://publicip:8000/seafhttp’, everything works exactly as expected on the macOS client, on the iOS client, and via the web interface, despite using nginx. It’s like that line is not necessary. Am I going crazy?

SOLUTION:

It should be
FILE_SERVER_ROOT = ‘http://publicip:8082

Found in jrtech3d’s post:

SOLUTION FOR BOTH INTERNAL AND EXTERNAL UPLOAD/DOWNLOAD

External upload/download means you will be accessing your cloud server remotely and this means you will have some more configurations to do

Step 1
Obtain your public IP address. This is most often available through the WAN status of your home gateway router. (This is your router connecting to your ISP)

Step 2
You will have to forward ports 8000 and 8082 on your gateway router (This is your router connecting to your ISP). Because of the vast variations and variety of routers, I cannot walk you through Port Forwarding / Virtual Servers features
N.B : If you have additional internal routers, you will also have to forward ports 8000 and 8082

Step 3
Go to the FILE_SERVER_ROOT option and set the address to your public IP, followed by port 8082
Example FILE_SERVER_ROOT http://x.x.x.x:8082 ( the Xs represents your public IP)

Step 4
Go to the SERVICE_URL option and set the address to your public IP, followed by port 8000
Example SERVER_URL http://x.x.x.x:8000 ( the Xs represents your public IP)

N.B Pay close attention to the port numbers and don’t mix them up

So you should have something like this ( the Xs represents your public IP)
SERVICE_URL http://x.x.x.x:8000
FILE_SERVER_ROOT http://x.x.x.x:8082

Step 5
Restart seafile server by right clicking on seafile icon at lower right of the desktop and select “Restart Seafile Server”.

Step 6
Open the SeaFile app on your phone (whether android or iOS)

Step 7
Select the “Add Account” option and the server option you will be selecting is " Other Seafile Server"

Step 8
a. uncheck the https option
b. For the server address, enter : http://x.x.x.x:8000 (remember it will be your router’s public IP address and it would work even if you connected locally)
c. The username or email will be the credentials you created through the admin account
d. The password will be the password for the username or email you created

1 Like