"Connection Error" when using Nginx proxy

Hello. I’m setting up my first Syncthing v1.23.1 instance on Ubuntu 20.04LTS with Nginx as the proxy to an FQDN over https (i.e. externally viewable via a browser). I’m using the Syncthing apt setup as outlined here, running as a system service under systemd. I am using the service file from here with two changes on the ExecStart line to change the GUI address to non-localhost and enable logging to /var/log/syncthing.log:

ExecStart=/usr/bin/syncthing serve --no-browser --no-restart --logflags=0 --gui-address=0.0.0.0:8384 --logfile=/var/log/syncthing.log

I am using Nginx as a proxy via the http upstream, with basic htpasswd auth while I find my way and set things up properly. This proxy uses a hostname and port (port 707 in this case) as I run other proxies on the same host. I can access the Nginx proxy via https://hostname.example.com:707, I am prompted for the htpasswd login details (as expected), and I see the Syncthing GUI in my browser, with the correct machine hostname, a red ‘Danger’ box telling me about remote access without a password (expected) and a green ‘GUI Authentication’ box prompting me to set up authentication (expected).

After around 5 seconds, a modal appears asking if I want to report anonymous statistics. I say ‘Yes’ and immediately I see a red ‘Connection Error’ with the following text:

Syncthing seems to be experiencing a problem processing your request. Please refresh the page or restart Syncthing if the problem persists.

If I leave the modal in place without clicking, the browser console throws two errors:

[Error] Failed to load resource: the server responded with a status of 404 () (customicons.css, line 0)
[Error] Failed to load resource: the server responded with a status of 501 () (upgrade, line 0)

Then, the following errors are appended to the console:

[Error] Failed to load resource: The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 303.)
[Error] Failed to load resource: The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 303.)
[Error] Failed to load resource: the server responded with a status of 501 () (upgrade, line 0)

If I then click ‘Yes’ from the modal, which triggers the ‘Connection Error’ modal, the following errors appear in the console:

[Error] Failed to load resource: the server responded with a status of 403 () (config, line 0)
[Error] Failed to load resource: The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 303.)
[Error] Failed to load resource: The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 303.)
[Error] Failed to load resource: the server responded with a status of 501 () (upgrade, line 0)

I’ve opened ports using ufw:

$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
80/tcp                     ALLOW       Anywhere                  
443/tcp                    ALLOW       Anywhere                  
707/tcp                    ALLOW       Anywhere                  
22000/tcp                  ALLOW       Anywhere                  
22000/udp                  ALLOW       Anywhere                  
syncthing                  ALLOW       Anywhere                  
syncthing-gui              ALLOW       Anywhere                  
80/tcp (v6)                ALLOW       Anywhere (v6)             
443/tcp (v6)               ALLOW       Anywhere (v6)             
707/tcp (v6)               ALLOW       Anywhere (v6)             
22000/tcp (v6)             ALLOW       Anywhere (v6)             
22000/udp (v6)             ALLOW       Anywhere (v6)             
syncthing (v6)             ALLOW       Anywhere (v6)             
syncthing-gui (v6)         ALLOW       Anywhere (v6)  

Edit: I would check the logs, but…there are none, despite the path being set in the service file.

…and now I’m scratching my head as to what else I need to do to get this firing on all cylinders properly.

What have I missed?

Thank for your reading, and your considerations in any advice & feedback.

I think the only unexpected error there is the 403 on loading config. That should happen and will make the gui unhappy. You should investigate why that happens.

Thank you, @calmh – when I visit /rest/config I see a CSRF Error message. This sounds like there’re two browsers listening and they’re colliding. Can I set another ExecStart flag to prevent this?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.