diff --git a/ip/index.ts b/ip/index.ts index 2e58c056a..22ef3fca7 100644 --- a/ip/index.ts +++ b/ip/index.ts @@ -637,6 +637,13 @@ function findIP(request: RequestLike, headers: Headers): string { return trueClientIP; } + // Fly.io + // Fly-Client-IP: https://fly.io/docs/networking/request-headers/#fly-client-ip + const flyClientIP = headers.get("fly-client-ip"); + if (isGlobalIP(flyClientIP)) { + return flyClientIP; + } + // Default nginx proxy/fcgi; alternative to x-forwarded-for, used by some proxies // X-Real-IP const xRealIP = headers.get("x-real-ip"); diff --git a/ip/test/ipv4.test.ts b/ip/test/ipv4.test.ts index b3f39d49e..e97a69a90 100644 --- a/ip/test/ipv4.test.ts +++ b/ip/test/ipv4.test.ts @@ -206,6 +206,7 @@ describe("find public IPv4", () => { headerSuite("CF-Connecting-IP"); headerSuite("DO-Connecting-IP"); headerSuite("Fastly-Client-IP"); + headerSuite("Fly-Client-IP"); headerSuite("True-Client-IP"); headerSuite("X-Real-IP"); headerSuite("X-Cluster-Client-IP"); diff --git a/ip/test/ipv6.test.ts b/ip/test/ipv6.test.ts index 6707c8fb3..1f61a8eb0 100644 --- a/ip/test/ipv6.test.ts +++ b/ip/test/ipv6.test.ts @@ -169,6 +169,7 @@ describe("find public IPv4", () => { headerSuite("CF-Connecting-IP"); headerSuite("DO-Connecting-IP"); headerSuite("Fastly-Client-IP"); + headerSuite("Fly-Client-IP"); headerSuite("True-Client-IP"); headerSuite("X-Real-IP"); headerSuite("X-Cluster-Client-IP");