Proxy Rules
Understanding how PortPilot routes traffic to your dev servers.
How Routing Works
The PortPilot proxy uses the HTTP Host header to determine which project a request is for. When you visit https://my-app.test, the proxy:
- Extracts
my-app.testfrom the Host header - Looks up the project name (
my-app) in the config - Finds the assigned port (e.g., 3001)
- Forwards the request to
http://localhost:3001
The Hosts File
For your browser to resolve .test domains to localhost, PortPilot adds entries to your system's hosts file. Run portpilot sync to update these entries:
# Hosts file entries managed by PortPilot# PortPilot Start127.0.0.1 my-app.test127.0.0.1 my-api.test127.0.0.1 my-blog.test# PortPilot EndSync After Adding Projects
Remember to run portpilot sync (with sudo/admin) after adding or removing projects to update the hosts file.
WebSocket Support
The proxy includes WebSocket upgrade handlers, which means Hot Module Replacement (HMR) works seamlessly. Your development experience with frameworks like Next.js, Vite, and webpack-dev-server will work exactly as expected.
Proxy Commands
Control the proxy with these commands:
# Run proxy in foreground (see logs in terminal)portpilot proxy# Run proxy in background (daemon mode)portpilot proxy -d# Stop the background proxyportpilot proxy stop# Check if proxy is runningportpilot proxy status# View proxy logsportpilot proxy logs# Force HTTP to HTTPS redirectportpilot proxy --https-redirectHTTPS Redirect
By default, both HTTP (port 80) and HTTPS (port 443) work independently. If you want to force all HTTP traffic to redirect to HTTPS, use the --https-redirect flag:
portpilot proxy -d --https-redirect