Home > Back-end >  What is the purpose of "proxy_set_header REMOTE-HOST $remote_addr"?
What is the purpose of "proxy_set_header REMOTE-HOST $remote_addr"?

Time:05-05

I am learning to add a reverse proxy for WordPress, and in the process of referring to other people's configuration parameters, I found that someone used the following parameters in the configuration.

proxy_set_header REMOTE-HOST $remote_addr;

I tried to search the web to understand it, but I couldn't find any information about it. What exactly does it do, please?

CodePudding user response:

Its purpose: It tells the reverse proxy software (nginx) to add an HTTP header to each request it forwards from your audiences' browsers to your server. The header it adds looks something like this:

REMOTE-HOST: 198.51.100.121

This header announces to your server the IP address of your audience. Without it your WordPress web server logs would show all requests coming from the proxy server's address. Which is boring and useless.

But you're doing it strangely. You should be using the X-Forwarded-For header. The nginx directive for that is

        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

and in the HTTP request it looks something like this

X-Forwarded-For: 198.51.100.121

There's probably no harm in adding your REMOTE-HOST header, but the standard is X-Forwarded-For.

  • Related