set-misc-nginx-module icon indicating copy to clipboard operation
set-misc-nginx-module copied to clipboard

Add set_secure_random_hex

Open ckiickA opened this issue 10 years ago • 4 comments

Create a random hexadecimal string. Very useful for making trace-ids in X-B3-* headers for zipkin.

ckiickA avatar Nov 19 '15 20:11 ckiickA

@ckiickA Have you looked at the existing set_secure_random_* directives?

See https://github.com/openresty/set-misc-nginx-module#set_secure_random_alphanum for example.

agentzh avatar Nov 23 '15 03:11 agentzh

I have. However, there's no way to restrict the string generated to just hex digits. The Zipkin spec says traceid's are random hexadecimal 64 bit numbers. I attempted to use get_random and hex_encode, but hex_encode just gives the ascii codes of the digits.

ckiickA avatar Nov 23 '15 15:11 ckiickA

@ckiickA Hmm, maybe you should use the ngx_lua module for such special requirements instead. Otherwise this simple ngx_set_misc module would keep growing forever, which is a bad thing IMHO :)

agentzh avatar Nov 23 '15 15:11 agentzh

Not an option for our environment. I can use a custom patch for now. Just thought you might find it useful. Producing a random hex string doesn't seem that much of a special requirement to me. I was surprised that none of the existing modules could do it. Anyway, do what you want with the PR. Just trying to give back.

On Mon, Nov 23, 2015 at 9:29 AM, Yichun Zhang [email protected] wrote:

@ckiickA https://github.com/ckiickA Hmm, maybe you should use the ngx_lua module for such special requirements instead. Otherwise this simple ngx_set_misc module would keep growing forever, which is a bad thing IMHO :)

— Reply to this email directly or view it on GitHub https://github.com/openresty/set-misc-nginx-module/pull/28#issuecomment-158969256 .

Chris J. Kiick Senior Performance Engineer, Atlassian [email protected]

ckiickA avatar Nov 23 '15 15:11 ckiickA