File tree Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -267,11 +267,8 @@ function getRequestHeaders (req) {
267
267
headers [ HTTP2_HEADER_UPGRADE ] = 'websocket'
268
268
}
269
269
270
- const fwd = {
271
- by : req . headers [ HTTP2_HEADER_AUTHORITY ] || req . headers [ HTTP2_HEADER_HOST ] ,
272
- proto : req . socket . encrypted ? 'https' : 'http' ,
273
- for : `for=${ req . socket . remoteAddress } `
274
- }
270
+ headers [ HTTP2_HEADER_FORWARDED ] = `by=${ req . socket . localAddress } `
271
+ headers [ HTTP2_HEADER_FORWARDED ] += `; for=${ req . socket . remoteAddress } `
275
272
276
273
if ( req . headers [ HTTP2_HEADER_FORWARDED ] ) {
277
274
const expr = / f o r = \s * ( [ ^ \s ] + ) / ig
@@ -280,16 +277,16 @@ function getRequestHeaders (req) {
280
277
if ( ! m ) {
281
278
break
282
279
}
283
- fwd . for += `; ${ m [ 1 ] } `
280
+ headers [ HTTP2_HEADER_FORWARDED ] += `; ${ m [ 1 ] } `
284
281
}
285
282
}
286
283
287
- headers [ HTTP2_HEADER_FORWARDED ] = [
288
- `by= ${ fwd . by } ` ,
289
- fwd . for ,
290
- fwd . host && `host= ${ fwd . host } ` ,
291
- `proto= ${ fwd . proto } `
292
- ] . filter ( x => x ) . join ( '; ' )
284
+ const host = req . headers [ HTTP2_HEADER_AUTHORITY ] || req . headers [ HTTP2_HEADER_HOST ]
285
+ if ( host ) {
286
+ headers [ HTTP2_HEADER_FORWARDED ] += `; host= ${ host } `
287
+ }
288
+
289
+ headers [ HTTP2_HEADER_FORWARDED ] += `; proto= ${ req . socket . encrypted ? 'https' : 'http' } `
293
290
294
291
return headers
295
292
}
You can’t perform that action at this time.
0 commit comments