Skip to content

fix: match REMOTE_ADDR and SERVER_NAME of dispatcher requests to the SAPI - #5

Open
roxblnfk wants to merge 1 commit into
1.xfrom
fix/unix-peer-server-params
Open

roxblnfk wants to merge 1 commit into
1.xfrom
fix/unix-peer-server-params

Conversation

@roxblnfk

@roxblnfk roxblnfk commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

🔍 What was changed

  • A unix-socket peer now gets REMOTE_ADDR=127.0.0.1 and REMOTE_PORT=0, as the Rapira SAPI sets them in Worker mode. Before, the socket path or nothing, so trusted proxies on private subnets behind nginx on a unix socket were trusted in Worker mode only.
  • SERVER_NAME is no longer taken from the client's authority, which the request still carries in HTTP_HOST. When the client sent no authority, the URI's host is synthesized by the host (listener address, or the configured server_name on a unix socket), so it still fills SERVER_NAME and getHost() keeps a host to fall back on.

Why?

Ports rapira-rs/sdk-php#16. Taking the configured server name and port from the dispatcher is tracked in rapira-rs/sdk-php#17, pending rapira-rs/contract#7.

Checklist

  • How was this tested:
    • Unit tests updated
    • Unit and Feature suites and php-cs-fixer run locally
    • Acceptance suite

Review notes

  • The SDK drops SERVER_NAME outright; here it stays for a request without an authority, because Symfony's getHost() falls back to SERVER_NAME when HTTP_HOST is missing, and on a unix listener nothing else would give it a host.

fix: leave the client's authority out of SERVER_NAME

Behind a proxy on a unix socket, REMOTE_ADDR held the socket path or nothing, so trusted proxies matching on private subnets failed in Dispatcher mode while Worker mode trusted the proxy.

The SAPI sets SERVER_NAME from the configured server name, which a dispatcher cannot see yet; the client's authority under that name passed a client value off as a server one. Without an authority the URI's host is the host's own synthesis, so it still fills SERVER_NAME for getHost() to fall back on.

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
@roxblnfk
roxblnfk requested a review from a team as a code owner October 8, 2026 11:41
@coderabbitai

coderabbitai Bot commented Oct 8, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 3e51c8b8-3348-4a6c-b43a-d384b7b6f300
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

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