Using Railway as a reverse proxy

Warning
  1. The following self-hosted proxy isn't provided by PostHog, so we can't take responsibility for it! If unsure, we recommend using our managed reverse proxy.

  2. If you are using the EU cloud then use eu instead of us in all domains (e.g. us.i.posthog.com -> eu.i.posthog.com).

  3. Avoid using generic or common path names like /analytics, /tracking, /ingest, or /posthog for your reverse proxy. They will most likely be blocked. Instead, use a non-obvious path name or something random and unique to your application that's unlikely to appear in a filter list.

Railway provides a simple way to deploy a reverse proxy for PostHog. Click the button below to deploy a reverse proxy on Railway:

Deploy on Railway

Make sure to set the POSTHOG_CLOUD_REGION variable to either us or eu depending on your PostHog cloud region.

Afterwards, configure your PostHog client to send requests through your reverse proxy.

JavaScript
posthog.init('<ph_project_api_key>', {
api_host: 'https://your-project-name.up.railway.app', // Your Railway domain
ui_host: 'https://us.posthog.com', // Or https://eu.posthog.com depending on your cloud region.
})

Community questions

Was this page useful?

Questions about this page? or post a community question.