You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similar to the [set_encode_base64](#set_encode_base64) directive, but uses URL safe base64 variant, '+' becomes '-', '/' becomes '_' and there is no padding with '=' characters.
Similar to the [set_encode_base64url](#set_encode_base64url) directive, but does exactly the the opposite operation, .i.e, decoding a base64url digest into its original form.
693
+
694
+
[Back to TOC](#table-of-contents)
695
+
630
696
set_encode_hex
631
697
--------------
632
698
**syntax:***set_encode_hex $dst <src>*
@@ -1010,6 +1076,23 @@ This directive was first introduced in the `v0.22rc7` release.
1010
1076
1011
1077
[Back to TOC](#table-of-contents)
1012
1078
1079
+
set_expired
1080
+
-----------
1081
+
**syntax:***set_expired $dst <timestamp>*
1082
+
1083
+
**default:***no*
1084
+
1085
+
**context:***location, location if*
1086
+
1087
+
**phase:***rewrite*
1088
+
1089
+
Sets `$dst` to either `1` or `0`, dependent on whether or not the
1090
+
timestamp as defined in `timestamp` (seconds since 1970-01-01 00:00:00) is or is not in the past.
1091
+
1092
+
Behind the scene, this directive utilizes the `ngx_time` API in the Nginx core, so usually no syscall is involved due to the time caching mechanism in the Nginx core.
Copy file name to clipboardExpand all lines: doc/HttpSetMiscModule.wiki
+71Lines changed: 71 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -84,6 +84,15 @@ This document describes ngx_set_misc [https://github.com/agentzh/set-misc-nginx-
84
84
# $b == 'abcde'
85
85
}
86
86
87
+
location /base64url {
88
+
set $a 'abcde';
89
+
set_encode_base64url $a;
90
+
set_decode_base64url $b $a;
91
+
92
+
# now $a == 'YWJjZGU' and
93
+
# $b == 'abcde'
94
+
}
95
+
87
96
location /hex {
88
97
set $a 'abcde';
89
98
set_encode_hex $a;
@@ -125,6 +134,24 @@ This document describes ngx_set_misc [https://github.com/agentzh/set-misc-nginx-
125
134
echo $signature;
126
135
}
127
136
137
+
# GET /secure?e=1394493753&s=HkADYytcoQQzqbjQX33k_ZBB_DQ
138
+
# returns 403 when signature on expire time is not correct OR
139
+
# when expire time is passed. See: HttpSecureLinkModule.
140
+
# This example has a valid signed expiry at 2030-01-01. Output:
141
+
# "OK"
142
+
location /secure {
143
+
set_hmac_sha1 $signature 'secret-key' $arg_e;
144
+
set_encode_base64url $signature;
145
+
if ($signature != $arg_s) {
146
+
return 403;
147
+
}
148
+
set_expired $expired $arg_e;
149
+
if ($expired) {
150
+
return 403;
151
+
}
152
+
echo "OK";
153
+
}
154
+
128
155
location = /rand {
129
156
set $from 3;
130
157
set $to 15;
@@ -518,6 +545,36 @@ This directive can be invoked by [[HttpLuaModule]]'s [[HttpLuaModule#ndk.set_var
518
545
519
546
Similar to the [[#set_encode_base64|set_encode_base64]] directive, but does exactly the the opposite operation, .i.e, decoding a base64 digest into its original form.
520
547
548
+
== set_encode_base64url ==
549
+
'''syntax:'''''set_encode_base64url $dst <src>''
550
+
551
+
'''syntax:'''''set_encode_base64url $dst''
552
+
553
+
'''default:'''''no''
554
+
555
+
'''context:'''''location, location if''
556
+
557
+
'''phase:'''''rewrite''
558
+
559
+
'''category:'''''ndk_set_var_value''
560
+
561
+
Similar to the [[#set_encode_base64|set_encode_base64]] directive, but uses URL safe base64 variant, '+' becomes '-', '/' becomes '_' and there is no padding with '=' characters.
562
+
563
+
== set_decode_base64url ==
564
+
'''syntax:'''''set_decode_base64url $dst <src>''
565
+
566
+
'''syntax:'''''set_decode_base64url $dst''
567
+
568
+
'''default:'''''no''
569
+
570
+
'''context:'''''location, location if''
571
+
572
+
'''phase:'''''rewrite''
573
+
574
+
'''category:'''''ndk_set_var_value''
575
+
576
+
Similar to the [[#set_encode_base64url|set_encode_base64url]] directive, but does exactly the the opposite operation, .i.e, decoding a base64url digest into its original form.
577
+
521
578
== set_encode_hex ==
522
579
'''syntax:'''''set_encode_hex $dst <src>''
523
580
@@ -862,6 +919,20 @@ And accessing <code>/rotate</code> will also output integer sequence 0, 1, 2, 3,
862
919
863
920
This directive was first introduced in the <code>v0.22rc7</code> release.
864
921
922
+
== set_expired ==
923
+
'''syntax:'''''set_expired $dst <timestamp>''
924
+
925
+
'''default:'''''no''
926
+
927
+
'''context:'''''location, location if''
928
+
929
+
'''phase:'''''rewrite''
930
+
931
+
Sets <code>$dst</code> to either <code>1</code> or <code>0</code>, dependent on whether or not the
932
+
timestamp as defined in <code>timestamp</code> (seconds since 1970-01-01 00:00:00) is or is not in the past.
933
+
934
+
Behind the scene, this directive utilizes the <code>ngx_time</code> API in the Nginx core, so usually no syscall is involved due to the time caching mechanism in the Nginx core.
0 commit comments