diff --git a/cmd/anubis/main.go b/cmd/anubis/main.go index da30ad5..add0fec 100644 --- a/cmd/anubis/main.go +++ b/cmd/anubis/main.go @@ -5,6 +5,7 @@ import ( "context" "crypto/ed25519" "crypto/rand" + "crypto/tls" "embed" "encoding/hex" "errors" @@ -55,6 +56,7 @@ var ( redirectDomains = flag.String("redirect-domains", "", "list of domains separated by commas which anubis is allowed to redirect to. Leaving this unset allows any domain.") 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, set to an empty string to disable proxying when only using auth request") + targetInsecureSkipVerify = flag.Bool("target-insecure-skip-verify", false, "if true, skips TLS validation for the backend") healthcheck = flag.Bool("healthcheck", false, "run a health check against Anubis") 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") debugBenchmarkJS = flag.Bool("debug-benchmark-js", false, "respond to every request with a challenge for benchmarking hashrate") @@ -133,7 +135,7 @@ func setupListener(network string, address string) (net.Listener, string) { return listener, formattedAddress } -func makeReverseProxy(target string) (http.Handler, error) { +func makeReverseProxy(target string, insecureSkipVerify bool) (http.Handler, error) { targetUri, err := url.Parse(target) if err != nil { return nil, fmt.Errorf("failed to parse target URL: %w", err) @@ -155,6 +157,13 @@ func makeReverseProxy(target string) (http.Handler, error) { transport.RegisterProtocol("unix", libanubis.UnixRoundTripper{Transport: transport}) } + if insecureSkipVerify { + slog.Warn("TARGET_INSECURE_SKIP_VERIFY is set to true, TLS certificate validation will not be performed", "target", target) + transport.TLSClientConfig = &tls.Config{ + InsecureSkipVerify: true, + } + } + rp := httputil.NewSingleHostReverseProxy(targetUri) rp.Transport = transport @@ -196,7 +205,7 @@ func main() { // when using anubis via Systemd and environment variables, then it is not possible to set targe to an empty string but only to space if strings.TrimSpace(*target) != "" { var err error - rp, err = makeReverseProxy(*target) + rp, err = makeReverseProxy(*target, *targetInsecureSkipVerify) if err != nil { log.Fatalf("can't make reverse proxy: %v", err) } diff --git a/docs/docs/CHANGELOG.md b/docs/docs/CHANGELOG.md index ddd1722..26e2a0e 100644 --- a/docs/docs/CHANGELOG.md +++ b/docs/docs/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- Add `--target-insecure-skip-verify` flag/envvar to allow Anubis to hit a self-signed HTTPS backend. + ## v1.18.0: Varis zos Galvus The big ticket feature in this release is [CEL expression matching support](https://anubis.techaro.lol/docs/admin/configuration/expressions). This allows you to tailor your approach for the individual services you are protecting. diff --git a/docs/docs/admin/installation.mdx b/docs/docs/admin/installation.mdx index 095cf98..431386f 100644 --- a/docs/docs/admin/installation.mdx +++ b/docs/docs/admin/installation.mdx @@ -73,6 +73,21 @@ Anubis uses these environment variables for configuration: | `USE_REMOTE_ADDRESS` | unset | If set to `true`, Anubis will take the client's IP from the network socket. For production deployments, it is expected that a reverse proxy is used in front of Anubis, which pass the IP using headers, instead. | | `WEBMASTER_EMAIL` | unset | If set, shows a contact email address when rendering error pages. This email address will be how users can get in contact with administrators. | +
+Advanced configuration settings + +:::note + +If you don't know or understand what these settings mean, ignore them. These are intended to work around very specific issues. + +::: + +| Environment Variable | Default value | Explanation | +| :---------------------------- | :------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------- | +| `TARGET_INSECURE_SKIP_VERIFY` | `false` | If `true`, skip TLS certificate validation for targets that listen over `https`. If your backend does not listen over `https`, ignore this setting. | + +
+ For more detailed information on configuring Open Graph tags, please refer to the [Open Graph Configuration](./configuration/open-graph.mdx) page. ### Using Base Prefix