I built the following config files (some obfuscation is in play)
Had to post on pasted bin as there is a limit of links
In C:\Caddy there is an index.html file
This is what I am observing:
Site 1 does not have an explicit HTTP binding however if I browse to it on HTTP it redirects to the backend specified by site 2
Site 2: no issues proxies HTTP and HTTPs as expected
Site 3: No issues proxies HTTP traffic as expected
Site 4: Proxies to backend on site 2 if HTTP is used. If HTTPS is specified the correct file is served up (no proxying)
Site 5: no issues serves up HTML file as expected
Site 6: Serves HTML file From C:\Caddy (where the executable is)
What I am struggling with
Why do HTTP sites proxy to backends while HTTP do not?
Is there a precendene I need to be aware of?
Do proxy statements live withing blocks?
You can get around this by instead using the proper code formatting. You can do that by indenting code lines with four spaces, opening and closing a code block with three backticks ( ``` ), or selecting your text in the editor and clicking the code button ().
Immediately I see one large problem with your Caddyfile. Looking at the specification for Caddyfile structure (available at https://caddyserver.com/docs/caddyfile#structure), you must open a site definition block with a brace at the end of the label line, not on a new line - like so:
I believe all of your issues stem from the unintentionally global scope of all your Caddy directives. With the correct structure, I suspect you will find Caddy’s behaviour much more consistent.