1. The problem I’m having:
I have two services running on two different ports: an Ollama server on 11434 and a Whisper server on 5000 and would like to restrict those ports using API keys passed along in the auth header. I have followed a number of tutorials using reverse-proxy to try and black my site, but after launching caddy I am still able to get to the site without any auth errors or caddy output.
I am also running an apache2 webserver as well and I was hoping to be able to keep it, rather then using Caddy to handle those requests.
2. Error messages and/or full log output:
kim@el3ktra:~$ caddy run --config ./Caddyfile --envfile ./caddy.env
2025/02/13 03:09:59.999 INFO using config from file {"file": "./Caddyfile"}
2025/02/13 03:10:00.000 INFO adapted config to JSON {"adapter": "caddyfile"}
2025/02/13 03:10:00.000 INFO admin admin endpoint started {"address": "localhost:2019", "enforce_origin": false, "origins": ["//[::1]:2019", "//127.0.0.1:2019", "//localhost:2019"]}
2025/02/13 03:10:00.001 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0xc000754d00"}
2025/02/13 03:10:00.001 DEBUG http.auto_https adjusted config {"tls": {"automation":{"policies":[{}]}}, "http": {"servers":{"srv0":{"listen":[":5000"],"routes":[{"handle":[{"handler":"subroute","routes":[{"handle":[{"handler":"authentication","providers":{"http_basic":{"accounts":[{"password":"{env.BASIC_USER_AUTH}","username":"{env.BASIC_AUTH_USER}"}],"hash":{"algorithm":"bcrypt"},"hash_cache":{}}}},{"handler":"reverse_proxy","upstreams":[{"dial":"localhost:5000"}]}]}]}],"terminal":true}],"automatic_https":{"skip":["el3ktra.net"]}}}}}
2025/02/13 03:10:00.001 DEBUG http starting server loop {"address": "[::]:5000", "tls": false, "http3": false}
2025/02/13 03:10:00.001 WARN http HTTP/2 skipped because it requires TLS {"network": "tcp", "addr": ":5000"}
2025/02/13 03:10:00.001 WARN http HTTP/3 skipped because it requires TLS {"network": "tcp", "addr": ":5000"}
2025/02/13 03:10:00.001 INFO http.log server running {"name": "srv0", "protocols": ["h1", "h2", "h3"]}
2025/02/13 03:10:00.001 INFO autosaved config (load with --resume flag) {"file": "/home/kim/.config/caddy/autosave.json"}
2025/02/13 03:10:00.001 INFO serving initial configuration
2025/02/13 03:10:00.006 INFO tls cleaning storage unit {"storage": "FileStorage:/home/kim/.local/share/caddy"}
2025/02/13 03:10:00.008 INFO tls finished cleaning storage units
3. Caddy version:
2.9.1 h1
4. How I installed and ran Caddy:
curl https://webi.sh/caddy | sh
a. System environment:
Ubuntu 24.04.1 LTS
Arch: x86_64
b. Command:
caddy run --config ./Caddyfile --envfile ./caddy.env
c. Service/unit/compose file:
PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.
d. My complete Caddy config:
*caddy.env:*
BASIC_AUTH_USER='apitoken'
BASIC_USER_AUTH='<generated from caddy hash-password>'
*Cadyfile: (port 5000 version)*
{
debug
}
http://el3ktra.net:5000 {
basic_auth {
{env.BASIC_AUTH_USER} {env.BASIC_USER_AUTH}
}
reverse_proxy localhost:5000
}