0

I have server Front server:Apple and Back End server Orange

Just to be clear in first line I don't want to pass through user ip address through Apple to Orange as I already implemented that by using

proxy_set_header X-Real-IP $remote_addr;

My question is I want to pass through Front end server ip address to backend server because we have too many front end servers, so I will know which front end server send from. any ideas or example ? I can't use REMOTE_ADDR since it's passing through user ip address.

thanks.

danone
  • 166
  • 1
  • 10
  • 1
    Inspect all your headers, because you *should* find it at `REMOTE_ADDR`; what you're doing above is to set a header called `X_REAL_IP` with the value of the client IP. The front-end's IP will be in `REMOTE_ADDR` – jaygooby Sep 04 '20 at 10:56
  • The back end server will already know what address connected to it! – Michael Hampton Sep 04 '20 at 16:47

2 Answers2

0

I don't know any automatic way to do that. You can use proxy_set_header frontend_ip <ipaddress>.

The <ipaddress> is either added manually to the configuration or it is added by configuration management system when it generates configuration.

Then you can do anything with the header value in backend.


Old answer before question clarification

Your backend web servers are likely configured to replace connecting host IP address with address in X-Real-IP header.

You need to modify your backend server configuration so that they do not use X-Real-IP.

For example, in nginx, remove real_ip_header and set_real_ip_from lines from configuration.

Also make sure that your backend applications are not using REMOTE_ADDR but the actual header instead.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63
  • changing backend application from REMOTE_ADDR to X-Real-IP is not an option because of nature of application we can't change those settings do you have any idea other than REMOTE_ADDR I can pass a variable which I can define on front end server ? – danone Sep 05 '20 at 04:01
0

I found solution you just need to use HTTP_X_FORWARDED_FROM at backend server and you can see frontend ip address by using this. works perfectly.

danone
  • 166
  • 1
  • 10