From 7fe59249d4fa722647b056d113dad0091f8a62ac Mon Sep 17 00:00:00 2001 From: "posthog[bot]" <206114724+posthog[bot]@users.noreply.github.com> Date: Mon, 10 Aug 2026 16:25:07 +0000 Subject: [PATCH] Disable IP spoofing check in production The app runs behind Cloudflare and an internal Docker proxy. Rails' ActionDispatch::RemoteIp raises IpSpoofAttackError when a request sends a Client-IP header that disagrees with X-Forwarded-For, which returns a 500 before the request reaches a controller. Because Client-IP is client-supplied, any client can trigger the error at will. Set config.action_dispatch.ip_spoofing_check = false, the standard setting for an app behind Cloudflare, where the trusted client IP comes from the proxy and never from a client-supplied header. Generated-By: PostHog Code Task-Id: f28b7132-79cc-4246-957b-9a634dfb338f --- config/environments/production.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/config/environments/production.rb b/config/environments/production.rb index a9498d0..b4a6ca9 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -28,6 +28,13 @@ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. config.force_ssl = true + # Turn off the IP spoofing check. The app runs behind Cloudflare and an internal + # Docker proxy, so the trusted client IP comes from the proxy, not from a + # client-supplied header. With the check on, any request that sends a Client-IP + # header that disagrees with X-Forwarded-For makes ActionDispatch::RemoteIp raise + # IpSpoofAttackError and return a 500 before the request reaches a controller. + config.action_dispatch.ip_spoofing_check = false + # Skip http-to-https redirect for the default health check endpoint. # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }