M
M
mint_candy2019-05-24 21:52:14
Node.js
mint_candy, 2019-05-24 21:52:14

How to set X-Forwarded-For header in request?

Hello. There is a proxy server written using the express-http-proxy library on node.js. I need the client's IP address to be stored in the request. In nginx, you can set the header proxy_set_header X-Real-IP $remote_addr; or proxy_set_header X-Forwarded-For $remote_addr;

How to do this in Node.js???

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Chernyshev, 2019-05-28
@IvanBlacky

req.headers['someHeader'] = 'someValue'
This kind of code can be added to the middleware, which will be processed for each proxied request.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question