M
M
Monkz2020-05-11 13:00:12
Nginx
Monkz, 2020-05-11 13:00:12

How to configure nginx proxy_pass to spoof IP when proxying?

Good afternoon!
Slightly non-standard scheme
Clients connect to nginx www.sample.com:4545 (sample.com ip = 2.2.2.2)
Nginx proxies them

location / {
proxy_pass http://10.3.3.3:5555;
}


How to make sure that 10.3.3.3 always receives a request from 3.3.3.3, and not from 2.2.2.2 or client ip ???

I tried with set_real_ip_from 3.3.3.3;but somehow unsuccessfully :(

Help, please.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Shatokhin, 2020-05-11
@Sovigod

On 2.2.2.2 you need to add "X-Forwarded-For” header generation link
And on 10.3.3.3 use it instead of remote_addr. If nginx is there, then set_real_ip_from can be used.

M
Monkz, 2020-05-11
@Monkz

Unfortunately, I can influence 10.3.3.3 - there is a firewall that only allows incoming from 3.3.3.3

K
ky0, 2020-05-11
@ky0

How to make sure that 10.3.3.3 always receives a request from 3.3.3.3, and not from 2.2.2.2 or the client's ip?

Are you talking about the packet at the network layer or the HTTP header? In the first case - to change at the OS level, in the second - to change the corresponding header with nginx.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question