Currently in our setup, we are using the X-Real-IP header setting in
nginx,
to tell in our backend apache logs the IP address of the client.
Is it possible to set up nginx to insert an arbitrary HTTP header with
text
of my choosing, or with it’s own IP address?
I’d like to set this up for the purposes of doing some easier log
analysis.
Thanks!
Posted at Nginx Forum:
Currently in our setup, we are using the X-Real-IP header setting in nginx, to tell in our backend apache logs the IP address of the client. Is it possible to set up nginx to insert an arbitrary HTTP header with text of my choosing, or with it's own...
On Fri, Feb 01, 2013 at 02:21:05PM -0500, zacharyalexstern wrote:
Hi there,
Currently in our setup, we are using the X-Real-IP header setting in nginx,
to tell in our backend apache logs the IP address of the client.
Which line in your nginx configuration is doing that?
Is it possible to set up nginx to insert an arbitrary HTTP header with text
of my choosing, or with it’s own IP address?
Yes.
What happens if you copy the current line, and change some parts of it?
It should be straightforward enough to test.
f
Francis D. [email protected]
Ah, so, we have this line:
proxy_set_header X-Real-IP $remote_addr;
Is there a list of the variables similar to $remote_addr somewhere?
Is $proxy_host possibly what we need?
Posted at Nginx Forum:
Currently in our setup, we are using the X-Real-IP header setting in nginx, to tell in our backend apache logs the IP address of the client. Is it possible to set up nginx to insert an arbitrary HTTP header with text of my choosing, or with it's own...
I’d like nginx to set a header that contains the IP address of the
server
nginx is running on.
So something like:
proxy_set_header X-Nginx-IP $proxy_host;
Assuming $proxy_host evaluates to the IP of the server nginx is running
on.
Posted at Nginx Forum:
Currently in our setup, we are using the X-Real-IP header setting in nginx, to tell in our backend apache logs the IP address of the client. Is it possible to set up nginx to insert an arbitrary HTTP header with text of my choosing, or with it's own...
On Fri, Feb 01, 2013 at 02:57:00PM -0500, zacharyalexstern wrote:
I’d like nginx to set a header that contains the IP address of the server
nginx is running on.
There is (almost certainly) not exactly one IP address that fits that
description.
Maybe $server_addr is adequate?
Easiest is probably “proxy_set_header X-Nginx-IP 10.11.12.13;” on the
server that you want to identify as 10.11.12.13.
But if you wind back to why you want that – apache already knows what
ip address the connection to it came from (which should be an address of
the server that nginx is running on).
It would have logged it, except that you configured apache to discard
that address and instead use the content of the X-Real-IP header.
Possibly changing the apache configuration to log the content of the
X-Real-IP header as well as its client ip address is easiest of all.
Whether that is appropriate in your environment depends on what else
your apache does with the information.
f
Francis D. [email protected]
On Fri, Feb 01, 2013 at 02:44:17PM -0500, zacharyalexstern wrote:
Ah, so, we have this line:
proxy_set_header X-Real-IP $remote_addr;
Module ngx_http_proxy_module for details.
Is there a list of the variables similar to $remote_addr somewhere?
http://nginx.org/en/docs/http/ngx_http_core_module.html#variables
Other modules may provide other variables.
Is $proxy_host possibly what we need?
Possibly.
It really depends on what you wish to achieve, which I don’t think is
clear yet from this thread.
f
Francis D. [email protected]
There are several nodes in between nginx and apache. It’s not internet
→
nginx → apache.
It’s internet → nginx → varnish → haproxy - > apache1
- >
apache2
- >
apacheN
So far, everything is in the apache access logs except the IP of the
nginx
server connecting.
But you’re right, I could just set it manually, for each nginx server. I
might just do that.
And you’re also again right that our servers have multiple IPs.
Posted at Nginx Forum:
Currently in our setup, we are using the X-Real-IP header setting in nginx, to tell in our backend apache logs the IP address of the client. Is it possible to set up nginx to insert an arbitrary HTTP header with text of my choosing, or with it's own...