Deploying a reverse proxy to PostHog Cloud

Last updated:

|Edit this page

A reverse proxy allows you to send events to PostHog Cloud using your own domain.

This means that events are sent from your own domain and are less likely to be intercepted by tracking blockers. You'll be able to capture more usage data without having to self-host PostHog.

Setting up a reverse proxy means setting up a service to redirect requests from a subdomain you choose (like e.yourdomain.com) to PostHog. It is best practice to use a subdomain that does not include posthog, analytics, tracking, or other similar words.

Note: PostHog Cloud requires that the proxy sets the Host header to eu.posthog.com for requests sent to https://eu.posthog.com and app.posthog.com for requests sent to https://app.posthog.com. Check the guides below on how to do that for several proxies.

You then use this subdomain as your instance host in the initialization of PostHog instead of app.posthog.com or eu.posthog.com.

Make sure to pass the proper ui_host parameter when initializing our browser integration, so that links to the PostHog interface point to the correct host.

Deploying a reverse proxy

Options for deploying a reverse proxy include:

Questions?

Was this page useful?

Next article

Setting up Caddy as a reverse proxy

We like using Caddy because it makes setting up the reverse proxy and TLS a breeze. You'll want to sub out YOUR_TRACKING_DOMAIN for whatever domain you use for proxying to PostHog. We'd suggest something like e.yourdomain.com or the like. Make sure your DNS records point to your machine and that ports 80 and 443 are open to the public and directed toward Caddy. If you want to use a config file instead, you can use something of the form:

Read next article