How to proxy analytics through your own domain
If your analytics dashboard shows fewer visitors than your server logs, some events probably never left the browser. Ad blockers and browser privacy tools stop requests to known analytics vendors. To fix this, serve analytics requests from a path on your own domain and forward them to the vendor from your own infrastructure.
This guide covers three ways to do that on Render:
- a rewrite rule on a static site
- framework rewrites inside a web service you already run
- a small dedicated reverse proxy web service
A decision table at the end helps you pick one.
You need:
- A static site or web service on Render with a custom domain.
- A client-side analytics SDK or script tag that already sends events. The examples use PostHog and Plausible.
Documentation and prices checked: Render between 2026-09-11 and 2026-11-20, PostHog between 2026-10-09 and 2026-11-20, Plausible between 2026-10-09 and 2026-11-05.
Why analytics requests get blocked
Per PostHog's documentation, ad blockers maintain lists of known analytics domains and block requests to them. Blocklists also match obvious paths. PostHog warns that blockers catch path names like /analytics, /tracking, /telemetry and /posthog. Per Plausible's documentation, some visitors use adblockers or privacy tools that block analytics scripts, and some blocklist maintainers block all analytics regardless of a vendor's privacy practices.
With a first-party path, the browser sends requests to your domain on an unremarkable path, so domain-based rules have nothing to match. Your infrastructure then forwards the request to the vendor. Plausible describes a proxied script as indistinguishable from your own files.
How much a proxy recovers depends on your audience:
- PostHog estimates that a reverse proxy typically increases event capture by 10-30%, depending on your user base.
- Plausible estimates that its default, unproxied script misses between 5% and 25% of visitors with strict blockers, depending on audience.
Treat both figures as vendor estimates for their own products, not predictions for your site.
Proxying changes how events reach the vendor, not whether you may collect them. The last section covers this.
Before you start: pick a path and find your vendor's ingestion host
Pick a neutral path
Avoid /analytics, /track, /posthog, and any other name that describes what the path does. The examples use /k7x. Replace it with your own short, unique segment in every config.
Collect your vendor's values
Ingestion hostnames, asset paths and required headers differ by vendor and by region, so no single config works everywhere. Here are the values the examples use:
Vendor | Value | Used for |
|---|---|---|
PostHog (US) | us.i.posthog.com | API requests, including event capture and /flags |
PostHog (US) | us-assets.i.posthog.com | Requests under /static/ and /array/ |
PostHog (EU) | eu.i.posthog.com | API requests for EU projects |
Plausible | https://plausible.io/js/pa-XXXXX.js | Your site's script. The pa-XXXXX part differs per site. |
Plausible | https://plausible.io/api/event | Event submission |
PostHog uses separate domains for API requests and static assets, so its proxies route two hosts. The examples use PostHog US. EU projects use eu.i.posthog.com.
When values change, treat each vendor's official guide as the source of truth:
- PostHog: Deploy a reverse proxy, plus the Caddy and nginx guides
- Plausible: Bypass adblockers with a proxy, plus the Caddy and nginx guides
PostHog notes that it can't help troubleshoot a self-hosted proxy.
Pattern 1: Rewrite rule on a Render static site
This pattern fits a Render static site with no server code.
You add redirect and rewrite rules to static sites in the Render Dashboard. Each rule has three parts:
- Source: a path, not a full URL
- Destination: a path or a full, publicly accessible URL
- Action: Rewrite or Redirect
In Source, * matches any string from that position onward. In Destination, * inserts the string that Source captured. Choose Rewrite: a redirect sends the browser to the destination with a 301 response, which exposes the vendor host again.
For PostHog US, order the asset rules above the catch-all rule:
Source | Destination | Action |
|---|---|---|
/k7x/static/* | https://us-assets.i.posthog.com/static/* | Rewrite |
/k7x/array/* | https://us-assets.i.posthog.com/array/* | Rewrite |
/k7x/* | https://us.i.posthog.com/* | Rewrite |
Then point your SDK at https://www.example.com/k7x, as shown in Pattern 2.
For Plausible, add these rules, ordered above any catch-all rule. Replace pa-XXXXX with your script ID:
Source | Destination | Action |
|---|---|---|
/k7x/js/script.js | https://plausible.io/js/pa-XXXXX.js | Rewrite |
/k7x/api/event | https://plausible.io/api/event | Rewrite |
Then change your Plausible script tag's src to /k7x/js/script.js and point the snippet's init call at the proxied event path with plausible.init({ endpoint: '/k7x/api/event' }), as in Pattern 2.
A test on a Render static site with an onrender.com subdomain, against httpbin, Plausible and PostHog, showed that the rewrite forwards the method, body, path and query unchanged, with no redirect on trailing-slash paths such as /k7x/e/. Render set Host to the destination host. Render appended the visitor IP to X-Forwarded-For and also sent it in True-Client-Ip and CF-Connecting-Ip. Plausible's debug response (X-Debug-Request) reported the real visitor IP even when the request carried a fake X-Forwarded-For.
Static rewrites forward Cookie and Authorization unchanged and can't remove them. If other apps on the same domain set cookies, use Pattern 2 or 3.
Run the live test
Run this test on a staging copy of your site:
- Deploy the rules and the SDK change, then open the site with an ad blocker enabled.
- Trigger a few events. In the network tab, confirm that requests go to
/k7xand succeed. - Confirm the events appear in your vendor's live events view, with locations that match yours rather than a data center.
- For Plausible, if the event response includes
x-plausible-dropped: 1, Plausible didn't record the event.
If any step fails, move to Pattern 3.
Pattern 2: Framework rewrites inside an existing web service
This pattern fits when you already run a web service on Render, such as a Next.js app, and want the proxy inside it with no new service.
This example uses Next.js rewrites to map the neutral path to PostHog's US hosts, sending /static/ and /array/ to the asset host.
Next, point the SDK at the new path. PostHog's SDK takes your proxy address in api_host, and the PostHog app address for your region in ui_host.
For Plausible, the official proxy guides map a script path and an event path under one subdirectory: /your-subdirectory/js/script.js to your site's script, and /your-subdirectory/api/event to Plausible's event endpoint. Under /k7x, the script rule looks like this:
Then change your Plausible script tag's src to /k7x/js/script.js. The snippet's init call must also point at the proxied event path: plausible.init({ endpoint: '/k7x/api/event' }). Step 3 of Plausible's Caddy guide shows the script src change together with the endpoint option in plausible.init.
Rewrites forward request headers, including cookies that belong to your application. Strip Cookie before requests leave for either analytics vendor. Handle Authorization differently: PostHog's proxy reference requires forwarding it when its value starts with Bearer phc_, Bearer phs_ or Bearer phx_, because capture v1 SDKs send the project token there, and stripping any other value. If your proxy drops the token, PostHog rejects the request with a 401. In Next.js 16, a small Proxy function can filter the headers before the rewrites run:
If you already have a Proxy or middleware function, merge this branch into it and include /k7x/:path* in its matcher. Let analytics requests pass through the header filter without login or locale redirects. The Plausible event handler below also uses an explicit list of outgoing headers.
Forward the client IP explicitly for Plausible
Plausible needs the visitor IP in X-Forwarded-For and the original User-Agent for unique visitor counting. The handler below forwards only the required headers, leaving application cookies and authorization behind. It assumes your trusted ingress has already sanitized X-Forwarded-For. Confirm that behavior for your deployment; copying an incoming header does not validate it. If the ingress appends to a caller-supplied chain, resolve the visitor IP using the known trusted proxies before forwarding it. For the App Router:
After you deploy, Plausible's guides expect the event request at the subdirectory's /api/event path to return 202. If either vendor sees your server's IP, inspect the ingress headers and proxy trust configuration first. A route handler can forward a validated visitor IP explicitly, but copying the same incorrect header into another handler will not fix it.
PostHog also publishes proxy guides for other frameworks, such as SvelteKit and Nuxt.
Pattern 3: A dedicated reverse proxy web service
This pattern fits when several apps should share one proxy, or when your framework has no rewrite support. You run Caddy as its own Render web service on a subdomain.
A proxy subdomain can share a site with apps under the same registrable domain: https://e.example.com is same-site with https://www.example.com and https://app.example.com, but each is a different browser origin. Requests to the proxy still need valid CORS responses. For an app on another-site.com, attach e.another-site.com to the same service.
Configure Caddy
Render routes all public internet traffic for a web service to a single port, which defaults to 10000. Render also provides automatic TLS for custom domains, so Caddy can serve plain HTTP.
This Caddyfile sets the upstream Host, strips application cookies, strips any Authorization value that isn't a PostHog token, and preserves the vendor's CORS response headers. Caddy forwards the browser's Origin and any OPTIONS preflight to the vendor. Do not remove Access-Control-Allow-Origin unless you supply a complete replacement CORS policy for the app origins, methods and request headers you support.
Caddy sets X-Forwarded-For by default. Here, trusted_proxies_strict resolves the client address from right to left through the configured trusted hops, and header_up X-Forwarded-For {client_ip} sends that resolved address to the vendor instead of the raw incoming chain. private_ranges is illustrative, not a verified list of Render ingress ranges: confirm which proxies connect to your service and how they handle caller-supplied headers. A correct-looking location alone does not establish that an IP cannot be spoofed. See Caddy's proxy trust options.
For Plausible, use a site block like this, and keep the same global options block from above. The User-Agent header is one of two key headers Plausible uses for unique visitor counting.
Then change your Plausible script tag's src to https://e.example.com/k7x/js/script.js. The snippet's init call must also point at the proxied event path: plausible.init({ endpoint: 'https://e.example.com/k7x/api/event' }), as in Pattern 2.
Add a Dockerfile
Deploy with a Blueprint
This minimal Blueprint deploys the proxy as a Docker web service and attaches a subdomain. The plan field takes a compute plan ID, such as 0.5c-512mb for 0.5 CPU and 512 MB RAM.
After the first deploy, point the subdomain's DNS at the service as described in Render's custom domain docs. Then set your SDK's api_host to https://e.example.com/k7x.
Understand the cost
This service adds compute and bandwidth to your own Render bill, because Render charges for compute and for metered features like bandwidth.
- Compute: The
0.5c-512mbplan costs $7/month. The Free plan is a poor fit: a Free web service spins down after 15 minutes without inbound traffic and takes about one minute to spin back up. - Bandwidth: Inbound traffic is free. Requests your service sends over the public internet count as outbound bandwidth, and so do HTTP responses to browsers. Hobby includes 5 GB per month, Pro 25 GB and Scale 1 TB. After that, outbound bandwidth costs $0.15 per GB.
- Custom domains: Hobby includes 2 custom domains, Pro 15 and Scale 25. Each additional domain costs $0.25/month.
Per PostHog's documentation, proxied traffic includes events, session recordings, feature flags and SDK assets. PostHog also offers a managed reverse proxy that's free for PostHog Cloud users.
Forwarding the headers your vendor needs
Forward the vendor's routing and visitor information, while keeping application credentials out of upstream requests:
- Host: The upstream request must carry the vendor's hostname. PostHog uses
Hostto route your request and returns 401 errors without it. - X-Forwarded-For: This header carries the client IP. Without it, the vendor sees your proxy's IP. PostHog relies on
X-Forwarded-Forfor accurate geolocation. If this header is missing or holds your server's IP, Plausible's bot filter drops the event, and the API still returns HTTP 202.
Plausible also lists User-Agent as a key header for unique visitor counting. PostHog's guides tell you to use the ingestion domain that matches your project's region. Check each config against the vendor guides linked above.
Header | Why it matters | Pattern 1 (static rewrite) | Pattern 2 (framework rewrite) | Pattern 3 (Caddy) |
|---|---|---|---|---|
Host | PostHog returns 401 errors without it | Set to the destination host by Render | Check for 401 responses on /k7x requests (see Verify the proxy works). | header_up Host |
X-Forwarded-For | Geolocation in PostHog. Plausible drops events silently when it's wrong. | Render appends the visitor IP and sends True-Client-Ip and CF-Connecting-Ip | Forward a visitor IP established by trusted ingress; copying an unverified header is insufficient. | Resolve with verified trusted proxy ranges and strict parsing; forward {client_ip}. |
Cookie | Not needed by either vendor. | Forwarded unchanged | The Proxy function strips it before rewrites; the Plausible handler forwards only its listed headers. | Both vendor variants remove it with header_up -Cookie. |
Authorization | Forward only PostHog token values ( Bearer phc_, phs_, phx_), strip the rest. Plausible doesn't use it. | Forwarded unchanged | The Proxy function keeps PostHog token values and strips the rest; the Plausible handler doesn't forward it. | The PostHog blocks strip non-PostHog values with request_header @foreign_auth -Authorization; the Plausible variant removes it with header_up -Authorization. |
Origin and CORS response headers | A separate proxy subdomain is cross-origin, even when it is same-site. | Not needed, same origin | No CORS exchange is needed for a path on the page's own origin. | Forward Origin and preflight requests; preserve the vendor's CORS response headers. |
Verify the proxy works
Work through this checklist after each deploy:
- Check the network tab. With developer tools open, trigger an event. Analytics requests should go to your domain on
/k7xand succeed, with none from the browser to the vendor host.
- PostHog: look for requests to your proxy path with a
200 OKresponse. PostHog's Node guide also tests the proxy withcurl -Iagainst the proxy path's/flags?v=2endpoint, expecting200 OK. That confirms the proxy reaches PostHog, not that PostHog records your events. A 401 on/k7xrequests means the upstreamHostis wrong or theAuthorizationtoken was stripped. - Plausible: expect the script request to return 200 and the event request 202. A 202 can still hide a dropped event: if the response includes
x-plausible-dropped: 1, Plausible didn't record it.
- Check the vendor's live events view. Confirm events appear as you click around. PostHog's guide ends its checks by confirming events appear in the PostHog app.
- Test with an ad blocker enabled. Repeat steps 1 and 2. Events should still arrive.
- Check the visitor IP. Geolocation is a smoke test, not proof that forwarding is trustworthy. On staging, Plausible's
X-Debug-Request: trueheader returns the IP it would use. Confirm the expected visitor IP and check that a caller-suppliedX-Forwarded-Forcannot override it. - Check headers and CORS. Use a dummy cookie and a dummy non-PostHog
Authorizationvalue with a staging echo upstream to confirm they are removed before forwarding. For PostHog, also confirm that anAuthorizationvalue starting withBearer phc_,Bearer phs_orBearer phx_passes through unchanged. For a proxy subdomain, check that browser requests and anyOPTIONSpreflights succeed without CORS errors, and that the app can read feature-flag responses. A successful request from a command-line client does not test browser CORS.
Which pattern should you use?
Start from your service type.
Your setup | Recommended pattern | Where the proxy runs | Extra cost | Notes |
|---|---|---|---|---|
Static site only | Pattern 1 | On the static site itself, through rewrite rules | None for the static site itself, since static sites are free. Proxied responses count toward your workspace's outbound bandwidth. | Static rewrites forward Cookie and Authorization unchanged. If you also need cookie stripping, use Pattern 3. |
Single framework app | Pattern 2 | Inside your existing web service | No new service. Proxied traffic counts toward outbound bandwidth. | Confirm the visitor IP as in Verify the proxy works, step 4. |
Multiple apps, or no framework rewrite support | Pattern 3 | Dedicated web service on a subdomain | Compute from $7/month, plus outbound bandwidth beyond your plan's allowance | One proxy serves every app under the same registrable domain. Add a subdomain per extra domain, at $0.25/month beyond your plan's included domains. |
Proxying doesn't change your consent obligations
A proxy changes how events reach your vendor, not whether you're allowed to collect them. Cookie banners, GDPR, and similar requirements apply the same way whether events go straight to the vendor or through /k7x on your domain. If you use a proxy to get around a visitor's refusal of consent, you're still collecting data without consent.
This guide doesn't give legal advice. Before you deploy a proxy, run the change through your own compliance process, and keep your consent logic in front of the SDK so it controls whether events fire at all. PostHog documents privacy controls and compliance guidance for frameworks including GDPR.