summaryrefslogtreecommitdiff
path: root/pod/nginx/ngx_http_ssl_module.pod
blob: eb2ed74a82b5a81dbac4d9ae15506b6300ecb687 (plain)
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
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
=encoding utf-8

=head1 NAME

ngx_http_ssl_module - Module ngx_http_ssl_module




=head1



The C<ngx_http_ssl_module> module provides the
necessary support for HTTPS.





This module is not built by default, it should be enabled with the
C<--with-http_ssl_module>
configuration parameter.

B<NOTE>

This module requires the
L<OpenSSL|http://www.openssl.org> library.





=head1 Example Configuration



To reduce the processor load it is recommended to

=over




=item *

set the number of
L<worker processes|ngx_core_module>
equal to the number of processors,



=item *

enable
L<keep-alive|ngx_http_core_module>
connections,



=item *

enable the shared session cache,



=item *

disable the built-in session cache,



=item *

and possibly increase the session lifetime
(by default, 5 minutes):



=back




    
    <emphasis>worker_processes auto;</emphasis>
    
    http {
    
        ...
    
        server {
            listen              443 ssl;
            <emphasis>keepalive_timeout   70;</emphasis>
    
            ssl_protocols       TLSv1.2 TLSv1.3;
            ssl_ciphers         AES128-SHA:AES256-SHA:RC4-SHA:DES-CBC3-SHA:RC4-MD5;
            ssl_certificate     /usr/local/nginx/conf/cert.pem;
            ssl_certificate_key /usr/local/nginx/conf/cert.key;
            <emphasis>ssl_session_cache   shared:SSL:10m;</emphasis>
            <emphasis>ssl_session_timeout 10m;</emphasis>
    
            ...
        }






=head1 Directives

=head2 ssl


B<syntax:> ssl I<C<on> E<verbar> C<off>>


B<default:> I<off>


B<context:> I<http>


B<context:> I<server>





This directive was made obsolete in version 1.15.0
and was removed in version 1.25.1.
The C<ssl> parameter
of the L<ngx_http_core_module> directive
should be used instead.







=head2 ssl_buffer_size


B<syntax:> ssl_buffer_size I<I<C<size>>>


B<default:> I<16k>


B<context:> I<http>


B<context:> I<server>



This directive appeared in version 1.5.9.





Sets the size of the buffer used for sending data.





By default, the buffer size is 16k, which corresponds to minimal
overhead when sending big responses.
To minimize Time To First Byte it may be beneficial to use smaller values,
for example:

    
    ssl_buffer_size 4k;









=head2 ssl_certificate


B<syntax:> ssl_certificate I<I<C<file>>>



B<context:> I<http>


B<context:> I<server>





Specifies a I<C<file>> with the certificate in the PEM format
for the given virtual server.
If intermediate certificates should be specified in addition to a primary
certificate, they should be specified in the same file in the following
order: the primary certificate comes first, then the intermediate certificates.
A secret key in the PEM format may be placed in the same file.





Since version 1.11.0,
this directive can be specified multiple times
to load certificates of different types, for example, RSA and ECDSA:

    
    server {
        listen              443 ssl;
        server_name         example.com;
    
        ssl_certificate     example.com.rsa.crt;
        ssl_certificate_key example.com.rsa.key;
    
        ssl_certificate     example.com.ecdsa.crt;
        ssl_certificate_key example.com.ecdsa.key;
    
        ...
    }



B<NOTE>

Only OpenSSL 1.0.2 or higher supports separate
L<certificate chains|configuring_https_servers>
for different certificates.
With older versions, only one certificate chain can be used.






Since version 1.15.9, variables can be used in the I<C<file>> name
when using OpenSSL 1.0.2 or higher:

    
    ssl_certificate     $ssl_server_name.crt;
    ssl_certificate_key $ssl_server_name.key;


Note that using variables implies that
a certificate will be loaded for each SSL handshake,
and this may have a negative impact on performance.





The value
C<data>:I<C<$variable>>
can be specified instead of the I<C<file>> (1.15.10),
which loads a certificate from a variable
without using intermediate files.
Note that inappropriate use of this syntax may have its security implications,
such as writing secret key data to
L<error log|ngx_core_module>.





It should be kept in mind that due to the HTTPS protocol limitations
for maximum interoperability virtual servers should listen on
L<different
IP addresses|configuring_https_servers>.







=head2 ssl_certificate_cache


B<syntax:> ssl_certificate_cache I<C<off>>


B<syntax:> ssl_certificate_cache I<
    C<max>=I<C<N>>
    [C<inactive>=I<C<time>>]
    [C<valid>=I<C<time>>]>


B<default:> I<off>


B<context:> I<http>


B<context:> I<server>



This directive appeared in version 1.27.4.





Defines a cache that stores
SSL certificates and
secret keys
specified with variables.





The directive has the following parameters:

=over



=item 
C<max>





sets the maximum number of elements in the cache;
on cache overflow the least recently used (LRU) elements are removed;



=item 
C<inactive>





defines a time after which an element is removed from the cache
if it has not been accessed during this time;
by default, it is 10 seconds;



=item 
C<valid>





defines a time during which
an element in the cache is considered valid
and can be reused;
by default, it is 60 seconds.
Certificates that exceed this time will be reloaded or revalidated;



=item 
C<off>





disables the cache.




=back







Example:

    
    ssl_certificate       $ssl_server_name.crt;
    ssl_certificate_key   $ssl_server_name.key;
    ssl_certificate_cache max=1000 inactive=20s valid=1m;









=head2 ssl_certificate_key


B<syntax:> ssl_certificate_key I<I<C<file>>>



B<context:> I<http>


B<context:> I<server>





Specifies a I<C<file>> with the secret key in the PEM format
for the given virtual server.





The value
C<engine>:I<C<name>>:I<C<id>>
can be specified instead of the I<C<file>> (1.7.9),
which loads a secret key with a specified I<C<id>>
from the OpenSSL engine I<C<name>>.





The value
C<data>:I<C<$variable>>
can be specified instead of the I<C<file>> (1.15.10),
which loads a secret key from a variable without using intermediate files.
Note that inappropriate use of this syntax may have its security implications,
such as writing secret key data to
L<error log|ngx_core_module>.





Since version 1.15.9, variables can be used in the I<C<file>> name
when using OpenSSL 1.0.2 or higher.







=head2 ssl_ciphers


B<syntax:> ssl_ciphers I<I<C<ciphers>>>


B<default:> I<HIGH:!aNULL:!MD5>


B<context:> I<http>


B<context:> I<server>





Specifies the enabled ciphers.
The ciphers are specified in the format understood by the
OpenSSL library, for example:

    
    ssl_ciphers ALL:!aNULL:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;







The full list can be viewed using the
“C<openssl ciphers>” command.






B<NOTE>

The previous versions of nginx used
L<different|configuring_https_servers>
ciphers by default.








=head2 ssl_client_certificate


B<syntax:> ssl_client_certificate I<I<C<file>>>



B<context:> I<http>


B<context:> I<server>





Specifies a I<C<file>> with trusted CA certificates in the PEM format
used to verify client certificates and
OCSP responses if L</ssl_stapling> is enabled.





The list of certificates will be sent to clients.
If this is not desired, the L</ssl_trusted_certificate>
directive can be used.







=head2 ssl_conf_command


B<syntax:> ssl_conf_command I<I<C<name>> I<C<value>>>



B<context:> I<http>


B<context:> I<server>



This directive appeared in version 1.19.4.





Sets arbitrary OpenSSL configuration
L<commands|https://www.openssl.org/docs/man1.1.1/man3/SSL_CONF_cmd.html>.

B<NOTE>

The directive is supported when using OpenSSL 1.0.2 or higher.






Several C<ssl_conf_command> directives
can be specified on the same level:

    
    ssl_conf_command Options PrioritizeChaCha;
    ssl_conf_command Ciphersuites TLS_CHACHA20_POLY1305_SHA256;


These directives are inherited from the previous configuration level
if and only if there are no C<ssl_conf_command> directives
defined on the current level.






B<NOTE>

Note that configuring OpenSSL directly
might result in unexpected behavior.








=head2 ssl_crl


B<syntax:> ssl_crl I<I<C<file>>>



B<context:> I<http>


B<context:> I<server>



This directive appeared in version 0.8.7.





Specifies a I<C<file>> with revoked certificates (CRL)
in the PEM format used to verify
client certificates.







=head2 ssl_dhparam


B<syntax:> ssl_dhparam I<I<C<file>>>



B<context:> I<http>


B<context:> I<server>



This directive appeared in version 0.7.2.





Specifies a I<C<file>> with DH parameters for DHE ciphers.





By default no parameters are set,
and therefore DHE ciphers will not be used.

B<NOTE>

Prior to version 1.11.0, builtin parameters were used by default.








=head2 ssl_early_data


B<syntax:> ssl_early_data I<C<on> E<verbar> C<off>>


B<default:> I<off>


B<context:> I<http>


B<context:> I<server>



This directive appeared in version 1.15.3.





Enables or disables TLS 1.3
L<early data|https://datatracker.ietf.org/doc/html/rfc8446#section-2.3>.

B<NOTE>

Requests sent within early data are subject to
L<replay attacks|https://datatracker.ietf.org/doc/html/rfc8470>.
To protect against such attacks at the application layer,
the $ssl_early_data variable
should be used.



    
    proxy_set_header Early-Data $ssl_early_data;




B<NOTE>

The directive is supported when using OpenSSL 1.1.1 or higher (1.15.4) and
L<BoringSSL|https://boringssl.googlesource.com/boringssl/>.








=head2 ssl_ecdh_curve


B<syntax:> ssl_ecdh_curve I<I<C<curve>>>


B<default:> I<auto>


B<context:> I<http>


B<context:> I<server>



This directive appeared in version 1.1.0.



This directive appeared in version 1.0.6.





Specifies a I<C<curve>> for ECDHE ciphers.





When using OpenSSL 1.0.2 or higher,
it is possible to specify multiple curves (1.11.0), for example:

    
    ssl_ecdh_curve prime256v1:secp384r1;







The special value C<auto> (1.11.0) instructs nginx to use
a list built into the OpenSSL library when using OpenSSL 1.0.2 or higher,
or C<prime256v1> with older versions.






B<NOTE>

Prior to version 1.11.0,
the C<prime256v1> curve was used by default.







B<NOTE>

When using OpenSSL 1.0.2 or higher,
this directive sets the list of curves supported by the server.
Thus, in order for ECDSA certificates to work,
it is important to include the curves used in the certificates.








=head2 ssl_key_log


B<syntax:> ssl_key_log I<path>



B<context:> I<http>


B<context:> I<server>



This directive appeared in version 1.27.2.





Enables logging of client connection SSL keys
and specifies the path to the key log file.
Keys are logged in the
L<SSLKEYLOGFILE|https://datatracker.ietf.org/doc/html/draft-ietf-tls-keylogfile>
format compatible with Wireshark.






B<NOTE>

This directive is available as part of our
commercial subscription.








=head2 ssl_ocsp


B<syntax:> ssl_ocsp I<C<on> E<verbar>
        C<off> E<verbar>
        C<leaf>>


B<default:> I<off>


B<context:> I<http>


B<context:> I<server>



This directive appeared in version 1.19.0.





Enables OCSP validation of the client certificate chain.
The C<leaf> parameter
enables validation of the client certificate only.





For the OCSP validation to work,
the L</ssl_verify_client> directive should be set to
C<on> or C<optional>.





To resolve the OCSP responder hostname,
the L<ngx_http_core_module> directive
should also be specified.





Example:

    
    ssl_verify_client on;
    ssl_ocsp          on;
    resolver          192.0.2.1;









=head2 ssl_ocsp_cache


B<syntax:> ssl_ocsp_cache I<
    C<off> E<verbar>
    [C<shared>:I<C<name>>:I<C<size>>]>


B<default:> I<off>


B<context:> I<http>


B<context:> I<server>



This directive appeared in version 1.19.0.





Sets C<name> and C<size> of the cache
that stores client certificates status for OCSP validation.
The cache is shared between all worker processes.
A cache with the same name can be used in several virtual servers.





The C<off> parameter prohibits the use of the cache.







=head2 ssl_ocsp_responder


B<syntax:> ssl_ocsp_responder I<I<C<url>>>



B<context:> I<http>


B<context:> I<server>



This directive appeared in version 1.19.0.





Overrides the URL of the OCSP responder specified in the
“L<Authority
Information Access|https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.2.1>” certificate extension
for validation of client certificates.





Only “C<http:E<sol>E<sol>>” OCSP responders are supported:

    
    ssl_ocsp_responder http://ocsp.example.com/;









=head2 ssl_password_file


B<syntax:> ssl_password_file I<I<C<file>>>



B<context:> I<http>


B<context:> I<server>



This directive appeared in version 1.7.3.





Specifies a I<C<file>> with passphrases for
secret keys
where each passphrase is specified on a separate line.
Passphrases are tried in turn when loading the key.





Example:

    
    http {
        ssl_password_file /etc/keys/global.pass;
        ...
    
        server {
            server_name www1.example.com;
            ssl_certificate_key /etc/keys/first.key;
        }
    
        server {
            server_name www2.example.com;
    
            # named pipe can also be used instead of a file
            ssl_password_file /etc/keys/fifo;
            ssl_certificate_key /etc/keys/second.key;
        }
    }









=head2 ssl_prefer_server_ciphers


B<syntax:> ssl_prefer_server_ciphers I<C<on> E<verbar> C<off>>


B<default:> I<off>


B<context:> I<http>


B<context:> I<server>





Specifies that server ciphers should be preferred over client
ciphers when using the SSLv3 and TLS protocols.







=head2 ssl_protocols


B<syntax:> ssl_protocols I<
    [C<SSLv2>]
    [C<SSLv3>]
    [C<TLSv1>]
    [C<TLSv1.1>]
    [C<TLSv1.2>]
    [C<TLSv1.3>]>


B<default:> I<TLSv1.2 TLSv1.3>


B<context:> I<http>


B<context:> I<server>





Enables the specified protocols.





If the directive is specified
on the L<ngx_http_core_module> level,
the value from the default server can be used.
Details are provided in the
“L<Virtual
server selection|server_names>” section.






B<NOTE>

The C<TLSv1.1> and C<TLSv1.2> parameters
(1.1.13, 1.0.12) work only when OpenSSL 1.0.1 or higher is used.


B<NOTE>

The C<TLSv1.3> parameter (1.13.0) works only when
OpenSSL 1.1.1 or higher is used.


B<NOTE>

The C<TLSv1.3> parameter is used by default
since 1.23.4.








=head2 ssl_reject_handshake


B<syntax:> ssl_reject_handshake I<C<on> E<verbar> C<off>>


B<default:> I<off>


B<context:> I<http>


B<context:> I<server>



This directive appeared in version 1.19.4.





If enabled, SSL handshakes in
the L<ngx_http_core_module> block will be rejected.





For example, in the following configuration, SSL handshakes with
server names other than C<example.com> are rejected:

    
    server {
        listen               443 ssl default_server;
        ssl_reject_handshake on;
    }
    
    server {
        listen              443 ssl;
        server_name         example.com;
        ssl_certificate     example.com.crt;
        ssl_certificate_key example.com.key;
    }









=head2 ssl_session_cache


B<syntax:> ssl_session_cache I<
    C<off> E<verbar>
    C<none> E<verbar>
    [C<builtin>[:I<C<size>>]]
    [C<shared>:I<C<name>>:I<C<size>>]>


B<default:> I<none>


B<context:> I<http>


B<context:> I<server>





Sets the types and sizes of caches that store session parameters.
A cache can be of any of the following types:

=over



=item C<off>




the use of a session cache is strictly prohibited:
nginx explicitly tells a client that sessions may not be reused.



=item C<none>




the use of a session cache is gently disallowed:
nginx tells a client that sessions may be reused, but does not
actually store session parameters in the cache.



=item C<builtin>




a cache built in OpenSSL; used by one worker process only.
The cache size is specified in sessions.
If size is not given, it is equal to 20480 sessions.
Use of the built-in cache can cause memory fragmentation.



=item C<shared>




a cache shared between all worker processes.
The cache size is specified in bytes; one megabyte can store
about 4000 sessions.
Each shared cache should have an arbitrary name.
A cache with the same name can be used in several virtual servers.
It is also used to automatically generate, store, and
periodically rotate TLS session ticket keys (1.23.2)
unless configured explicitly
using the L</ssl_session_ticket_key> directive.




=back







Both cache types can be used simultaneously, for example:

    
    ssl_session_cache builtin:1000 shared:SSL:10m;


but using only shared cache without the built-in cache should
be more efficient.







=head2 ssl_session_ticket_key


B<syntax:> ssl_session_ticket_key I<I<C<file>>>



B<context:> I<http>


B<context:> I<server>



This directive appeared in version 1.5.7.





Sets a I<C<file>> with the secret key used to encrypt
and decrypt TLS session tickets.
The directive is necessary if the same key has to be shared between
multiple servers.
By default, a randomly generated key is used.





If several keys are specified, only the first key is
used to encrypt TLS session tickets.
This allows configuring key rotation, for example:

    
    ssl_session_ticket_key current.key;
    ssl_session_ticket_key previous.key;







The I<C<file>> must contain 80 or 48 bytes
of random data and can be created using the following command:

    
    openssl rand 80 > ticket.key


Depending on the file size either AES256 (for 80-byte keys, 1.11.8)
or AES128 (for 48-byte keys) is used for encryption.







=head2 ssl_session_tickets


B<syntax:> ssl_session_tickets I<C<on> E<verbar> C<off>>


B<default:> I<on>


B<context:> I<http>


B<context:> I<server>



This directive appeared in version 1.5.9.





Enables or disables session resumption through
L<TLS session tickets|https://datatracker.ietf.org/doc/html/rfc5077>.







=head2 ssl_session_timeout


B<syntax:> ssl_session_timeout I<I<C<time>>>


B<default:> I<5m>


B<context:> I<http>


B<context:> I<server>





Specifies a time during which a client may reuse the
session parameters.







=head2 ssl_stapling


B<syntax:> ssl_stapling I<C<on> E<verbar> C<off>>


B<default:> I<off>


B<context:> I<http>


B<context:> I<server>



This directive appeared in version 1.3.7.





Enables or disables
L<stapling
of OCSP responses|https://datatracker.ietf.org/doc/html/rfc6066#section-8> by the server.
Example:

    
    ssl_stapling on;
    resolver 192.0.2.1;







For the OCSP stapling to work, the certificate of the server certificate
issuer should be known.
If the L</ssl_certificate> file does
not contain intermediate certificates,
the certificate of the server certificate issuer should be
present in the
L</ssl_trusted_certificate> file.





For a resolution of the OCSP responder hostname,
the L<ngx_http_core_module> directive
should also be specified.







=head2 ssl_stapling_file


B<syntax:> ssl_stapling_file I<I<C<file>>>



B<context:> I<http>


B<context:> I<server>



This directive appeared in version 1.3.7.





When set, the stapled OCSP response will be taken from the
specified I<C<file>> instead of querying
the OCSP responder specified in the server certificate.





The file should be in the DER format as produced by the
“C<openssl ocsp>” command.







=head2 ssl_stapling_responder


B<syntax:> ssl_stapling_responder I<I<C<url>>>



B<context:> I<http>


B<context:> I<server>



This directive appeared in version 1.3.7.





Overrides the URL of the OCSP responder specified in the
“L<Authority
Information Access|https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.2.1>” certificate extension.





Only “C<http:E<sol>E<sol>>” OCSP responders are supported:

    
    ssl_stapling_responder http://ocsp.example.com/;









=head2 ssl_stapling_verify


B<syntax:> ssl_stapling_verify I<C<on> E<verbar> C<off>>


B<default:> I<off>


B<context:> I<http>


B<context:> I<server>



This directive appeared in version 1.3.7.





Enables or disables verification of OCSP responses by the server.





For verification to work, the certificate of the server certificate
issuer, the root certificate, and all intermediate certificates
should be configured as trusted using the
L</ssl_trusted_certificate> directive.







=head2 ssl_trusted_certificate


B<syntax:> ssl_trusted_certificate I<I<C<file>>>



B<context:> I<http>


B<context:> I<server>



This directive appeared in version 1.3.7.





Specifies a I<C<file>> with trusted CA certificates in the PEM format
used to verify client certificates and
OCSP responses if L</ssl_stapling> is enabled.





In contrast to the certificate set by L</ssl_client_certificate>,
the list of these certificates will not be sent to clients.







=head2 ssl_verify_client


B<syntax:> ssl_verify_client I<
    C<on> E<verbar> C<off> E<verbar>
    C<optional> E<verbar> C<optional_no_ca>>


B<default:> I<off>


B<context:> I<http>


B<context:> I<server>





Enables verification of client certificates.
The verification result is stored in the
$ssl_client_verify variable.





The C<optional> parameter (0.8.7+) requests the client
certificate and verifies it if the certificate is present.





The C<optional_no_ca> parameter (1.3.8, 1.2.5)
requests the client
certificate but does not require it to be signed by a trusted CA certificate.
This is intended for the use in cases when a service that is external to nginx
performs the actual certificate verification.
The contents of the certificate is accessible through the
$ssl_client_cert variable.







=head2 ssl_verify_depth


B<syntax:> ssl_verify_depth I<I<C<number>>>


B<default:> I<1>


B<context:> I<http>


B<context:> I<server>





Sets the verification depth in the client certificates chain.







=head1 Error Processing



The C<ngx_http_ssl_module> module supports several
non-standard error codes that can be used for redirects using the
L<ngx_http_core_module> directive:

=over



=item C<495>
an error has occurred during the client certificate verification;



=item C<496>
a client has not presented the required certificate;



=item C<497>
a regular request has been sent to the HTTPS port.




=back







The redirection happens after the request is fully parsed and
the variables, such as C<$request_uri>,
C<$uri>, C<$args> and others, are available.




=head1 Embedded Variables



The C<ngx_http_ssl_module> module supports
embedded variables:

=over



=item C<$ssl_alpn_protocol>




returns the protocol selected by ALPN during the SSL handshake,
or an empty string otherwise (1.21.4);



=item C<$ssl_cipher>




returns the name of the cipher used
for an established SSL connection;



=item C<$ssl_ciphers>




returns the list of ciphers supported by the client (1.11.7).
Known ciphers are listed by names, unknown are shown in hexadecimal,
for example:

    
    AES128-SHA:AES256-SHA:0x00ff



B<NOTE>

The variable is fully supported only when using OpenSSL version 1.0.2 or higher.
With older versions, the variable is available
only for new sessions and lists only known ciphers.




=item C<$ssl_client_escaped_cert>




returns the client certificate in the PEM format (urlencoded)
for an established SSL connection (1.13.5);



=item C<$ssl_client_cert>




returns the client certificate in the PEM format
for an established SSL connection, with each line except the first
prepended with the tab character;
this is intended for the use in the
L<ngx_http_proxy_module> directive;

B<NOTE>

The variable is deprecated,
the C<$ssl_client_escaped_cert> variable should be used instead.




=item C<$ssl_client_fingerprint>




returns the SHA1 fingerprint of the client certificate
for an established SSL connection (1.7.1);



=item C<$ssl_client_i_dn>




returns the “issuer DN” string of the client certificate
for an established SSL connection according to
L<RFC 2253|https://datatracker.ietf.org/doc/html/rfc2253> (1.11.6);



=item C<$ssl_client_i_dn_legacy>




returns the “issuer DN” string of the client certificate
for an established SSL connection;

B<NOTE>

Prior to version 1.11.6, the variable name was C<$ssl_client_i_dn>.




=item C<$ssl_client_raw_cert>





returns the client certificate in the PEM format
for an established SSL connection;



=item C<$ssl_client_s_dn>




returns the “subject DN” string of the client certificate
for an established SSL connection according to
L<RFC 2253|https://datatracker.ietf.org/doc/html/rfc2253> (1.11.6);



=item C<$ssl_client_s_dn_legacy>




returns the “subject DN” string of the client certificate
for an established SSL connection;

B<NOTE>

Prior to version 1.11.6, the variable name was C<$ssl_client_s_dn>.




=item C<$ssl_client_serial>




returns the serial number of the client certificate
for an established SSL connection;



=item C<$ssl_client_v_end>




returns the end date of the client certificate (1.11.7);



=item C<$ssl_client_v_remain>




returns the number of days
until the client certificate expires (1.11.7);



=item C<$ssl_client_v_start>




returns the start date of the client certificate (1.11.7);



=item C<$ssl_client_verify>




returns the result of client certificate verification:
“C<SUCCESS>”, “C<FAILED:>I<C<reason>>”,
and “C<NONE>” if a certificate was not present;

B<NOTE>

Prior to version 1.11.7, the “C<FAILED>” result
did not contain the I<C<reason>> string.




=item C<$ssl_curve>




returns the negotiated curve used for
SSL handshake key exchange process (1.21.5).
Known curves are listed by names, unknown are shown in hexadecimal,
for example:

    
    prime256v1



B<NOTE>

The variable is supported only when using OpenSSL version 3.0 or higher.
With older versions, the variable value will be an empty string.




=item C<$ssl_curves>




returns the list of curves supported by the client (1.11.7).
Known curves are listed by names, unknown are shown in hexadecimal,
for example:

    
    0x001d:prime256v1:secp521r1:secp384r1



B<NOTE>

The variable is supported only when using OpenSSL version 1.0.2 or higher.
With older versions, the variable value will be an empty string.


B<NOTE>

The variable is available only for new sessions.




=item C<$ssl_early_data>




returns “C<1>” if
TLS 1.3 early data is used
and the handshake is not complete, otherwise “” (1.15.3).



=item C<$ssl_protocol>




returns the protocol of an established SSL connection;



=item C<$ssl_server_name>




returns the server name requested through
L<SNI|http://en.wikipedia.org/wiki/Server_Name_Indication>
(1.7.0);



=item C<$ssl_session_id>




returns the session identifier of an established SSL connection;



=item C<$ssl_session_reused>




returns “C<r>” if an SSL session was reused,
or “C<.>” otherwise (1.5.11).




=back