How to do on-fly defragmentation on nginx?

I store encrypted (AES 256) files on nginx. I open them on a GET request and use the key as a request parameter. For reference http://www.my_secure_nginx.com/files/secret_audio.mp3?key=mysecretkey
Can you suggest a solution how to do this for the nginx fileserver (possibly existing filters) to support responsive responses. In other words, I need to make decryption files "on the fly" in nginx.

+3


source to share


1 answer


The easiest way is to write your own nginx module in Lua . The Lua-resty-string module already supports AES . Add the file handling code reader code and you're done. Lua modules are very fast as they work with non-blocking I / O.

The important part to keep in mind is the indentation handling - the original file size has to be stored somewhere (DB, xattr, etc.) and passed or read by nginx.



Another non-trivial question is the possible support for random access. For this, the data must be AES encrypted in CTR mode . XTS, CBC, CFB are also great, but require a little extra development work.

0


source







All Articles