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/* | 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. - 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
/analyticsor/posthog, use/eor/phinstead.
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.
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
- Request body: Some platforms strip it, removing your API key
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 API key: Find it in project settings. Use the project API key, 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.