Docker-Seafile with NGINX reverse proxy on main server

My setup consists of a main-server (running Ubuntu, with NGINX) where port 443 for all services (seafile, wiki …) is forwarded to, and a new 2nd (internal) server (Raspberry) which runs Docker-Seafile on port 8090.

https → Router -->port 443–> main Server -->port 8090–> 2nd Server (Docker-Seafile)

To access seafile via hxxps://seafile.myurl.com I have setup a reverse proxy on the main-server which forwards the traffic to the 2nd-server (I did not touch the nginx-config inside docker).

It works fine accessing hxxps://seafile.myurl.com for login, seeing the libraries and downloading, but fails when I try to upload files with a ‘network error’. (Uploading directly from the 2nd server works).
The Docker-Seafile Nginx-configuration includes also locations like seafhttp, seafdav, and media - and after reading tens of posts and attempts I was unable to include these in my reverse-proxy on the main-server.
It should be as simple as

location /seafhttp {
proxy_pass http://local_Ip:8090/seafhttp;
}
but it does not work …

Maybe someone can help
Thanks!

Hi,

Don’t. I’m guessing you have a nginx server on the 2nd server too, just let it handle that. On your primary server just redirect everything to the 2nd server.

Something like this do the job (no TLS):

server {
    listen 80;

    server_name seafile.myurl.com;
        
    location / {
        proxy_pass http://2nd-server:8090;
        proxy_set_header Host $http_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-Proto $scheme;
    }
}

Thanks!
This matches more or less what I have - it runs fine for seeing the libraries and downloading, but fails when I try to upload files with a ‘network error’.
The main server runs Nginx (where I put the above config), and the 2nd (Docker-Seafile) server runs Nginx as well, and there is Nginx within the Docker-Seafile folders (/opt/seafile-data/nginx).
There seems no Nginx required for the 2nd server, as the Docker-Seafile installation is handling everything.
If I just access via the local-url, everything is running fine. But if I access via hxxps://seafile/myurl.com uploads are not working.

That’s right, no need to have a second nginx on the host.

This is weird. What’s the content (redacted) of your seahub_settings.py? Anything in the logs?

My seahub_settings.py shows:

SERVICE_URL = “http://seafile.myurl.com/
TIME_ZONE = ‘Asia/Shanghai’ (‘Asia/Singapore’ was not working!)
FILE_SERVER_ROOT = “http://seafile.myurl.com/seafhttp
If I use the local-IP local uploads are working, but with external-url neither internal nor external uploads are working

There is nothing in the logs at all …

Can you provide a screenshot of your browser console showing the details of the failed request?

I mean something like this:

Not so sure how to get it … but I found this when I try uploading a file:

resumable.js:915 Mixed Content: The page at ‘https://seafile.xxxxxxx.com/library/080512e9-7863-4216-b04f-9f646776fe0f/My%20Library/’ was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint ‘http://seafile.xxxxx.com/seafhttp/upload-aj/d6c66be1-dbca-44ed-ac68-0dcbc59b6752?ret-json=1’. This request has been blocked; the content must be served over HTTPS.

Will try to get a browser console screenshot tomorrow …

Ok we’re moving forward.

Try to use https in the configuration (didn’t know it could fail this way):

SERVICE_URL = "https://seafile.myurl.com/"
FILE_SERVER_ROOT = "https://seafile.myurl.com/seafhttp"

This fixed it!
Thank you so much for your help!

1 Like