http-encrypted-session #
Encrypts and decrypts nginx variable values with AES-256 and an expiry time. Use it to store session data in a cookie that clients cannot read or change, often together with set_misc.
Source: upstream source
Directives
encrypted_session_expires #
syntax: encrypted_session_expires 1 arg; · context: http, server, location, server-if, location-if
For example, Back to TOC encrypted_session_expires ------------------------- syntax: encrypted_session_expires <time> default: encrypted_session_expires 1d; context: http, server, server if, location, location if Sets expiration time difference (in seconds by default).
encrypted_session_iv #
syntax: encrypted_session_iv 1 arg; · context: http, server, location, server-if, location-if
For example, Back to TOC encrypted_session_iv -------------------- syntax: encrypted_session_iv <iv> default: encrypted_session_iv "deadbeefdeadbeef"; context: http, server, server if, location, location if Accepted for configuration compatibility (must be no longer than 16 bytes).
encrypted_session_key #
syntax: encrypted_session_key 1 arg; · context: http, server, location, server-if, location-if
Sets the 32-byte cipher key used to encrypt and decrypt session data.
set_decrypt_session #
syntax: set_decrypt_session 1 arg; · context: http, server, location, server-if, location-if
Decrypts an encrypted string and stores the result in the specified variable.
set_encrypt_session #
syntax: set_encrypt_session 1 arg; · context: http, server, location, server-if, location-if
Encrypts a given string value and stores the result in the specified variable.
Example
encrypted_session_key "abcdefghijklmnopqrstuvwxyz123456";
encrypted_session_iv "12345678";
encrypted_session_expires 1d;
location /foo {
set $uid 1315;
set_encrypt_session $session $uid;
set_encode_base32 $session;
#echo $session;
echo_exec /bar _s=$session;
}
location /bar {
encrypted_session_expires 30d;
set_unescape_uri $session $arg__s;
set_decode_base32 $session;
set_decrypt_session $uid $session;
echo $uid;
}