Skip to content

feat: support local HTTP proxy projects #372

Open

Description

@clvsh

Goal

Let a linked Project use PV's .test HTTPS routing for an already-running local HTTP service, such as a Node API. This should work for an ordinary standalone Project without requiring monorepo workspace or wildcard routing support.

Example:

pv link ~/Code/node-api --hostname api.laravel.test
# ~/Code/node-api/pv.yml
proxy: 3000

PV serves https://api.laravel.test and proxies requests to http://127.0.0.1:3000.

Behavior

  • proxy: <local-port> selects a served proxy mode. Validate the port and reject incompatible serving settings; serve: false remains resource-only and creates no route.
  • Terminate HTTPS at the PV Gateway using its local CA, route the Project's exact primary hostname to loopback, and preserve the original Host and forwarding headers.
  • Do not allocate or start a FrankenPHP worker for a proxy Project. PV does not start, supervise, or install the target application; the user runs the service.
  • Keep the linked Project's path, config, Managed Resource requirements, and environment mappings under the ordinary Project model. A missing Project directory follows existing missing-Project behavior.

Acceptance criteria

  • Update DESIGN.md and user documentation with the proxy config and process-ownership contract.
  • Integration tests verify HTTPS-to-loopback proxying, Host/forwarding headers, invalid ports or incompatible modes, and no PHP worker demand.
  • A standalone proxy Project can use an exact subdomain such as api.laravel.test without workspace config.

Related: #365 (workspace config) and #371 (automatic wildcard subdomains). Those features are independently useful; this issue does not require either one.

Activity

  1. pullfrog commented on Sep 29, 2026

    @pullfrog
    Contributor

    Assessment

    Actionable without #365 or #371. pv link --hostname already accepts api.laravel.test; the resolver sends .test traffic to the Gateway, which already terminates HTTPS and forwards headers. Today, however, crates/daemon/src/gateway.rs derives every served route from a FrankenPHP worker, and Project resource discovery assumes served Projects demand the PHP/FrankenPHP pair. A proxy route must bypass both assumptions while retaining the existing last-valid-config behavior.

    Plan

    1. Define the config contract in DESIGN.md and docs/user/README.md: proxy: 3000 means plain HTTP to 127.0.0.1:3000, with PV owning TLS/routing but not the target process. Accept only integer ports 1–65535; reject proxy combined with PHP serving settings such as root or php when served. Treat serve: false as resource-only even if proxy is present, with no route or worker. Document that an unavailable target is not started by PV and does not prevent the Gateway from running.
    2. Parse and validate proxy in crates/config (model.rs, parser.rs, relevant path validation) with typed errors and round-trip serialization. Validate on both pv link and watched config changes, preserving existing behavior that invalid edits do not replace the last valid state. Cover wrong YAML types, zero/out-of-range ports, incompatible keys, and serve: false in nearby config tests.
    3. Separate routing from PHP demand in crates/daemon/src/project_env.rs and gateway.rs: a served proxy Project retains its ordinary Project record, hostname reservations, resources, allocations, ${url}/TLS env behavior, and missing-directory handling, but demands no implicit PHP/FrankenPHP pair and contributes no worker. Extend the runtime plan and targeted/system reconciliation so PHP↔proxy and served↔resource-only transitions remove stale worker/route fragments safely; retain the last applied proxy target/fragment on invalid config and daemon restart without using the now-invalid config as desired state.
    4. Render a Gateway-only route in gateway_config.rs using the existing TLS, loopback binding, access log, Host, and X-Forwarded-* behavior, pointing at the validated loopback port. Keep explicit hostnames exact and reuse the existing config validation, fingerprint, and admin reload transaction rather than introducing a second Gateway.
    5. Verify end to end with config snapshots and daemon integration tests: an HTTP fixture on loopback receives a request through HTTPS at an exact subdomain with the original Host and forwarded scheme/host/client IP; no PHP worker/artifact demand appears; resource/env reconciliation still works; invalid config and mode transitions retain/remove routes as intended. Use the existing real-Caddy gateway E2E pattern for the actual proxy/header behavior, then run focused cargo nextest tests, formatting, and workspace Clippy per CONTRIBUTING.md.

    Scope assumption: the port is a fixed user-owned loopback listener; PV does not allocate it, test it as a managed runtime, or support upstream TLS, wildcard hosts, or workspace configuration. No implementation has started.

    Task list (3/3 completed)
    • Read issue, repository guidance and relevant architecture
    • Assess feasibility and scope against existing code and tests
    • Publish actionable plan or analysis to issue

    Pullfrog  | Implement plan ➔ | View workflow run | via Pullfrog | Using GPT Sol | 𝕏

  2. added
    feature
    gateway
    on Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featuregateway

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions