Skip to content

fix: proxy detection behind pf redirects#136

Open
yangshun wants to merge 1 commit intovercel-labs:mainfrom
yangshun:fix/pf-redirect-proxy-detection
Open

fix: proxy detection behind pf redirects#136
yangshun wants to merge 1 commit intovercel-labs:mainfrom
yangshun:fix/pf-redirect-proxy-detection

Conversation

@yangshun
Copy link
Copy Markdown

@yangshun yangshun commented Mar 18, 2026

Summary

Fixes a false positive existing proxy check when /etc/pf.conf is modified.

Background

I wanted to access my sites without any port numbers, so I modifed my /etc/pf.conf and added this line

rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port 80 -> 127.0.0.1 port 1355

After modifying it, I enabled pfctl so that I can access at my app at http://myapp.localhost, which gets routed to http://myapp.localhost:1355:

sudo pfctl -e

This worked fine. But after I stopped the portless proxy server, I could not start it again, and I get this error "Proxy failed to start (timed out)".

Things recovered after disabling pfctl:

sudo pfctl -d

I could start portless again like before.

My changes to /etc/pf.conf led portless to think that the proxy server is running when it isn't. I think this is a bug in portless.

Fix

  • Add a listener-port response header so health checks can tell which local port actually accepted the request
  • Tighten isProxyRunning() to reject PF/NAT redirect false positives when the probed port differs from the actual listener port
  • Add regression coverage for redirected-port detection and proxy response headers

Testing

  • pnpm --filter portless test
  • pnpm --filter portless typecheck
  • pnpm --filter portless build

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 18, 2026

@yangshun is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@yangshun yangshun changed the title Fix proxy detection behind pf redirects fix: proxy detection behind pf redirects Mar 18, 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.

1 participant