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 the same host it is calling. 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:

Reverse proxy requirements

If you want to use an alternative reverse proxy that we have not documented, it must meet the following requirements:

YAML
- route: e.yourdomain.com/static/*
reverse_proxy: https://us-assets.i.posthog.com/static/*
host_header: us-assets.i.posthog.com
- route: e.yourdomain.com/*
reverse_proxy: https://us.i.posthog.com/*
host_header: us.i.posthog.com

Questions?

Was this page useful?

Next article

Setting up AWS CloudFront as a reverse proxy

CloudFront can be used as a reverse proxy. Although there are multiple other options if you're using AWS . By default, CloudFront doesn't forward headers, cookies, or query parameters received from the origin that PostHog uses. To set these up, you need an "origin request policy" as in the instructions below. Create a distribution On the AWS dashboard, search for CloudFront, then create a new CloudFront distribution Set the origin domain to your PostHog instance us.i.posthog.com or eu.i…

Read next article