Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seed Lua's number generator on nginx worker init #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

quinox
Copy link

@quinox quinox commented Aug 15, 2017

During testing I discovered Lua doesn't seed itself, resulting in the same request IDs showing in my logs. I've implemented seeding for Unix-like systems using /dev/urandom; Lots of pages on the internet suggest os.time() but this seems like it would make different nginx workers seed with the same number which is undesirable (but I'm no expert, so I could be wrong).

--restarted nginx (no seed)
::1 - - [15/Aug/2017:15:05:26 +0200] "GET / HTTP/1.1" request_id=KSG6-N7L5TK0U-1TMT69XB
::1 - - [15/Aug/2017:15:05:26 +0200] "GET / HTTP/1.1" request_id=U01R-EYZDA9VY-LR2DNYQ3
::1 - - [15/Aug/2017:15:05:26 +0200] "GET / HTTP/1.1" request_id=2OJS-2IPJ3N27-TOZOTZDD
--restarted nginx (no seed)
::1 - - [15/Aug/2017:15:05:33 +0200] "GET / HTTP/1.1" request_id=KSG6-N7L5TK0U-1TMT69XB
::1 - - [15/Aug/2017:15:05:33 +0200] "GET / HTTP/1.1" request_id=U01R-EYZDA9VY-LR2DNYQ3
::1 - - [15/Aug/2017:15:05:33 +0200] "GET / HTTP/1.1" request_id=2OJS-2IPJ3N27-TOZOTZDD
--restarted nginx (seeded)
::1 - - [15/Aug/2017:15:05:45 +0200] "GET / HTTP/1.1" request_id=EQKT-I0AA72YT-S5A9GSN9
::1 - - [15/Aug/2017:15:05:45 +0200] "GET / HTTP/1.1" request_id=EIXC-X5J1ANTW-KJXZS8BE
::1 - - [15/Aug/2017:15:05:45 +0200] "GET / HTTP/1.1" request_id=TWNB-360U791Q-DNNEOK1O
--restarted nginx (seeded)
::1 - - [15/Aug/2017:15:05:55 +0200] "GET / HTTP/1.1" request_id=SF8O-V264GYXS-24408CF5
::1 - - [15/Aug/2017:15:05:55 +0200] "GET / HTTP/1.1" request_id=DRUE-C66R00Q3-7XSW5YZP
::1 - - [15/Aug/2017:15:05:55 +0200] "GET / HTTP/1.1" request_id=89KS-FZR9M8RB-5R0I1S3A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant