1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
|
=encoding utf-8
=head1 NAME
ngx_stream_core_module - Module ngx_stream_core_module
=head1
The C<ngx_stream_core_module> module
is available since version 1.9.0.
This module is not built by default, it should be enabled with the
C<--with-stream>
configuration parameter.
=head1 Example Configuration
worker_processes auto;
error_log /var/log/nginx/error.log info;
events {
worker_connections 1024;
}
stream {
upstream backend {
hash $remote_addr consistent;
server backend1.example.com:12345 weight=5;
server 127.0.0.1:12345 max_fails=3 fail_timeout=30s;
server unix:/tmp/backend3;
}
upstream dns {
server 192.168.0.1:53535;
server dns.example.com:53;
}
server {
listen 12345;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass backend;
}
server {
listen 127.0.0.1:53 udp reuseport;
proxy_timeout 20s;
proxy_pass dns;
}
server {
listen [::1]:12345;
proxy_pass unix:/tmp/stream.socket;
}
}
=head1 Directives
=head2 listen
B<syntax:> listen I<
I<C<address>>:I<C<port>>
[C<default_server>]
[C<ssl>]
[C<udp>]
[C<proxy_protocol>]
[C<setfib>=I<C<number>>]
[C<fastopen>=I<C<number>>]
[C<backlog>=I<C<number>>]
[C<rcvbuf>=I<C<size>>]
[C<sndbuf>=I<C<size>>]
[C<accept_filter>=I<C<filter>>]
[C<deferred>]
[C<bind>]
[C<ipv6only>=C<on>E<verbar>C<off>]
[C<reuseport>]
[C<so_keepalive>=C<on>E<verbar>C<off>E<verbar>[I<C<keepidle>>]:[I<C<keepintvl>>]:[I<C<keepcnt>>]]>
B<context:> I<server>
Sets the I<C<address>> and I<C<port>> for the socket
on which the server will accept connections.
It is possible to specify just the port.
The address can also be a hostname, for example:
listen 127.0.0.1:12345;
listen *:12345;
listen 12345; # same as *:12345
listen localhost:12345;
IPv6 addresses are specified in square brackets:
listen [::1]:12345;
listen [::]:12345;
UNIX-domain sockets are specified with the “C<unix:>”
prefix:
listen unix:/var/run/nginx.sock;
Port ranges (1.15.10) are specified with the
first and last port separated by a hyphen:
listen 127.0.0.1:12345-12399;
listen 12345-12399;
The C<default_server> parameter, if present,
will cause the server to become the default server for the specified
I<C<address>>:I<C<port>> pair (1.25.5).
If none of the directives have the C<default_server>
parameter then the first server with the
I<C<address>>:I<C<port>> pair will be
the default server for this pair.
The C<ssl> parameter allows specifying that all
connections accepted on this port should work in SSL mode.
The C<udp> parameter configures a listening socket
for working with datagrams (1.9.13).
In order to handle packets from the same address and port in the same session,
the C<reuseport> parameter
should also be specified.
The C<proxy_protocol> parameter (1.11.4)
allows specifying that all connections accepted on this port should use the
L<PROXY
protocol|http://www.haproxy.org/download/1.8/doc/proxy-protocol.txt>.
B<NOTE>
The PROXY protocol version 2 is supported since version 1.13.11.
The C<listen> directive
can have several additional parameters specific to socket-related system calls.
These parameters can be specified in any
C<listen> directive, but only once for a given
I<C<address>>:I<C<port>> pair.
=over
=item
C<setfib>=I<C<number>>
this parameter (1.25.5) sets the associated routing table, FIB
(the C<SO_SETFIB> option) for the listening socket.
This currently works only on FreeBSD.
=item
C<fastopen>=I<C<number>>
enables
“L<TCP Fast Open|http://en.wikipedia.org/wiki/TCP_Fast_Open>”
for the listening socket (1.21.0) and
L<limits|https://datatracker.ietf.org/doc/html/rfc7413#section-5.1>
the maximum length for the queue of connections that have not yet completed
the three-way handshake.
B<NOTE>
Do not enable this feature unless the server can handle
receiving the
L<same SYN packet with data|https://datatracker.ietf.org/doc/html/rfc7413#section-6.1> more than once.
=item
C<backlog>=I<C<number>>
sets the C<backlog> parameter in the
C<listen> call that limits
the maximum length for the queue of pending connections (1.9.2).
By default,
C<backlog> is set to -1 on FreeBSD, DragonFly BSD, and macOS,
and to 511 on other platforms.
=item
C<rcvbuf>=I<C<size>>
sets the receive buffer size
(the C<SO_RCVBUF> option) for the listening socket (1.11.13).
=item
C<sndbuf>=I<C<size>>
sets the send buffer size
(the C<SO_SNDBUF> option) for the listening socket (1.11.13).
=item
C<accept_filter>=I<C<filter>>
sets the name of accept filter
(the C<SO_ACCEPTFILTER> option) for the listening socket
that filters incoming connections before passing them to
C<accept> (1.25.5).
This works only on FreeBSD and NetBSD 5.0+.
Possible values are
L<dataready|http://man.freebsd.org/accf_data>
and
L<httpready|http://man.freebsd.org/accf_http>.
=item
C<deferred>
instructs to use a deferred C<accept>
(the C<TCP_DEFER_ACCEPT> socket option) on Linux (1.25.5).
=item
C<bind>
this parameter instructs to make a separate C<bind>
call for a given address:port pair.
The fact is that if there are several C<listen> directives with
the same port but different addresses, and one of the
C<listen> directives listens on all addresses
for the given port (C<*:>I<C<port>>), nginx will
C<bind> only to C<*:>I<C<port>>.
It should be noted that the C<getsockname> system call will be
made in this case to determine the address that accepted the connection.
If the C<setfib>,
C<fastopen>,
C<backlog>, C<rcvbuf>,
C<sndbuf>, C<accept_filter>,
C<deferred>, C<ipv6only>,
C<reuseport>,
or C<so_keepalive> parameters
are used then for a given
I<C<address>>:I<C<port>> pair
a separate C<bind> call will always be made.
=item
C<ipv6only>=C<on>E<verbar>C<off>
this parameter determines
(via the C<IPV6_V6ONLY> socket option)
whether an IPv6 socket listening on a wildcard address C<[::]>
will accept only IPv6 connections or both IPv6 and IPv4 connections.
This parameter is turned on by default.
It can only be set once on start.
=item
C<reuseport>
this parameter (1.9.1) instructs to create an individual listening socket
for each worker process
(using the
C<SO_REUSEPORT> socket option on Linux 3.9+ and DragonFly BSD,
or C<SO_REUSEPORT_LB> on FreeBSD 12+), allowing a kernel
to distribute incoming connections between worker processes.
This currently works only on Linux 3.9+, DragonFly BSD,
and FreeBSD 12+ (1.15.1).
B<NOTE>
Inappropriate use of this option may have its security
L<implications|http://man7.org/linux/man-pages/man7/socket.7.html>.
=item
C<so_keepalive>=C<on>E<verbar>C<off>E<verbar>[I<C<keepidle>>]:[I<C<keepintvl>>]:[I<C<keepcnt>>]
this parameter configures the “TCP keepalive” behavior
for the listening socket.
If this parameter is omitted then the operating system’s settings will be
in effect for the socket.
If it is set to the value “C<on>”, the
C<SO_KEEPALIVE> option is turned on for the socket.
If it is set to the value “C<off>”, the
C<SO_KEEPALIVE> option is turned off for the socket.
Some operating systems support setting of TCP keepalive parameters on
a per-socket basis using the C<TCP_KEEPIDLE>,
C<TCP_KEEPINTVL>, and C<TCP_KEEPCNT> socket options.
On such systems (currently, Linux 2.4+, NetBSD 5+, and
FreeBSD 9.0-STABLE), they can be configured
using the I<C<keepidle>>, I<C<keepintvl>>, and
I<C<keepcnt>> parameters.
One or two parameters may be omitted, in which case the system default setting
for the corresponding socket option will be in effect.
For example,
so_keepalive=30m::10
will set the idle timeout (C<TCP_KEEPIDLE>) to 30 minutes,
leave the probe interval (C<TCP_KEEPINTVL>) at its system default,
and set the probes count (C<TCP_KEEPCNT>) to 10 probes.
=back
B<NOTE>
Before version 1.25.5, different servers must listen on different
I<C<address>>:I<C<port>> pairs.
=head2 preread_buffer_size
B<syntax:> preread_buffer_size I<I<C<size>>>
B<default:> I<16k>
B<context:> I<stream>
B<context:> I<server>
This directive appeared in version 1.11.5.
Specifies a I<C<size>> of the
L<preread|stream_processing> buffer.
=head2 preread_timeout
B<syntax:> preread_timeout I<I<C<timeout>>>
B<default:> I<30s>
B<context:> I<stream>
B<context:> I<server>
This directive appeared in version 1.11.5.
Specifies a I<C<timeout>> of the
L<preread|stream_processing> phase.
=head2 proxy_protocol_timeout
B<syntax:> proxy_protocol_timeout I<I<C<timeout>>>
B<default:> I<30s>
B<context:> I<stream>
B<context:> I<server>
This directive appeared in version 1.11.4.
Specifies a I<C<timeout>> for
reading the PROXY protocol header to complete.
If no entire header is transmitted within this time,
the connection is closed.
=head2 resolver
B<syntax:> resolver I<
I<C<address>> ...
[C<valid>=I<C<time>>]
[C<ipv4>=C<on>E<verbar>C<off>]
[C<ipv6>=C<on>E<verbar>C<off>]
[C<status_zone>=I<C<zone>>]>
B<context:> I<stream>
B<context:> I<server>
This directive appeared in version 1.11.3.
Configures name servers used to resolve names of upstream servers
into addresses, for example:
resolver 127.0.0.1 [::1]:5353;
The address can be specified as a domain name or IP address,
with an optional port.
If port is not specified, the port 53 is used.
Name servers are queried in a round-robin fashion.
By default, nginx will look up both IPv4 and IPv6 addresses while resolving.
If looking up of IPv4 or IPv6 addresses is not desired,
the C<ipv4=off> (1.23.1) or
the C<ipv6=off> parameter can be specified.
By default, nginx caches answers using the TTL value of a response.
The optional C<valid> parameter allows overriding it:
resolver 127.0.0.1 [::1]:5353 valid=30s;
B<NOTE>
To prevent DNS spoofing, it is recommended
configuring DNS servers in a properly secured trusted local network.
The optional C<status_zone> parameter (1.17.1)
enables
L<collection|ngx_http_api_module>
of DNS server statistics of requests and responses
in the specified I<C<zone>>.
The parameter is available as part of our
commercial subscription.
B<NOTE>
Before version 1.11.3, this directive was available as part of our
commercial subscription.
=head2 resolver_timeout
B<syntax:> resolver_timeout I<I<C<time>>>
B<default:> I<30s>
B<context:> I<stream>
B<context:> I<server>
This directive appeared in version 1.11.3.
Sets a timeout for name resolution, for example:
resolver_timeout 5s;
B<NOTE>
Before version 1.11.3, this directive was available as part of our
commercial subscription.
=head2 server
server { B<...> }
B<context:> I<stream>
Sets the configuration for a virtual server.
There is no clear separation between IP-based (based on the IP address)
and name-based (based on the
L<TLS
Server Name Indication extension|http://en.wikipedia.org/wiki/Server_Name_Indication> (SNI, RFC 6066)) (1.25.5)
virtual servers.
Instead, the L</listen> directives describe all
addresses and ports that should accept connections for the server, and the
L</server_name> directive lists all server names.
=head2 server_name
B<syntax:> server_name I<I<C<name>> ...>
B<default:> I<"">
B<context:> I<server>
This directive appeared in version 1.25.5.
Sets names of a virtual server, for example:
server {
server_name example.com www.example.com;
}
The first name becomes the primary server name.
Server names can include an asterisk (“C<*>”)
replacing the first or last part of a name:
server {
server_name example.com *.example.com www.example.*;
}
Such names are called wildcard names.
The first two of the names mentioned above can be combined in one:
server {
server_name .example.com;
}
It is also possible to use regular expressions in server names,
preceding the name with a tilde (“C<~>”):
server {
server_name www.example.com ~^www\d+\.example\.com$;
}
Regular expressions can contain captures that can later
be used in other directives:
server {
server_name ~^(www\.)?(.+)$;
proxy_pass www.$2:12345;
}
Named captures in regular expressions create variables
that can later be used in other directives:
server {
server_name ~^(www\.)?(?<domain>.+)$;
proxy_pass www.$domain:12345;
}
If the directive’s parameter is set to “C<$hostname>”, the
machine’s hostname is inserted.
During searching for a virtual server by name,
if the name matches more than one of the specified variants,
(e.g. both a wildcard name and regular expression match), the first matching
variant will be chosen, in the following order of priority:
=over
=item 1.
the exact name
=item 2.
the longest wildcard name starting with an asterisk,
e.g. “C<*.example.com>”
=item 3.
the longest wildcard name ending with an asterisk,
e.g. “C<mail.*>”
=item 4.
the first matching regular expression
(in order of appearance in the configuration file)
=back
=head2 server_names_hash_bucket_size
B<syntax:> server_names_hash_bucket_size I<I<C<size>>>
B<default:> I<32E<verbar>64E<verbar>128>
B<context:> I<stream>
This directive appeared in version 1.25.5.
Sets the bucket size for the server names hash tables.
The default value depends on the size of the processor’s cache line.
The details of setting up hash tables are provided in a separate
L<document|hash>.
=head2 server_names_hash_max_size
B<syntax:> server_names_hash_max_size I<I<C<size>>>
B<default:> I<512>
B<context:> I<stream>
This directive appeared in version 1.25.5.
Sets the maximum I<C<size>> of the server names hash tables.
The details of setting up hash tables are provided in a separate
L<document|hash>.
=head2 stream
stream { B<...> }
B<context:> I<main>
Provides the configuration file context in which the stream server directives
are specified.
=head2 tcp_nodelay
B<syntax:> tcp_nodelay I<C<on> E<verbar> C<off>>
B<default:> I<on>
B<context:> I<stream>
B<context:> I<server>
This directive appeared in version 1.9.4.
Enables or disables the use of the C<TCP_NODELAY> option.
The option is enabled for both client and proxied server connections.
=head2 variables_hash_bucket_size
B<syntax:> variables_hash_bucket_size I<I<C<size>>>
B<default:> I<64>
B<context:> I<stream>
This directive appeared in version 1.11.2.
Sets the bucket size for the variables hash table.
The details of setting up hash tables are provided in a separate
L<document|hash>.
=head2 variables_hash_max_size
B<syntax:> variables_hash_max_size I<I<C<size>>>
B<default:> I<1024>
B<context:> I<stream>
This directive appeared in version 1.11.2.
Sets the maximum I<C<size>> of the variables hash table.
The details of setting up hash tables are provided in a separate
L<document|hash>.
=head1 Embedded Variables
The C<ngx_stream_core_module> module supports variables
since 1.11.2.
=over
=item C<$binary_remote_addr>
client address in a binary form, value’s length is always 4 bytes
for IPv4 addresses or 16 bytes for IPv6 addresses
=item C<$bytes_received>
number of bytes received from a client (1.11.4)
=item C<$bytes_sent>
number of bytes sent to a client
=item C<$connection>
connection serial number
=item C<$hostname>
host name
=item C<$msec>
current time in seconds with the milliseconds resolution
=item C<$nginx_version>
nginx version
=item C<$pid>
PID of the worker process
=item C<$protocol>
protocol used to communicate with the client:
C<TCP> or C<UDP> (1.11.4)
=item C<$proxy_protocol_addr>
client address from the PROXY protocol header (1.11.4)
The PROXY protocol must be previously enabled by setting the
C<proxy_protocol> parameter
in the L</listen> directive.
=item C<$proxy_protocol_port>
client port from the PROXY protocol header (1.11.4)
The PROXY protocol must be previously enabled by setting the
C<proxy_protocol> parameter
in the L</listen> directive.
=item C<$proxy_protocol_server_addr>
server address from the PROXY protocol header (1.17.6)
The PROXY protocol must be previously enabled by setting the
C<proxy_protocol> parameter
in the L</listen> directive.
=item C<$proxy_protocol_server_port>
server port from the PROXY protocol header (1.17.6)
The PROXY protocol must be previously enabled by setting the
C<proxy_protocol> parameter
in the L</listen> directive.
=item C<$proxy_protocol_tlv_>I<C<name>>
TLV from the PROXY Protocol header (1.23.2).
The C<name> can be a TLV type name or its numeric value.
In the latter case, the value is hexadecimal
and should be prefixed with C<0x>:
$proxy_protocol_tlv_alpn
$proxy_protocol_tlv_0x01
SSL TLVs can also be accessed by TLV type name or its numeric value,
both prefixed by C<ssl_>:
$proxy_protocol_tlv_ssl_version
$proxy_protocol_tlv_ssl_0x21
The following TLV type names are supported:
=over
=item *
C<alpn> (C<0x01>)E<mdash>
upper layer protocol used over the connection
=item *
C<authority> (C<0x02>)E<mdash>
host name value passed by the client
=item *
C<unique_id> (C<0x05>)E<mdash>
unique connection id
=item *
C<netns> (C<0x30>)E<mdash>
name of the namespace
=item *
C<ssl> (C<0x20>)E<mdash>
binary SSL TLV structure
=back
The following SSL TLV type names are supported:
=over
=item *
C<ssl_version> (C<0x21>)E<mdash>
SSL version used in client connection
=item *
C<ssl_cn> (C<0x22>)E<mdash>
SSL certificate Common Name
=item *
C<ssl_cipher> (C<0x23>)E<mdash>
name of the used cipher
=item *
C<ssl_sig_alg> (C<0x24>)E<mdash>
algorithm used to sign the certificate
=item *
C<ssl_key_alg> (C<0x25>)E<mdash>
public-key algorithm
=back
Also, the following special SSL TLV type name is supported:
=over
=item *
C<ssl_verify>E<mdash>
client SSL certificate verification result,
zero if the client presented a certificate
and it was successfully verified, and non-zero otherwise
=back
The PROXY protocol must be previously enabled by setting the
C<proxy_protocol> parameter
in the L</listen> directive.
=item C<$remote_addr>
client address
=item C<$remote_port>
client port
=item C<$server_addr>
an address of the server which accepted a connection
Computing a value of this variable usually requires one system call.
To avoid a system call, the L</listen> directives
must specify addresses and use the C<bind> parameter.
=item C<$server_port>
port of the server which accepted a connection
=item C<$session_time>
session duration in seconds with a milliseconds resolution
(1.11.4);
=item C<$status>
session status (1.11.4), can be one of the following:
=over
=item C<200>
session completed successfully
=item C<400>
client data could not be parsed, for example,
the PROXY protocol header
=item C<403>
access forbidden, for example, when access is limited for
L<certain client addresses|ngx_stream_access_module>
=item C<500>
internal server error
=item C<502>
bad gateway, for example,
if an upstream server could not be selected or reached.
=item C<503>
service unavailable, for example, when access is limited by the
L<number of connections|ngx_stream_limit_conn_module>
=back
=item C<$time_iso8601>
local time in the ISO 8601 standard format
=item C<$time_local>
local time in the Common Log Format
=back
|