Caddy V2 Reverse Proxy 404 error

Not able to get this working behind Caddy V2 as a subdirectory. I am running the latest versions of both Caddy and Syncthing in Docker containers.

Having the same issues as this user it appears.

I tried removing JWT to rule it out, but I get the same error. I have many other apps working, but they all support a base URL/prefix. Not sure if that is what is causing me issues or if I am missing something else.

Caddyfile (relevant part)

  route /syncthing/* {

Caddy Logs

{"level":"debug","ts":1624196432.527457,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"","request":{"remote_addr":"","proto":"HTTP/2.0","method":"GET","host":"","uri":"/syncthing/","headers":{"X-Forwarded-Proto":["https"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36"],"Sec-Fetch-User":["?1"],"Referer":[""],"Accept-Language":["en-US,en;q=0.9"],"Sec-Fetch-Mode":["navigate"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"],"Sec-Fetch-Site":["same-origin"],"Accept-Encoding":["gzip, deflate, br"],"Cookie":["access_token=<redacted>; CSRF-Token-LK7LV=<rectaed>"],"X-Forwarded-For":[""],"Sec-Ch-Ua":["\" Not;A Brand\";v=\"99\", \"Google Chrome\";v=\"91\", \"Chromium\";v=\"91\""],"Sec-Ch-Ua-Mobile":["?0"],"Upgrade-Insecure-Requests":["1"],"Sec-Fetch-Dest":["document"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","proto_mutual":true,"server_name":""}},"headers":{"X-Xss-Protection":["1; mode=block"],"Content-Length":["19"],"Cache-Control":["no-cache, must-revalidate"],"X-Content-Type-Options":["nosniff"],"X-Frame-Options":["SAMEORIGIN"],"X-Syncthing-Id":["LK7LVQ6-GJT2XBS-URYGXWG-QSMEKSG-NOPRWA5-4ZL2VBE-DJMD32Y-2NGQPAV"],"X-Syncthing-Version":["v1.17.0"],"Date":["Sun, 20 Jun 2021 13:40:32 GMT"],"Content-Type":["text/plain; charset=utf-8"]},"status":404}

Any ideas?

Not sure, to me it seems like its not stripping the syncthing prefix from urls, but I don’t know enough about caddy to be sure, or to advise anything. Best to ask caddy folks perhaps.

Caddy does nto do that by default. I added a uri strip prefix and that seems to have solved it. Thanks!

1 Like

Can you please update the docs? It should be trivial via github web editor.

I think it is updated now.

I don’t see any change from what it was before. What exactly needs adding?

I see it when I go to and click the pencil to edit. Must be something I am missing to submit it. Below is what I changed it to.

Caddy v2

.. code-block:: none

handle_path /syncthing/* {
reverse_proxy [http://localhost:8384](http://localhost:8384/)

I think the code formatting tries to do something smart as I see [foo](bar), but if that’s just formatting mistakes, then it’s identical to what’s there already?

Not sure what I am going wrong, but githb is beating me right now. Haha. Change it to the below as it worked for me.

Caddy v2

.. code-block:: none

    handle_path /syncthing/* {
        uri strip_preifx /suncthing
        reverse_proxy http://localhost:8384

I’ve updated the docs.

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