Note: 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.
Note: If you are using the EU cloud then use
euinstead ofusin all domains (e.g.us.i.posthog.com->eu.i.posthog.com)
Netlify supports redirects and rewrites which we can use as a reverse proxy from an /ingest route. In your netlify.toml file, add a redirect like this:
Note: If deploying SvelteKit on Netlify use
_redirectsfile and place it instaticfolder, as redirects innetlify.tomlconfiguration are not supported.
Note: This proxy configuration works with custom domains but may not work correctly with the default
.netlify.appdomain. If you're experiencing issues with PostHog requests being blocked, ensure you're using a custom domain rather than the default Netlify domain.
Once done, set the /ingest route of your domain as the API host in your PostHog initialization like this:
Once updated, deploy your changes on Netlify and check that PostHog requests are going to https://www.your-domain.com/ingest by checking the network tab on your domain.