diff --git a/src/utils/Fetcher.test.ts b/src/utils/Fetcher.test.ts index 8bcf0a7..49a15cb 100644 --- a/src/utils/Fetcher.test.ts +++ b/src/utils/Fetcher.test.ts @@ -31,10 +31,11 @@ describe('fetch', () => { 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'en', 'Authorization': 'Basic dXNlcjpwYXNz', - 'Forwarded': 'for=0.0.0.0', + 'Forwarded': 'by=unknown;for=0.0.0.0;host=some-url.test;proto=https', 'Priority': 'u=0', 'User-Agent': 'node', 'X-Forwarded-For': '0.0.0.0', + 'X-Forwarded-Host': 'some-url.test', 'X-Forwarded-Proto': 'https', 'X-Real-IP': '0.0.0.0', }); diff --git a/src/utils/Fetcher.ts b/src/utils/Fetcher.ts index 5ea734e..cc29033 100644 --- a/src/utils/Fetcher.ts +++ b/src/utils/Fetcher.ts @@ -105,6 +105,8 @@ export class Fetcher { const cookieString = this.cookieJar.getCookieStringSync(url.href); const noProxyHeaders = init?.noProxyHeaders ?? false; + const forwardedProto = url.protocol.slice(0, -1); + return { ...init, headers: { @@ -115,9 +117,10 @@ export class Fetcher { 'User-Agent': this.hostUserAgentMap.get(url.host) ?? 'node', ...(cookieString && { Cookie: cookieString }), ...(ctx.ip && !noProxyHeaders && { - 'Forwarded': `for=${ctx.ip}`, + 'Forwarded': `by=unknown;for=${ctx.ip};host=${url.host};proto=${forwardedProto}`, 'X-Forwarded-For': ctx.ip, - 'X-Forwarded-Proto': url.protocol.slice(0, -1), + 'X-Forwarded-Host': url.host, + 'X-Forwarded-Proto': forwardedProto, 'X-Real-IP': ctx.ip, }), ...init?.headers,