Skip to content

feat(fastcgi): populate SERVER_ADDR by default - #7912

Merged
steadytao merged 5 commits into
caddyserver:masterfrom
renich:feat/fastcgi-server-addr
Aug 10, 2026
Merged

feat(fastcgi): populate SERVER_ADDR by default#7912
steadytao merged 5 commits into
caddyserver:masterfrom
renich:feat/fastcgi-server-addr

Conversation

@renich

@renich renich commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Populate the SERVER_ADDR FastCGI environment variable using the local socket address of the incoming connection from the request context. Only sets SERVER_ADDR when local address resolves to a valid IP address.

Fixes #7891

Populate the SERVER_ADDR FastCGI environment variable using the local socket address of the incoming connection from the request context. This improves out-of-the-box compatibility for PHP applications that rely on $_SERVER['SERVER_ADDR'] (such as legacy frameworks and custom telemetry packages) when migrating from Nginx or Apache.

Co-developed-by: Gemini AI <renich+gemini@woralelandia.com>
Signed-off-by: Rénich Bon Ćirić <renich@woralelandia.com>
@CLAassistant

CLAassistant commented Jul 27, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@steadytao steadytao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also cover IPv4, IPv6, missing local-address context, Unix-domain addresses and an explicitly configured SERVER_ADDR override.

Comment thread modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go Outdated
@steadytao

Copy link
Copy Markdown
Member

Ah, quick note is we require an AI assistance disclosure as well.

@renich

renich commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Ah, quick note is we require an AI assistance disclosure as well.

Hi Zen (@steadytao),

AI assistance was already disclosed in commit 445b281:

Co-developed-by: Gemini AI renich+gemini@woralelandia.com

For full clarity, the specific model used during pair programming is Gemini 3.6 Flash with effort set to High.

renich added 2 commits August 3, 2026 15:13
Validate that SERVER_ADDR is only populated when the local address parses as a valid IP address, preventing Unix socket paths from being assigned if SplitHostPort fails. Add test cases covering IPv4, IPv6, missing context, Unix sockets, and explicit overrides.

Co-developed-by: Gemini AI <renich+gemini@woralelandia.com>
Signed-off-by: Rénich Bon Ćirić <renich@woralelandia.com>
@renich
renich requested a review from steadytao August 3, 2026 21:16

@steadytao steadytao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay. LGTM.

@steadytao
steadytao merged commit 546752e into caddyserver:master Aug 10, 2026
25 checks passed
@francislavoie francislavoie added this to the v2.11.5 milestone Aug 10, 2026
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.

Proposal: Populate SERVER_ADDR FastCGI environment variable by default

4 participants