WSL Docker with double nginx

I’ve gotten Seafile working within my internal network using fixed IPs, but I’m at a loss setting up my nginx.conf to access Seafile via a domain name. This is my nginx location block for Seafile.

location /seafile/ {
        proxy_pass         http://127.0.0.1:9080/;
        proxy_set_header   Host $host;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   X-Forwarded-For $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;
}
location /seafhttp/ {	
        rewrite ^/seafhttp(.*)$ $1 break;
        proxy_pass http://127.0.0.1:9080/seafhttp/;
        client_max_body_size 0;
        proxy_set_header X-Forwarded-For $remote_addr;
        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;
}

This is nginx running on the Windows layer, redirecting to the docker container listening on port 9080.

At the moment, what’s happening is that I access domain/seafile/, and I get redirected to domain/accounts/login, which breaks. I don’t see a redirect to /accounts in nginx.conf, so I’m assuming that happens in Seafile itself.

Can anybody advise me what needs to be done?

Edit: Added more info

Based on my digging, it seems like Seafile doesn’t play well with subdirectories, and requires a subdomain to work properly. Somebody correct me if I’m wrong.

I currently have the web UI up and running under a subdomain. However, file upload / download doesn’t work. I have set SERVICE_URL and FILE_SERVER_ROOT in the web settings to https://seafile.domain/ and https://seafile.domain/seafhttp respectively.

My nginx.conf block follows:

        location / {
	
            proxy_pass         http://127.0.0.1:9080/;
            proxy_set_header   Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Forwarded-For $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;

    }
	
    location /seafhttp {	
            rewrite ^/seafhttp(.*)$ $1 break;
            proxy_pass http://127.0.0.1:9080/seafhttp;
            client_max_body_size 0;
            proxy_set_header X-Forwarded-For $remote_addr;
            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;
    }

What am I missing here?

Hi, this should be http://127.0.0.1:8082 or whatever port redirected to 8082 in your container.

Hi. Port 9080 links to the nginx inside the container which then redirects to port 8000 or 8082 in the container. I forgot to mention that the setup works if I’m accessing the container via direct local IP (with appropriate SERVICE_URL and FILE_SERVER_ROOT), which skips the Windows-layer nginx. Therefore I’m fairly certain the problem lies with my Windows-layer nginx.conf.

Ok I see, then this block is probably useless since the redirection already exists:

Small progress. Removed that block, download works now, but uploading still fails.

Any error message/log?

Nothing in any of the server logs, as far as I can tell

You can try to watch the dev tools (F12) -> network activity tab when uploading a file. Working upload looks like below:

Oh. Upload works perfectly on Web UI. It just doesn’t work on android. I assumed that Web UI was using a different method from the android app.

Update: Turns out the app was caching some bad settings, despite me having changed to a new user account. Deleting the app cache got it working. Thanks for your help @Barolo