node-proxy-middleware
node-proxy-middleware copied to clipboard
via header received-by: os.hostname() vs incoming request host
I've noticed that os.hostname() is used to populate the via header's "received-by" section rather than the incoming request url host domain, port. I might be misinterpreting the spec here but I thought the intent of via was to specify the host dns name used to reach the proxy server rather than proxy host machine name.
Consider the following scenario:
I have two dns names pointing to my node webserver which uses node-proxy-middleware
- customer1.webserver.com -> my-webserver-ip
- customer2.webserver.com -> my-webserver-ip
if my-webserver-ip uses proxy-middleware to proxy "/api" to "http://my-appserver/api", then my-appserver should be able to use the via header to figure out if the request came via customer1.webserver.com or customer2.webserver.com.
I understand that the preserveHost flag can be used but becoming blind to the proxy shouldn't be necessary.
I can create a PR for this if desired.
From spec:
The received-by field is normally the host and optional port number of a recipient server or client that subsequently forwarded the message.
This means received-by
is the machine, that does forwarding/redirect, which is a proxy's machine,
os.hostname()
is correct here.
To see the originating request chain (the case you've described with customer1.webserver.com
) X-Forwarded-For
is used.