Self-hosted proxy reference
Contents
This page covers requirements and troubleshooting for self-hosted reverse proxies. For platform-specific setup, see the individual proxy guides.
Requirements
Your proxy must route requests to these PostHog domains:
| Region | Static assets /static/* and config /array/* | Everything else |
|---|---|---|
| US | us-assets.i.posthog.com | us.i.posthog.com |
| EU | eu-assets.i.posthog.com | eu.i.posthog.com |
Check your project URL in the PostHog app to confirm your region.
Checklist
- Set the
Hostheader to the PostHog domain (e.g.,Host: us.i.posthog.com). Without this, you'll get 401 errors. - Forward the
Authorizationheader when its value starts withBearer phc_. Capture v1 SDKs send the project token asAuthorization: Bearer <token>. Strip any otherAuthorizationvalue, such as session tokens your app adds to its own requests. If your project token doesn't start withphc_, forward only the exact valueBearer <your project token>instead. - Forward every
PostHog-*header, plusContent-Type,Content-Encoding, andUser-Agent, unchanged. Capture v1 SDKs need them, and their request bodies can be compressed withgzip,deflate,br, orzstd. - Route
/i/v1/*paths to the regional ingestion host,us.i.posthog.comoreu.i.posthog.com. - Allow
GETandPOST** on all paths. - Support 64MB request bodies, session recordings can be large.
- Forward
X-Forwarded-Forto preserve client IPs for geolocation. - Avoid obvious paths like
/analytics,/posthog, or/ph. Use/eor/ingestinstead.
SDK configuration
When using a proxy, set both api_host and ui_host:
Without ui_host, the toolbar and session recordings player won't work correctly.
Configure custom request paths
The JavaScript Web SDK can expose custom paths with rewriteRequestPath. Keep api_host and ui_host configured as shown above. The path option does not replace either host option.
Your proxy routes must match every rewritten path and restore the standard PostHog path. Preserve query parameters when you forward requests. Route rewritten /array/* and /static/* paths to the regional asset host. Route rewritten API and Feature Flags paths to the regional ingestion host. See customize reverse proxy request paths for an SDK example.
Troubleshooting
401 Unauthorized
PostHog rejected the request. Check:
- Host header: Must match the PostHog domain you're proxying to
- Region: Proxy must point to same region as your project
- Project token: Legacy SDKs send it in the request body, which some platforms strip. Capture v1 SDKs send it as
Authorization: Bearer <token>. If the response'serrorfield ismissing_authorization, your proxy dropped that header. A proxy that keeps onlyBearer phc_values drops a project token that doesn't start withphc_.
400 Bad Request
If a capture v1 SDK gets a 400 response whose error field is missing_required_headers, your proxy dropped a header that capture v1 requires. Forward PostHog-Sdk-Info, PostHog-Attempt, PostHog-Request-Id, PostHog-Request-Timestamp, Content-Type, and User-Agent unchanged.
405 Method Not Allowed
Your proxy is blocking the HTTP method. Ensure both GET and POST are allowed.
502 Bad Gateway
Your proxy can't reach PostHog. Test connectivity:
If this fails, check DNS, firewall rules (port 443), and internet access. For SSL errors, enable SNI in your proxy settings.
CORS errors
Use a relative path to avoid cross-origin issues:
Events not appearing
- Check your token: Find it in project settings. Use the project token, not a personal key.
- Verify the region: Must match your PostHog project.
- Wait a few minutes: Check the activity feed before assuming it's broken.
Wrong geolocation / same location for all users
Your proxy isn't forwarding client IPs. Set the X-Forwarded-For header to the original client IP. If behind multiple proxies (e.g., Cloudflare + your proxy), ensure you're forwarding the original IP, not an intermediate one.
Large recordings failing
Check body size limits in your:
- Web server (nginx:
client_max_body_size, Apache:LimitRequestBody) - CDN or WAF
- Serverless function (if applicable)
PostHog needs up to 64MB per message for session recordings.
Toolbar or recordings player not working
You're missing ui_host in your SDK config. See SDK configuration above.
Still having issues?
For self-hosted proxies, check your proxy's logs and documentation, or ask in the PostHog community. If you're using the managed reverse proxy, contact support.





