Hi everyone,
we’ve recently moved our self-hosted n8n instance to the subdomain n8n.example.com of our primary domain example.com. n8n also runs behind an azure app proxy for external access, although i don’t think this is relevant. Since we moved n8n to our primary domain, we’ve started running into an unexpected issue:
n8n sets a PostHog tracking cookie named ph_phc_4URIAm1uYfJO7j8kWSe0J8lc8IqnstRLS7Jx8NcakHo_posthog on the entire parent domain (.example.com) instead of just the n8n.example.com subdomain.
This becomes a problem because we also run other apps on sibling subdomains, which are protected by a strict WAF (Sophos/ModSecurity). That WAF inspects cookie contents and flags the PostHog cookie as a potential SQL injection vector, resulting in 403 Forbidden errors for completely unrelated services.
Here is a decoded sample of the cookie payload (without azure app proxy)
{
"distinct_id": "641161f96fa124764b202... ...24097a6027621fb1946b#ebf6b1b3-c829-4f2d-9f5d-129d850e47bf",
"$sesid": [1752572045554, "01980d6f-28c6-7551-ab8f-0039fd4929f3", 1752572045510],
"$epp": true,
"$initial_person_info": {
"r": "$direct",
"u": "https://n8n.example.com/signin?redirect=%252F"
}
}
And here is a sample of the cookie payload with azure app proxy in front
{
"distinct_id": "641161f96fa124764b202... ...24097a6027621fb1946b#ebf6b1b3-c829-4f2d-9f5d-129d850e47bf",
"$sesid": [1752572203367, "01980d5c-4c44-7c8a-8906-6f2b548f4e27", 1752570809409],
"$epp": true,
"$initial_person_info": {
"r": "https://login.microsoftonline.com/",
"u": "https://n8n.example.com/signout"
}
}
The Web Application Firewall for the unrelated services throws the follow error:
[Tue Jul 15 08:56:33.102299 2025] [security2:error] [pid 16260:tid 140291113596672] [client 123.123.123.123:57804] [client 123.123.123.123]
ModSecurity: Warning. Pattern match "[\\"'`][\\\\s\\\\d]*?[^\\\\w\\\\s]\\\\W*?\\\\d\\\\W*?.*?[\\"'`\\\\d]" at REQUEST_COOKIES:ph_phc_XXXXXXXXXXXX_posthog.
[file "/usr/apache/conf/waf/rules/REQUEST-942-APPLICATION-ATTACK-SQLI.conf"]
[line "1345"] [id "942490"] [msg "Detects classic SQL injection probings 3/3"]
[data "Matched Data: \\x22:\\x2264 found within REQUEST_COOKIES:ph_phc_XXXXXXXXXXXX_posthog:
{\\x22distinct_id\\x22:\\x22[HASHED_ID]#[UUID]\\x22,\\x22$sesid\\x22:[TIMESTAMP_A,\\x22[SESSION_UUID]\\x22,TIMESTAMP_B],\\x22$epp\\x22:true,\\x22$initial_person_info\\x22:{\\x22r\\x22:\\x22https://login.microsoftonline.com/\\x22,\\x22u\\x22:\\x22https://n8n.example.com/signout\\x22}}"]
[severity "CRITICAL"] [ver "OWASP_CRS/3.3.3"] [tag "application-multi"] [tag "language-multi"] [tag "platform-multi"] [tag "attack-sqli"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/66"] [tag "PCI/6.5.2"] [tag "p [hostname "pbx.example.com"] [uri "/favicon.ico"] [unique_id "REDACTED"], referer: https://pbx.example.com/
As a temporary workaround we desiabled telemetry by setting
N8N_DIAGNOSTICS_ENABLED=false
This stops the cookie from being set altogether – which resolves the issue – but I’d prefer to keep diagnostics enabled, and simply restrict the cookie scope to the subdomain (n8n.example.com) instead of the whole domain.
Is there a way to instruct n8n to set the PostHog cookie only for n8n.example.com and not for .example.com?
Thanks in advance for any help or clarification!
Best regards,
Christian