Welcome! Log In Create A New Profile

Advanced

Doing a hash of IP - specifically $proxy_protocol_addr

Posted by opardalis 
Doing a hash of IP - specifically $proxy_protocol_addr
December 15, 2020 09:46AM
This may sound like a silly request, but I'm trying to determine if there is a native way within nginx to get a hash (ideally sha1 or sha256) of the $proxy_protocol_addr into another var.

I need the hash to be in var that I can pass to the fastcgi_cache_key, I dont want to use the real IP as the key because for privacy reasons I cant store the real clear text IP.

The question is mainly about doing this natively. I can do it using an external lua or perl module, but it would great if it was built-in. I looked at the code and some hashing does occur, for example for upstream load balancing a hash of IP is done, and in the ssl module the ssl cert is hashed and stored in the var $ssl_client_cert.

My gut tells me I cant do what I want natively, unless I patch the original src code and create a new var like $proxy_protocol_hash - unfortunately my C is really rusty and that endeavor is probably out of my reach. If someone is interested in doing it though, ping me.

The compelling reason to do this native in C/recompiled src vs a lua or perl mod is performance, my use case if very high scaling
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 75
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready