Change how to make Anubis work without a reverse proxy (#86)

* Change how to make Anubis work without a reverse proxy

* Apply suggestions from code review

Co-authored-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Henri Vasserman <henv@hot.ee>

* add support for unix sockets.

* add env var docs

* lib: fix tests

Signed-off-by: Xe Iaso <me@xeiaso.net>

---------

Signed-off-by: Henri Vasserman <henv@hot.ee>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Co-authored-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
Henri Vasserman 2025-03-28 19:38:34 +02:00 committed by GitHub
parent e9a6ebffbb
commit 57c3e9f1b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 26 additions and 10 deletions

View file

@ -45,7 +45,7 @@ var (
slogLevel = flag.String("slog-level", "INFO", "logging level (see https://pkg.go.dev/log/slog#hdr-Levels)")
target = flag.String("target", "http://localhost:3923", "target to reverse proxy to")
healthcheck = flag.Bool("healthcheck", false, "run a health check against Anubis")
debugXRealIPDefault = flag.String("debug-x-real-ip-default", "", "If set, replace empty X-Real-Ip headers with this value, useful only for debugging Anubis and running it locally")
useRemoteAddress = flag.Bool("use-remote-address", false, "read the client's IP address from the network request, useful for debugging and running Anubis on bare metal")
)
func keyFromHex(value string) (ed25519.PrivateKey, error) {
@ -214,7 +214,7 @@ func main() {
var h http.Handler
h = s
h = internal.DefaultXRealIP(*debugXRealIPDefault, h)
h = internal.RemoteXRealIP(*useRemoteAddress, *bindNetwork, h)
h = internal.XForwardedForToXRealIP(h)
srv := http.Server{Handler: h}
@ -226,7 +226,7 @@ func main() {
"serveRobotsTXT", *robotsTxt,
"target", *target,
"version", anubis.Version,
"debug-x-real-ip-default", *debugXRealIPDefault,
"use-remote-address", *useRemoteAddress,
)
go func() {