[SOLVED]Help to "reverse_proxying" two syncthing instances

1. Caddy version (caddy version):

v2.3.0

2. How I run Caddy:

a. System environment:

Debian10

b. Command:

caddy run

c. Service/unit/compose file:

N/A

d. My complete Caddyfile or JSON config:

{
debug
}

kobem.ovh {
       reverse_proxy   /_matrix/*      http://127.0.0.1:6167

       reverse_proxy   /debianSync     http://127.0.0.1:8384 {
               header_up Host localhost
       }

       reverse_proxy   /kobemSync      http://127.0.0.1:35911 {
               header_up Host localhost
       }

#        reverse_proxy   /               http://127.0.0.1:8384 {
#                header_up Host localhost
#        }
}

3. The problem I’m having:

I try to set up 2 instances of syncthing and I want to set up the reverse_proxy for these 2 instances. When I try to set an uri (/debainSync, /kobemSync) i got a 404 error.
When I try to reverse_proxying without uri (/) I got something but in y browser the result is awful, like no CSS.

4. Error messages and/or full log output:

This is the caddy log when an uri is set (and get a 404 error)

2021/02/25 18: 35: 24.502 info    http.log.access.log0    handled request {
    "request": {
      "remote_addr": "89.156.44.171:57906",
      "proto": "HTTP/2.0",
      "method": "GET",
      "host": "kobem.ovh",
      "uri": "/syncDebian",
      "headers": {
        "User-Agent": [
          "Mozilla/5.0 (X11; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0"
        ],
        "Accept": [
          "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
        ],
        "Accept-Language": [
          "en-US,en;q=0.5"
        ],
        "Accept-Encoding": [
          "gzip, deflate, br"
        ],
        "Dnt": [
          "1"
        ],
        "Cookie": [
          "CSRF-Token-P4DPI=vh4sVMNLzf3NwgtLWThzaDryzgr33gN9; CSRF-Token-R5OX3=FXCQyXTiTdyaW9AXRLDgtXTEZ6pJeaaL"
        ],
        "Upgrade-Insecure-Requests": [
          "1"
        ],
        "Te": [
          "trailers"
        ]
      },
      "tls": {
        "resumed": false,
        "version": 772,
        "cipher_suite": 4865,
        "proto": "h2",
        "proto_mutual": true,
        "server_name": "kobem.ovh"
      }
    },
    "common_log": "89.156.44.171 - - [25/Feb/2021:18:35:24 +0000] \"GET /syncDebian HTTP/2.0\" 0 0",
    "duration": 4.4692e-05,
    "size": 0,
    "status": 0,
    "resp_headers": {
      "Server": [
        "Caddy"
      ]
    }
  }
  2021/02/25 18: 35: 24.539 info    http.log.access.log0    handled request {{
    "request": {
      "remote_addr": "89.156.44.171:57906",
      "proto": "HTTP/2.0",
      "method": "GET",
      "host": "kobem.ovh",
      "uri": "/favicon.ico",
      "headers": {
        "Dnt": [
          "1"
        ],
        "Referer": [
          "https://kobem.ovh/syncDebian"
        ],
        "Cookie": [
          "CSRF-Token-P4DPI=vh4sVMNLzf3NwgtLWThzaDryzgr33gN9; CSRF-Token-R5OX3=FXCQyXTiTdyaW9AXRLDgtXTEZ6pJeaaL"
        ],
        "Te": [
          "trailers"
        ],
        "User-Agent": [
          "Mozilla/5.0 (X11; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0"
        ],
        "Accept": [
          "image/webp,*/*"
        ],
        "Accept-Language": [
          "en-US,en;q=0.5"
        ],
        "Accept-Encoding": [
          "gzip, deflate, br"
        ]
      },
      "tls": {
        "resumed": false,
        "version": 772,
        "cipher_suite": 4865,
        "proto": "h2",
        "proto_mutual": true,
        "server_name": "kobem.ovh"
      }
    },
    "common_log": "89.156.44.171 - - [25/Feb/2021:18:35:24 +0000] \"GET /favicon.ico HTTP/2.0\" 0 0",
    "duration": 3.4079e-05,
    "size": 0,
    "status": 0,
    "resp_headers": {
      "Server": [
        "Caddy"
      ]
    }
  }
  2021/02/25 18: 36: 03.079 error   http.log.access.log0    handled request {
    "request": {
      "remote_addr": "89.156.44.171:57910",
      "proto": "HTTP/2.0",
      "method": "GET",
      "host": "kobem.ovh",
      "uri": "/debianSync",
      "headers": {
        "Cookie": [
          "CSRF-Token-P4DPI=vh4sVMNLzf3NwgtLWThzaDryzgr33gN9; CSRF-Token-R5OX3=FXCQyXTiTdyaW9AXRLDgtXTEZ6pJeaaL"
        ],
        "Upgrade-Insecure-Requests": [
          "1"
        ],
        "Te": [
          "trailers"
        ],
        "User-Agent": [
          "Mozilla/5.0 (X11; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0"
        ],
        "Accept": [
          "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
        ],
        "Accept-Language": [
          "en-US,en;q=0.5"
        ],
        "Accept-Encoding": [
          "gzip, deflate, br"
        ],
        "Dnt": [
          "1"
        ]
      },
      "tls": {
        "resumed": false,
        "version": 772,
        "cipher_suite": 4865,
        "proto": "h2",
        "proto_mutual": true,
        "server_name": "kobem.ovh"
      }
    },
    "common_log": "89.156.44.171 - - [25/Feb/2021:18:36:03 +0000] \"GET /debianSync HTTP/2.0\" 404 19",
    "duration": 0.001814627,
    "size": 19,
    "status": 404,
    "resp_headers": {
      "X-Xss-Protection": [
        "1; mode=block"
      ],
      "Date": [
        "Thu, 25 Feb 2021 18:36:03 GMT"
      ],
      "Server": [
        "Caddy"
      ],
      "X-Frame-Options": [
        "SAMEORIGIN"
      ],
      "X-Syncthing-Version": [
        "v1.0.0-ds1"
      ],
      "Content-Length": [
        "19"
      ],
      "Cache-Control": [
        "no-cache, must-revalidate"
      ],
      "X-Content-Type-Options": [
        "nosniff"
      ],
      "Content-Type": [
        "text/plain; charset=utf-8"
      ],
      "X-Syncthing-Id": [
        "P4DPIBJ-3I5CKW6-HQWQLX5-ZTZT3K5-OPUFQJV-WMXAA25-2A6ADBU-7PXBLA3"
      ]
    }
  }

5. What I already tried:

I have already defined the header_up directive as I saw in another thread of the forum.
Now I don’t know what to do…

6. Links to relevant resources:

If you need more info please ask. Thanks for your time.

Path matching is exact in Caddy, so /debianSync will only match exactly /debianSync and not /debianSync/foo. So if you need to match any subpaths, you’ll need to add a * like this: /debianSync*

That said, generally I recommend using subdomains rather than subpaths for separate apps:

Thanks @francislavoie
I update caddyfile to use 1 subdomain for each instance and it’s ok but it’s look awful without CSS.
I think I have to ask the syncthing community.

What’s your Caddyfile now? Lack of CSS is typically because you’re not proxying all the necessary paths.

The content of Caddyfile now :

{
}

kobem.ovh {
#       reverse_proxy   /_matrix/*      http://127.0.0.1:6167

#       reverse_proxy   /               http://127.0.0.1:8384 {
#               header_up Host localhost
#       }
}

syncDebian.kobem.ovh {
        reverse_proxy   /       http://127.0.0.1:8384 {
                header_up Host localhost
        }
}

syncKobem.kobem.ovh {
        reverse_proxy   /       http://127.0.0.1:35911 {
                header_up Host localhost
        }
}

EDIT: I Forgot to remove the ‘/’ and now it’s working, thank you !
The right Caddyfile content is :

{
}

kobem.ovh {
#       reverse_proxy   /_matrix/*      http://127.0.0.1:6167

#       reverse_proxy   /               http://127.0.0.1:8384 {
#               header_up Host localhost
#       }
}

syncDebian.kobem.ovh {
        reverse_proxy    http://127.0.0.1:8384 {
                header_up Host localhost
        }
}

syncKobem.kobem.ovh {
        reverse_proxy    http://127.0.0.1:35911 {
                header_up Host localhost
        }
}
1 Like

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