Skip to content

Add Proxy.PreserveHost option - #4

Merged
sergeyfast merged 1 commit into
masterfrom
proxy-preserve-host-v0.0.4
Jun 29, 2026
Merged

Add Proxy.PreserveHost option#4
sergeyfast merged 1 commit into
masterfrom
proxy-preserve-host-v0.0.4

Conversation

@sergeyfast

Copy link
Copy Markdown
Member

Summary

Adds a Proxy.PreserveHost option plus docs/deploy polish for the next patch release (v0.0.4).

  • Proxy.PreserveHost (*bool, default true) in internal/waf/proxy and internal/app/config: forwards the original client Host to the backend and advertises it via X-Forwarded-Host, so backends build correct absolute URLs. Set false to rewrite Host to the backend address (previous default behavior).
  • Documents PreserveHost in cfg/local.toml.dist.
  • Documents the required Captcha.Secret and the memory-storage multi-instance warning in README.
  • Drops baked-in -config/-json flags from deployments/Dockerfile so the config path and log format are supplied at deploy time.

⚠️ Behavior changes — read before deploy

  1. Default Host handling flips. Previously the proxy always rewrote Host to the backend address; now (default PreserveHost = true) backends receive the original client Host + X-Forwarded-Host. Deployments relying on the old behavior must set Proxy.PreserveHost = false.
  2. Dockerfile ENTRYPOINT is now bare (["/opt/wafsrv/wafsrv"]). The config path (-config / WAFSRV_CONFIG) and -json must be supplied by the orchestrator (Nomad). Without them the container won't find config.toml and won't start.

Test plan

  • go build ./..., go vet — clean
  • go test ./internal/... — green; new TestPreserveHost covers both preserve and rewrite modes
  • make fmt — no changes; lint clean on touched packages (internal/waf/proxy, internal/app)

- Add Proxy.PreserveHost (*bool, default true) in internal/waf/proxy
  and internal/app/config: forward the original client Host to the
  backend and advertise it via X-Forwarded-Host so backends build
  correct absolute URLs; set false to rewrite Host to the backend
  address (previous default behavior)
- Add TestPreserveHost covering both preserve and rewrite modes
- Document PreserveHost in cfg/local.toml.dist
- Document required Captcha.Secret and the memory-storage multi-instance
  warning in README
- Drop baked-in -config/-json flags from deployments/Dockerfile so the
  config path and log format are supplied at deploy time
@sergeyfast
sergeyfast merged commit fd49917 into master Jun 29, 2026
2 checks passed
@sergeyfast
sergeyfast deleted the proxy-preserve-host-v0.0.4 branch June 29, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant