1. The problem I’m having:
I’m using caddy reverse-proxy locally to speed up development against a single-threaded PHP app on Windows by running 5 instances of the app with caddy sitting in front.
While this works reasonably well, I’m seeing 2 issues:
- When the upstream server responds with a 408 timeout status code, Caddy retries the request instead of forwarding that response to the browser
- Given that the servers can only handle 1 request at a time, I’d like to use the least_conn load balancing strategy to make best use of having 5 instances. By default, caddy doesn’t seem to do this.
My pwsh script to start caddy looks like this:
$processes = @()
$ports = 8081..8085
$ports | ForEach-Object {
$processes += Start-Process php -PassThru -ArgumentList "artisan serve --port $_" -NoNewWindow
}
$upstreams = ($ports | ForEach-Object { "--to=:$_" })
caddy reverse-proxy --from :8000 @upstreams
$processes | ForEach-Object { Stop-Process $_.Id }
I’ve tried creating a Caddyfile in the same directory, but either Caddy isn’t finding it or is silently rejecting my syntax. I’ve also tried configuring via the CLI but if the options are available to do so I can’t find them.
2. Error messages and/or full log output:
3. Caddy version:
2.7.6
4. How I installed and ran Caddy:
I used winget install caddy
to install. Script to run is pasted above.
a. System environment:
Windows 11
b. Command:
See above
c. Service/unit/compose file:
n/a
d. My complete Caddy config:
Trying to figure this out!