Deploy PostHog Proxy

Capture more usage data in PostHog using a reverse proxy

Deploy PostHog Proxy

PostHog Proxy

PostHog/posthog-nginx-reverse-proxy

Just deployed

Deploy and Host PostHog Proxy on Railway

A reverse proxy that routes PostHog analytics events through your own domain, preventing ad blockers and filter lists from interfering with tracking.

About Hosting PostHog Proxy

This nginx proxy sits between your application and PostHog Cloud. Requests to your domain (e.yourdomain.com or https://your-project-name.up.railway.app/) are forwarded. Your analytics will work normally, but tracking/ad blockers can't tell you're using PostHog.

The proxy handles both analytics events and static assets, routing them to the correct PostHog region (US or EU) based on your configuration.

Common Use Cases

  • Ad blockers are preventing analytics collection
  • Filter lists can possibly block PostHog domains
  • You want analytics requests to come from your own domain

Dependencies for PostHog Proxy

  • Nginx web server (included in this deployment)
  • A PostHog project hosted on us.posthog.com or eu.posthog.com
  • Custom domain pointed to your Railway deployment (optional but recommended)

Deployment Dependencies

None

Setup

  1. Deploy this template to Railway
  2. Set POSTHOG_CLOUD_REGION to us eu depending on the cloud region you use PostHog in
  3. Update your PostHog initialization code to point to your Railway domain:
posthog.init('phc_YOUR_TOKEN', {
  api_host: 'https://e.yourdomain.com', // Your Railway domain. See Domain Configuration for best practices
  ui_host: 'https://us.posthog.com' // or eu.posthog.com
})

See the PostHog proxy docs for more details. For configuring an SDK other than JavaScript, see the PostHog SDK docs.

Domain configuration

Railway will provide you with a configurable domain after deployment that you can use. You can also use a custom domain. Regardless of what you use, we recommend a few best practices:

  • Don't use a subdomain that includes posthog, analytics, tracking, or other similar words which might cause events to be blocked.
  • 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.

Why deploy on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying PostHog Proxy on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


Template Content

More templates in this category

View Template
Bugsink
Self-hosted Error Tracking. Sentry-SDK compatible

View Template
Litlyx
Modern, developer-friendly, cookiefree analytics tool. Alternative to Umami

View Template
Superset
An open-source modern data exploration and visualization platform.