From 4129c07170ed7e2a24426c041d25ab8dab6c0000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 23 Feb 2026 16:30:17 +0100 Subject: [PATCH] chore: use ldflags to set Server header --- Dockerfile | 2 +- alpine.Dockerfile | 2 +- caddy/module.go | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index b0ae116c69..c40488b8e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -118,7 +118,7 @@ ENV CGO_LDFLAGS="-L/usr/local/lib -lssl -lcrypto -lreadline -largon2 -lcurl -lon WORKDIR /go/src/app/caddy/frankenphp RUN GOBIN=/usr/local/bin \ - ../../go.sh install -ldflags "-w -s -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy'" -buildvcs=true && \ + ../../go.sh install -ldflags "-w -s -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy' -X 'github.com/caddyserver/caddy/v2/modules/caddyhttp.ServerHeader=FrankenPHP Caddy'" -buildvcs=true && \ setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \ cp Caddyfile /etc/frankenphp/Caddyfile && \ frankenphp version && \ diff --git a/alpine.Dockerfile b/alpine.Dockerfile index 8e4318db48..31650af4c6 100644 --- a/alpine.Dockerfile +++ b/alpine.Dockerfile @@ -123,7 +123,7 @@ ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLA WORKDIR /go/src/app/caddy/frankenphp RUN GOBIN=/usr/local/bin \ - ../../go.sh install -ldflags "-w -s -extldflags '-Wl,-z,stack-size=0x80000' -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy'" -buildvcs=true && \ + ../../go.sh install -ldflags "-w -s -extldflags '-Wl,-z,stack-size=0x80000' -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy' -X 'github.com/caddyserver/caddy/v2/modules/caddyhttp.ServerHeader=FrankenPHP Caddy'" -buildvcs=true && \ setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \ ([ -z "${NO_COMPRESS}" ] && upx --best /usr/local/bin/frankenphp || true) && \ frankenphp version && \ diff --git a/caddy/module.go b/caddy/module.go index e30535093b..189b295697 100644 --- a/caddy/module.go +++ b/caddy/module.go @@ -22,8 +22,6 @@ import ( "github.com/dunglas/frankenphp/internal/fastabs" ) -var serverHeader = []string{"FrankenPHP Caddy"} - // FrankenPHPModule represents the "php_server" and "php" directives in the Caddyfile // they are responsible for forwarding requests to FrankenPHP via "ServeHTTP" // @@ -249,8 +247,6 @@ func (f *FrankenPHPModule) ServeHTTP(w http.ResponseWriter, r *http.Request, _ c return caddyhttp.Error(http.StatusInternalServerError, err) } - // TODO: set caddyhttp.ServerHeader when https://github.com/caddyserver/caddy/pull/7338 will be released - w.Header()["Server"] = serverHeader if err = frankenphp.ServeHTTP(w, fr); err != nil && !errors.As(err, &frankenphp.ErrRejected{}) { return caddyhttp.Error(http.StatusInternalServerError, err) }