[dev] add support for real_ip_header to use any variable

Joaquin Cuenca Abela e98cuenc at gmail.com
Fri Jan 18 23:51:05 MSK 2008


I want to use the realip module, but I have the real IP at a different
header (X-User-IP) and I can't change it.
I thus added support to real_ip_header to use any variable, instead of
just the headers X-Real-IP and X-Forwarded-For, so now you can do:

real_ip_header $http_x_user_ip;

The patch keeps backwards compatibility, so you can still use
X-Real-IP and X-Forwarded-For, and it defaults to X-Real-IP.

While I was at it, I did a couple of mini optimizations in
ngx_http_variables. As I didn't benchmarked that change (or tested it
in detail), I'm putting it in a second patch (variable.patch).

It's my first look at nginx code, so I probably got something wrong,
but so far it seems to work here[TM]. I hope you will find it useful
enough to include it in nginx.


Joaquin Cuenca Abela
-------------- next part --------------
A non-text attachment was scrubbed...
Name: realip.patch
Type: application/octet-stream
Size: 4356 bytes
Desc: not available
URL: <http://nginx.org/pipermail/nginx/attachments/20080118/dfcc348f/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: variable.patch
Type: application/octet-stream
Size: 1761 bytes
Desc: not available
URL: <http://nginx.org/pipermail/nginx/attachments/20080118/dfcc348f/attachment-0001.obj>

More information about the nginx mailing list