Accessing an environment variable across nginx w/ Lua and Rails
Better to put it only in the two places it's actually needed, in the two respective configuration files, than in the global environment where every process has access to it, as you have it now.
I would use init_by_lua
directive in your vhost config.
init_by_lua 'HMAC_SECRET = "SECRET-STRING"';server { # and so on}
So you'll have you secret in two places, but both in your project (if I understand correctly and vhost config is in your project).
You can even use init_by_lua_file
and make some efforts to read and parse that file in your unicorn init.