TriliumNext / Notes

Build your personal knowledge base with TriliumNext Notes
https://triliumnext.github.io/Docs/
GNU Affero General Public License v3.0
1.04k stars 59 forks source link

(Bug report) client cannot connect to server #301

Closed hulmgulm closed 3 months ago

hulmgulm commented 3 months ago

TriliumNext Version

0.90.3

What operating system are you using?

Windows

What is your setup?

Local + server sync

Operating System Version

Win 11

Description

I updated my docker based server installation from zadams latest version to ghcr.io/triliumnext/notes:latest. Afterwards, the sync of the client worked fine. Then I updated my windows client and the sync is broken. I get this error when trying to sync: image

Error logs

No response

eliandoran commented 3 months ago

@hulmgulm , is there a possibility of checking the server logs? 403 forbidden means that the client has somehow lost the authentication with the server.

I'll try to reproduce the issue on my side as well.

hulmgulm commented 3 months ago

I see these requests in trilum server (0.90.3) log when using the 0.63.7 client:

304 GET /api/setup/status with 59 bytes took 2ms
200 POST /api/login/sync with 58 bytes took 2ms

and this in my nginx log:

api.xxxxx.de 130.41.104.184 - - [07/Aug/2024:08:09:13 +0000] "GET /notes/api/setup/status HTTP/2.0" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) TriliumNotes/0.63.7 Chrome/114.0.5735.289 Electron/25.9.8 Safari/537.36" "0.006" "0.001"
api.xxxxx.de 130.41.104.184 - - [07/Aug/2024:08:09:13 +0000] "POST /notes/api/login/sync HTTP/2.0" 200 75 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) TriliumNotes/0.63.7 Chrome/114.0.5735.289 Electron/25.9.8 Safari/537.36" "0.013" "0.001"

When using 0.90.3 client with the same server, I do not see a request in the trilium server log and this in the nginix log:

api.xxxxx.de 130.41.104.183 - - [07/Aug/2024:08:07:52 +0000] "GET /notes/api/setup/status HTTP/2.0" 403 166 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) TriliumNextNotes/0.90.3 Chrome/126.0.6478.127 Electron/31.2.1 Safari/537.36" "0.000" "-"
hulmgulm commented 3 months ago

Connecting the 0.90.3 client directly to trilium server without going via nginx works.

hulmgulm commented 3 months ago

OK, found the issue. For security reasons, I had this in my nginx confg:

  if ($http_user_agent !~* (TriliumNotes)) {
      return 403;
  }

TriliumNext uses a different user agent and therefore ningx responds with 403. Updating this statement made the sync work.

eliandoran commented 3 months ago

@hulmgulm , glad you managed to solve it.