Compare commits
682 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d9cd2b45c | ||
|
|
7ca1da8358 | ||
|
|
55d53e6659 | ||
|
|
6c2d17586b | ||
|
|
4696944245 | ||
|
|
49bb37dfdb | ||
|
|
1f855fc7b3 | ||
|
|
364beed773 | ||
|
|
51fd6918ca | ||
|
|
9906ccda42 | ||
|
|
d990354e3d | ||
|
|
2fc3e6c28c | ||
|
|
abcef6be86 | ||
|
|
6e9d46e672 | ||
|
|
16b8cde8e4 | ||
|
|
afd6544702 | ||
|
|
4fc17d6139 | ||
|
|
37134c44d7 | ||
|
|
b5a54ac219 | ||
|
|
4d8f878ba7 | ||
|
|
f5a3492926 | ||
|
|
09a2f40633 | ||
|
|
01745a836f | ||
|
|
6207be5f8f | ||
|
|
6f2a549ef1 | ||
|
|
de4386e440 | ||
|
|
bc2ada1f44 | ||
|
|
c10c7bcbe9 | ||
|
|
41e025f0f0 | ||
|
|
9b4bb07b34 | ||
|
|
9297e94389 | ||
|
|
16066cab61 | ||
|
|
ee8d2cede4 | ||
|
|
7b6b2f773d | ||
|
|
18d0671312 | ||
|
|
7a2b1f8833 | ||
|
|
11a46f728c | ||
|
|
2494e20784 | ||
|
|
1462ff019d | ||
|
|
2115974e93 | ||
|
|
8ac8b021b8 | ||
|
|
926bd43cff | ||
|
|
912a065406 | ||
|
|
6162427c45 | ||
|
|
bcec2d9075 | ||
|
|
daeed502cb | ||
|
|
5a8a6ceae2 | ||
|
|
2760ead490 | ||
|
|
e97bf606c8 | ||
|
|
d6d53893e8 | ||
|
|
aa50116272 | ||
|
|
07cc80ac6b | ||
|
|
8346b68a28 | ||
|
|
f8ae0a4b00 | ||
|
|
d3ded293ac | ||
|
|
fa52426d54 | ||
|
|
8df67cdde8 | ||
|
|
98b6473c84 | ||
|
|
8fbc8514ef | ||
|
|
1775420592 | ||
|
|
92e1a6567e | ||
|
|
486addd144 | ||
|
|
569953521a | ||
|
|
55cfae9636 | ||
|
|
d56b5b370d | ||
|
|
26b0b05f73 | ||
|
|
5d22134ee6 | ||
|
|
b16ad27878 | ||
|
|
017a731302 | ||
|
|
2427b383b5 | ||
|
|
1b253cd908 | ||
|
|
0da38122bd | ||
|
|
f20662eeaa | ||
|
|
d6d8b2205f | ||
|
|
4651bf411d | ||
|
|
744bd82c54 | ||
|
|
491642b1e9 | ||
|
|
14d0f3f222 | ||
|
|
05423c681a | ||
|
|
c117ae8fd8 | ||
|
|
05eee4b7a3 | ||
|
|
9c9545bf7f | ||
|
|
cc9edec1c6 | ||
|
|
831615fdd4 | ||
|
|
3531fa4d37 | ||
|
|
146b7933a9 | ||
|
|
2f898566fc | ||
|
|
af877cf784 | ||
|
|
6f4f9ec20c | ||
|
|
7c0d38cd2e | ||
|
|
cb82aad4c0 | ||
|
|
ba8f5a4eb8 | ||
|
|
ee0d68c34e | ||
|
|
216e0b5e12 | ||
|
|
aadeabe4a6 | ||
|
|
8aa00fcea2 | ||
|
|
5f15f04556 | ||
|
|
9cb21132a4 | ||
|
|
1aadd9ba8c | ||
|
|
f1fb85865d | ||
|
|
9c2b2cec38 | ||
|
|
9f9e5b8cd4 | ||
|
|
02d3a37cfb | ||
|
|
75c7b1399b | ||
|
|
284a935f3c | ||
|
|
050d9da7bd | ||
|
|
b4dd1a4ba8 | ||
|
|
22d58656a0 | ||
|
|
7a1fe49841 | ||
|
|
e5b340cb6f | ||
|
|
4f11827752 | ||
|
|
b53e09373a | ||
|
|
91fac60aae | ||
|
|
302ecfff51 | ||
|
|
515c736d5a | ||
|
|
14ccabf45a | ||
|
|
d23a746833 | ||
|
|
0fbd71362b | ||
|
|
9218caef71 | ||
|
|
510d376f00 | ||
|
|
c4ad18fecc | ||
|
|
20e76ac7a6 | ||
|
|
70d33d976b | ||
|
|
705b29c14f | ||
|
|
998d56c473 | ||
|
|
ae0faa43cd | ||
|
|
2f82265891 | ||
|
|
2e1da37f9a | ||
|
|
576ccc7009 | ||
|
|
6a0a1f6782 | ||
|
|
0442ed9b72 | ||
|
|
d851908c67 | ||
|
|
55d913255d | ||
|
|
1cc3bbf5ce | ||
|
|
4ea3437dfa | ||
|
|
6b48e11e5c | ||
|
|
fea6cc7537 | ||
|
|
5aba125fb7 | ||
|
|
3257177d80 | ||
|
|
5ee6db5e3e | ||
|
|
46eed825f1 | ||
|
|
0ea8a08761 | ||
|
|
993e5f8282 | ||
|
|
5ab320d82a | ||
|
|
fb8ddfd08c | ||
|
|
fee27ea712 | ||
|
|
061d129b1b | ||
|
|
e85ff32f35 | ||
|
|
621e703fad | ||
|
|
55651bba8b | ||
|
|
0185a2971c | ||
|
|
b6b7133a2e | ||
|
|
01446472dd | ||
|
|
08c9586346 | ||
|
|
7ede0fa4b9 | ||
|
|
2509fc1076 | ||
|
|
28c74e8dae | ||
|
|
6a580ad664 | ||
|
|
4099fcd618 | ||
|
|
e08b3487c9 | ||
|
|
12887a977b | ||
|
|
efb250da01 | ||
|
|
c75622db87 | ||
|
|
33eab70d32 | ||
|
|
4b85e95824 | ||
|
|
9df330e51e | ||
|
|
28c73e5b52 | ||
|
|
dad4a2d7bf | ||
|
|
9cd85f61d5 | ||
|
|
e0e1732842 | ||
|
|
fc4c4e17ca | ||
|
|
2901b917a0 | ||
|
|
b6e9cdc065 | ||
|
|
9cdb8047bf | ||
|
|
18027fa71b | ||
|
|
3670d39b71 | ||
|
|
4c622708bd | ||
|
|
15e33a3de5 | ||
|
|
098e551c35 | ||
|
|
fdc90a49be | ||
|
|
42535c01d9 | ||
|
|
f70d81be66 | ||
|
|
dc8094daf5 | ||
|
|
dbdf7d70e4 | ||
|
|
2671ef4aef | ||
|
|
42c8b0c4c9 | ||
|
|
0ff39b804c | ||
|
|
2daa09ff21 | ||
|
|
b411a84a59 | ||
|
|
54dd5d1ef0 | ||
|
|
dbca945a8f | ||
|
|
e22ae4a6fd | ||
|
|
fbf37456d0 | ||
|
|
fde0e809e4 | ||
|
|
679c971a19 | ||
|
|
53ef90a2f6 | ||
|
|
ed7b17d9d7 | ||
|
|
6260c0265e | ||
|
|
b9ac4b936e | ||
|
|
780744f231 | ||
|
|
6b3ee66783 | ||
|
|
115461744b | ||
|
|
a96135b74d | ||
|
|
04b0181980 | ||
|
|
0e5d97a268 | ||
|
|
b2b4c71997 | ||
|
|
e748d53a1f | ||
|
|
93c04dce8d | ||
|
|
0493e799f4 | ||
|
|
c5166f580e | ||
|
|
9dc9d90d34 | ||
|
|
0f15130476 | ||
|
|
75528bdfcb | ||
|
|
7c02ff637a | ||
|
|
496e0f5f27 | ||
|
|
8c909e7d11 | ||
|
|
d29a53dc1f | ||
|
|
a5eaf29c33 | ||
|
|
bbdee361f1 | ||
|
|
0780e636f9 | ||
|
|
83e3b25c46 | ||
|
|
36c4ed7632 | ||
|
|
ab7ac0aadb | ||
|
|
02396e3b58 | ||
|
|
b1b1b700ea | ||
|
|
42cf18734f | ||
|
|
41bd4076c0 | ||
|
|
391ca3e3b5 | ||
|
|
0cd573f043 | ||
|
|
e81001615c | ||
|
|
1d2f308cdf | ||
|
|
fd35a09240 | ||
|
|
9299a2801e | ||
|
|
004e4a5cda | ||
|
|
a7a2d6e44b | ||
|
|
6f7eb8bd97 | ||
|
|
0f330b85b1 | ||
|
|
ed009c0ec8 | ||
|
|
091dd855af | ||
|
|
2e6d7561a3 | ||
|
|
8aacd13241 | ||
|
|
ac066a73e4 | ||
|
|
b133403331 | ||
|
|
dc9876b6c2 | ||
|
|
583c71ec3d | ||
|
|
07abbb4c0d | ||
|
|
7b489159b3 | ||
|
|
e166a93a56 | ||
|
|
083d86a79d | ||
|
|
481c5a2318 | ||
|
|
a1ff28cec8 | ||
|
|
86c194e181 | ||
|
|
52d208daf3 | ||
|
|
308df38b14 | ||
|
|
7bb3fd56c6 | ||
|
|
7dfee13b56 | ||
|
|
8adbea8aec | ||
|
|
a33af34361 | ||
|
|
e748ffdce4 | ||
|
|
d10531e925 | ||
|
|
ded3cfc168 | ||
|
|
eb3bb2ab07 | ||
|
|
0e3844ad1e | ||
|
|
b6bd9e24a8 | ||
|
|
c36633320e | ||
|
|
89d37882b6 | ||
|
|
ba86bc04f6 | ||
|
|
39a59e6168 | ||
|
|
8526d918ed | ||
|
|
897e4135d3 | ||
|
|
df638c3fe6 | ||
|
|
10a4db5067 | ||
|
|
d3fc5c506a | ||
|
|
795e0acda7 | ||
|
|
caab609f5d | ||
|
|
90a7218622 | ||
|
|
ce4ce0676a | ||
|
|
6988797759 | ||
|
|
1ba594cc4d | ||
|
|
54f66dc67a | ||
|
|
9855571616 | ||
|
|
16b21a3af8 | ||
|
|
eefea9daec | ||
|
|
b01d6dd9cc | ||
|
|
4e3e518936 | ||
|
|
607f481d44 | ||
|
|
0b735897cb | ||
|
|
785141c7a0 | ||
|
|
d61f25ed3e | ||
|
|
6889b3a25a | ||
|
|
d743160597 | ||
|
|
323837bf70 | ||
|
|
dfc84558a5 | ||
|
|
a637b399b8 | ||
|
|
2006968c05 | ||
|
|
54347a9787 | ||
|
|
f9e58cea9b | ||
|
|
7c0a4cb0b3 | ||
|
|
fca248a965 | ||
|
|
98fe68432a | ||
|
|
84ae835582 | ||
|
|
ef2bdb5304 | ||
|
|
790785f1ab | ||
|
|
fa8b0d7bad | ||
|
|
6bb7c37605 | ||
|
|
d1cf6b57d7 | ||
|
|
b9e301d769 | ||
|
|
987c996173 | ||
|
|
eb00b066de | ||
|
|
e9ab13781d | ||
|
|
9f069a42ac | ||
|
|
d9d7a3354d | ||
|
|
1967ca2a57 | ||
|
|
ae5623916b | ||
|
|
7f2307626d | ||
|
|
242caf9e69 | ||
|
|
49b2b5cd97 | ||
|
|
2bb53bd303 | ||
|
|
3785649eb6 | ||
|
|
97a5dec57a | ||
|
|
3afdd9d9e3 | ||
|
|
fb7a11212f | ||
|
|
5bcb77c240 | ||
|
|
70b95b1708 | ||
|
|
e3e8d24930 | ||
|
|
09d30cf1a6 | ||
|
|
a9cfdc843e | ||
|
|
fa3962e54f | ||
|
|
65a88a0291 | ||
|
|
b1d5967d9c | ||
|
|
ab81ff8df2 | ||
|
|
c327496495 | ||
|
|
cbc6f09d2a | ||
|
|
5c1a1c8a6d | ||
|
|
85327a871e | ||
|
|
e3cc439ff0 | ||
|
|
35df872705 | ||
|
|
1f937dd6a5 | ||
|
|
f7444094ca | ||
|
|
0d2efaee95 | ||
|
|
a6f4bfa15b | ||
|
|
5e4f005240 | ||
|
|
aa9386129d | ||
|
|
1518c39e1b | ||
|
|
39f822dd8b | ||
|
|
1591fd7968 | ||
|
|
3b1163291b | ||
|
|
dd853b2572 | ||
|
|
dd7f7e8427 | ||
|
|
0c60d57031 | ||
|
|
6fd3cfb38f | ||
|
|
37e85e6e8d | ||
|
|
eba9ac4261 | ||
|
|
950a28f5ea | ||
|
|
fe79dd4cd3 | ||
|
|
f8aa9a1637 | ||
|
|
eac17ac03c | ||
|
|
cfa9cf31d7 | ||
|
|
6613e272eb | ||
|
|
9efeb5d8af | ||
|
|
24565440b2 | ||
|
|
bdf62b025b | ||
|
|
c3bb234871 | ||
|
|
6e17d6ff7b | ||
|
|
2b32f44454 | ||
|
|
0f427dd32d | ||
|
|
21caa570fb | ||
|
|
fcfe17a0a4 | ||
|
|
d120ce9fde | ||
|
|
4a1d5bfc58 | ||
|
|
bea149e317 | ||
|
|
65b44f0ca2 | ||
|
|
ad7c02570b | ||
|
|
83ca0511d1 | ||
|
|
6b8cd894da | ||
|
|
3a8b49f153 | ||
|
|
886dd04b62 | ||
|
|
bf2d7295d3 | ||
|
|
1a0d0d822e | ||
|
|
2bde43c6e9 | ||
|
|
8d0ab90536 | ||
|
|
aba100ff7b | ||
|
|
c8a6785898 | ||
|
|
20cc3527b4 | ||
|
|
ea28f2f32f | ||
|
|
5c252001a5 | ||
|
|
b0c6c9f67e | ||
|
|
5b469894d4 | ||
|
|
d3ff74e48a | ||
|
|
be107963a7 | ||
|
|
e8b68e5f41 | ||
|
|
3cbc5417b7 | ||
|
|
8219788df6 | ||
|
|
944163d70d | ||
|
|
941fd630a6 | ||
|
|
b4709639b3 | ||
|
|
b8141832a3 | ||
|
|
0223bae0af | ||
|
|
6798a6b800 | ||
|
|
4a2dc46002 | ||
|
|
718d45feaf | ||
|
|
0dfe09fb7c | ||
|
|
f8b4553eee | ||
|
|
77227f8691 | ||
|
|
e762468759 | ||
|
|
cf911d950a | ||
|
|
a3e64a9433 | ||
|
|
11d644d645 | ||
|
|
4443ee8b5a | ||
|
|
08b953ba70 | ||
|
|
94f5763c04 | ||
|
|
8cf9ed7145 | ||
|
|
3ce7d99aea | ||
|
|
45690ee044 | ||
|
|
3a9de2d511 | ||
|
|
eba7d8af77 | ||
|
|
d8c04f666f | ||
|
|
ede9f9ec25 | ||
|
|
26e764950f | ||
|
|
b886c0bd14 | ||
|
|
a4cc268628 | ||
|
|
eb3613695c | ||
|
|
23823c4b21 | ||
|
|
16169a0f74 | ||
|
|
afa2dc53c7 | ||
|
|
8c590fc68f | ||
|
|
15d2817384 | ||
|
|
53a396f406 | ||
|
|
ad41178036 | ||
|
|
7dd97d4bc3 | ||
|
|
6a1a518fec | ||
|
|
62d51562b5 | ||
|
|
c33dedf10b | ||
|
|
58c1fe3606 | ||
|
|
330d2cdc0e | ||
|
|
e014065d9e | ||
|
|
e80fc0b304 | ||
|
|
936e57a6de | ||
|
|
07f4c66ee9 | ||
|
|
a285717657 | ||
|
|
cb2b0e2bd3 | ||
|
|
4e6900e872 | ||
|
|
9521593cbc | ||
|
|
af266c0b83 | ||
|
|
9be2624d09 | ||
|
|
c417813df9 | ||
|
|
59aa78a4a6 | ||
|
|
ccbbbeb928 | ||
|
|
1c7ccc473f | ||
|
|
556b3364fb | ||
|
|
d7e939dc27 | ||
|
|
f68383add9 | ||
|
|
d8777c8689 | ||
|
|
3590c1bae0 | ||
|
|
c1ae91364c | ||
|
|
71225a28fa | ||
|
|
f8cd4483ac | ||
|
|
5266553e1b | ||
|
|
1f19ee3c56 | ||
|
|
6290f38069 | ||
|
|
1dce981707 | ||
|
|
b61c841929 | ||
|
|
000a44772d | ||
|
|
37714fa4f8 | ||
|
|
2f8ebe8d45 | ||
|
|
d6042d08f1 | ||
|
|
7a769a6a22 | ||
|
|
0f27ed800c | ||
|
|
4932ef3036 | ||
|
|
226bfe158f | ||
|
|
32d42ffee7 | ||
|
|
3fab237f34 | ||
|
|
1eac894902 | ||
|
|
73f29846b3 | ||
|
|
6e9dc343cd | ||
|
|
35f092ca30 | ||
|
|
bf16afc665 | ||
|
|
ea80027525 | ||
|
|
a6e8fae7f5 | ||
|
|
9b8323d2e2 | ||
|
|
612bf72ceb | ||
|
|
ebd1485b09 | ||
|
|
58a02f107e | ||
|
|
a312472fb5 | ||
|
|
1374ee5b9e | ||
|
|
55610b8425 | ||
|
|
56fb58cc6f | ||
|
|
ea98780960 | ||
|
|
1b868259fe | ||
|
|
3ac478f284 | ||
|
|
2528a35656 | ||
|
|
3ef600a3b5 | ||
|
|
fc36514eb8 | ||
|
|
795e153c2e | ||
|
|
5d503b48cb | ||
|
|
93d90884e2 | ||
|
|
92379d8131 | ||
|
|
31d2ed172b | ||
|
|
3156b97f3a | ||
|
|
a3b1d5b7ab | ||
|
|
09271a333a | ||
|
|
4b22ccdc81 | ||
|
|
f05f7a0ff9 | ||
|
|
817db85aae | ||
|
|
df24d9dff5 | ||
|
|
343791b657 | ||
|
|
fff84de367 | ||
|
|
065dd7f1ea | ||
|
|
dfe7677eb5 | ||
|
|
0cc71fad49 | ||
|
|
6bdd184d6a | ||
|
|
febf85d7e2 | ||
|
|
2eb2ae9c93 | ||
|
|
29fffd6de8 | ||
|
|
8ac755e1d6 | ||
|
|
02121df3b9 | ||
|
|
14779ec4be | ||
|
|
a318b57408 | ||
|
|
57a33aaf8b | ||
|
|
026ba7cdac | ||
|
|
761bbf9dbc | ||
|
|
c41186a3a4 | ||
|
|
90b62e0abc | ||
|
|
a3cd96ead4 | ||
|
|
e3b6be79fc | ||
|
|
1867228cce | ||
|
|
a8ee64b059 | ||
|
|
4e4733f68e | ||
|
|
23a2c7d848 | ||
|
|
2c4102d396 | ||
|
|
fed6df3756 | ||
|
|
965c722344 | ||
|
|
f2487741dc | ||
|
|
b6a445b1a9 | ||
|
|
cf88817355 | ||
|
|
851b0e36cd | ||
|
|
172d79aff4 | ||
|
|
619943ac1e | ||
|
|
6fd32b5a9b | ||
|
|
8414a94d59 | ||
|
|
82133865d4 | ||
|
|
77e022cf28 | ||
|
|
de2f057c10 | ||
|
|
6dfc3f3f70 | ||
|
|
e25c78b00a | ||
|
|
a3fbaa5990 | ||
|
|
6912414750 | ||
|
|
e373a5199b | ||
|
|
d5deff21c5 | ||
|
|
c2544d4c78 | ||
|
|
abdd5883a1 | ||
|
|
98b5828f83 | ||
|
|
0244b4e71e | ||
|
|
99a569b2e6 | ||
|
|
ad9af2884d | ||
|
|
6554a1cf28 | ||
|
|
7bafa37a52 | ||
|
|
9e31d5042f | ||
|
|
2aef648f3d | ||
|
|
68816390ee | ||
|
|
dd443f3eca | ||
|
|
9620be91fa | ||
|
|
85370fa31f | ||
|
|
6069bc53cd | ||
|
|
250a01d235 | ||
|
|
78375632dd | ||
|
|
a6e4f7f3ad | ||
|
|
02f9e29a31 | ||
|
|
9f26efdf86 | ||
|
|
e6b9d2f5e7 | ||
|
|
eeb27f7b50 | ||
|
|
43d8ba0e78 | ||
|
|
a533ff6aff | ||
|
|
743d9801e9 | ||
|
|
e6bc7e6043 | ||
|
|
87926db4c3 | ||
|
|
fdde850fc2 | ||
|
|
3e92192dc4 | ||
|
|
3ecae2f020 | ||
|
|
dcf8dd4682 | ||
|
|
3f88ba8903 | ||
|
|
10cd3e5f81 | ||
|
|
ad57c48465 | ||
|
|
912f5615dc | ||
|
|
8995ba02ba | ||
|
|
d0e5870060 | ||
|
|
65371e513a | ||
|
|
087592df2c | ||
|
|
9d8f0db268 | ||
|
|
541ce48292 | ||
|
|
889dfea4ca | ||
|
|
150365e784 | ||
|
|
23d361d1da | ||
|
|
eeed150858 | ||
|
|
8aa3158952 | ||
|
|
713149df8e | ||
|
|
ee5b0f96ad | ||
|
|
a283c95e2e | ||
|
|
f512a56faf | ||
|
|
2425574958 | ||
|
|
73fda600b3 | ||
|
|
0d00bd2322 | ||
|
|
399e19e2dc | ||
|
|
787fa28799 | ||
|
|
7a4cae050c | ||
|
|
86be8a9424 | ||
|
|
0f1bb344ff | ||
|
|
197d793a25 | ||
|
|
985c46d8b5 | ||
|
|
2d588871f0 | ||
|
|
c5c6a6149d | ||
|
|
d7a2aa7823 | ||
|
|
0e94e1e4bd | ||
|
|
f0951df040 | ||
|
|
c0f60087c3 | ||
|
|
8b67b2182f | ||
|
|
b9e2053c38 | ||
|
|
cdb38d06ba | ||
|
|
15cbb5debf | ||
|
|
d8f66e2411 | ||
|
|
c0a0300f12 | ||
|
|
4c06935b62 | ||
|
|
2be48ec982 | ||
|
|
d320b43476 | ||
|
|
3f6381d0fa | ||
|
|
2c5d4ee3a9 | ||
|
|
276b4dbe3e | ||
|
|
83a28f47d7 | ||
|
|
b0de1f19d3 | ||
|
|
7d253dd0f3 | ||
|
|
dffc0c47cf | ||
|
|
c219822cd8 | ||
|
|
f73a52afaf | ||
|
|
7c0f7b9449 | ||
|
|
6242403d33 | ||
|
|
ebfe5e9c17 | ||
|
|
dfdd67f5a4 | ||
|
|
f186815c2d | ||
|
|
8dfe5ae384 | ||
|
|
3d20c626c8 | ||
|
|
f1ccde2fe3 | ||
|
|
16c9853dc2 | ||
|
|
019fa89c53 | ||
|
|
1bfc1c85ce | ||
|
|
d8658bd8d9 | ||
|
|
a3c6a272f1 | ||
|
|
f837d1256a | ||
|
|
8d017504c0 | ||
|
|
31a0a844e3 | ||
|
|
e9a5519fb0 | ||
|
|
a7bc426b61 | ||
|
|
c1d93d112a | ||
|
|
2a8f4554a7 | ||
|
|
004cc3cb8c | ||
|
|
6186fbf8b0 | ||
|
|
b66398d1bf | ||
|
|
40872c9b43 | ||
|
|
59b8806859 | ||
|
|
271729aaaa | ||
|
|
dc910107cf | ||
|
|
fc7653bf3d | ||
|
|
e60fefad27 | ||
|
|
1a608eaefb | ||
|
|
b0de80d46b | ||
|
|
8534185b0c | ||
|
|
8cf0b75d80 | ||
|
|
374b1256cd | ||
|
|
c091d08fee | ||
|
|
ebbf7a7b74 | ||
|
|
d3a0da451a | ||
|
|
c51c9980cf | ||
|
|
6f2b3f1c54 | ||
|
|
0b1e9e56e1 | ||
|
|
9ef0bb3356 | ||
|
|
b9bf183df2 | ||
|
|
7422539f20 | ||
|
|
112aad39b6 | ||
|
|
124b8cd757 | ||
|
|
6ebbdb10c7 | ||
|
|
7d05f0d924 | ||
|
|
ba55d1a0b6 | ||
|
|
2e29168d92 |
@ -1,6 +1,9 @@
|
||||
.git
|
||||
.github
|
||||
test
|
||||
.dockerignore
|
||||
circle.yml
|
||||
.gitignore
|
||||
*.yml
|
||||
Dockerfile*
|
||||
Makefile
|
||||
README.md
|
||||
test
|
||||
|
||||
35
.github/ISSUE_TEMPLATE.md
vendored
Normal file
35
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
# ⚠️ PLEASE READ ⚠️
|
||||
|
||||
## Questions or Features
|
||||
|
||||
If you have a question or want to request a feature, please **DO NOT SUBMIT** a new issue.
|
||||
|
||||
Instead please use the relevant Discussions section's category:
|
||||
- 🙏 [Ask a question](https://github.com/nginx-proxy/nginx-proxy/discussions/categories/q-a)
|
||||
- 💡 [Request a feature](https://github.com/nginx-proxy/nginx-proxy/discussions/categories/ideas)
|
||||
|
||||
## Bugs
|
||||
|
||||
If you are logging a bug, please search the current open issues first to see if there is already a bug opened.
|
||||
|
||||
For bugs, the easier you make it to reproduce the issue you see and the more initial information you provide, the easier and faster the bug can be identified and can get fixed.
|
||||
|
||||
Please at least provide:
|
||||
- the exact nginx-proxy version you're using (if using `latest` please make sure it is up to date and provide the version number printed at container startup).
|
||||
- complete configuration (compose file, command line, etc) of both your nginx-proxy container(s) and proxied containers. You should redact sensitive info if needed but please provide **full** configurations.
|
||||
- generated nginx configuration obtained with `docker exec nameofyournginxproxycontainer nginx -T`
|
||||
|
||||
If you can provide a script or docker-compose file that reproduces the problems, that is very helpful.
|
||||
|
||||
## General advice about `latest`
|
||||
|
||||
Do not use the `latest` tag for production setups.
|
||||
|
||||
`latest` is nothing more than a convenient default used by Docker if no specific tag is provided, there isn't any strict convention on what goes into this tag over different projects, and it does not carry any promise of stability.
|
||||
|
||||
Using `latest` will most certainly put you at risk of experiencing uncontrolled updates to non backward compatible versions (or versions with breaking changes) and makes it harder for maintainers to track which exact version of the container you are experiencing an issue with.
|
||||
|
||||
This recommendation stands for pretty much every Docker image in existence, not just nginx-proxy's ones.
|
||||
|
||||
Thanks,
|
||||
Nicolas
|
||||
22
.github/dependabot.yml
vendored
Normal file
22
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
version: 2
|
||||
updates:
|
||||
# Maintain dependencies for Docker
|
||||
- package-ecosystem: "docker"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
commit-message:
|
||||
prefix: "build"
|
||||
labels:
|
||||
- "type/build"
|
||||
- "scope/dockerfile"
|
||||
|
||||
# Maintain Python dependencies (test suite)
|
||||
- package-ecosystem: "pip"
|
||||
directory: "/test/requirements"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
commit-message:
|
||||
prefix: "ci"
|
||||
labels:
|
||||
- "type/ci"
|
||||
143
.github/workflows/dockerhub.yml
vendored
Normal file
143
.github/workflows/dockerhub.yml
vendored
Normal file
@ -0,0 +1,143 @@
|
||||
name: DockerHub
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "0 0 * * 1"
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- "*.*.*"
|
||||
paths-ignore:
|
||||
- "test/*"
|
||||
- ".gitignore"
|
||||
- "docker-compose-separate-containers.yml"
|
||||
- "docker-compose.yml"
|
||||
- "LICENSE"
|
||||
- "Makefile"
|
||||
- "*.md"
|
||||
|
||||
jobs:
|
||||
multiarch-build-debian:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Retrieve version
|
||||
run: echo "GIT_DESCRIBE=$(git describe --tags)" >> $GITHUB_ENV
|
||||
|
||||
- name: Get Docker tags for Debian based image
|
||||
id: docker_meta_debian
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: |
|
||||
ghcr.io/nginx-proxy/nginx-proxy
|
||||
nginxproxy/nginx-proxy
|
||||
jwilder/nginx-proxy
|
||||
tags: |
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
labels: |
|
||||
org.opencontainers.image.authors=Nicolas Duchon <nicolas.duchon@gmail.com> (@buchdag), Jason Wilder
|
||||
org.opencontainers.image.version=${{ env.GIT_DESCRIBE }}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Log in to GitHub Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and push the Debian based image
|
||||
id: docker_build_debian
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile
|
||||
build-args: NGINX_PROXY_VERSION=${{ env.GIT_DESCRIBE }}
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
push: true
|
||||
tags: ${{ steps.docker_meta_debian.outputs.tags }}
|
||||
labels: ${{ steps.docker_meta_debian.outputs.labels }}
|
||||
|
||||
- name: Images digests
|
||||
run: echo ${{ steps.docker_build_debian.outputs.digest }}
|
||||
|
||||
multiarch-build-alpine:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Retrieve version
|
||||
run: echo "GIT_DESCRIBE=$(git describe --tags)" >> $GITHUB_ENV
|
||||
|
||||
- name: Get Docker tags for Alpine based image
|
||||
id: docker_meta_alpine
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: |
|
||||
ghcr.io/nginx-proxy/nginx-proxy
|
||||
nginxproxy/nginx-proxy
|
||||
jwilder/nginx-proxy
|
||||
tags: |
|
||||
type=semver,suffix=-alpine,pattern={{version}}
|
||||
type=semver,suffix=-alpine,pattern={{major}}.{{minor}}
|
||||
type=raw,value=alpine,enable={{is_default_branch}}
|
||||
labels: |
|
||||
org.opencontainers.image.authors=Nicolas Duchon <nicolas.duchon@gmail.com> (@buchdag), Jason Wilder
|
||||
org.opencontainers.image.version=${{ env.GIT_DESCRIBE }}
|
||||
flavor: latest=false
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Log in to GitHub Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and push the Alpine based image
|
||||
id: docker_build_alpine
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile.alpine
|
||||
build-args: NGINX_PROXY_VERSION=${{ env.GIT_DESCRIBE }}
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
push: true
|
||||
tags: ${{ steps.docker_meta_alpine.outputs.tags }}
|
||||
labels: ${{ steps.docker_meta_alpine.outputs.labels }}
|
||||
|
||||
- name: Images digests
|
||||
run: echo ${{ steps.docker_build_alpine.outputs.digest }}
|
||||
45
.github/workflows/test.yml
vendored
Normal file
45
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
paths-ignore:
|
||||
- "LICENSE"
|
||||
- "**.md"
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- "LICENSE"
|
||||
- "**.md"
|
||||
|
||||
jobs:
|
||||
unit:
|
||||
name: Unit Tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
base_docker_image: [alpine, debian]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Python 3.9
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.9
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r python-requirements.txt
|
||||
working-directory: test/requirements
|
||||
|
||||
- name: Build Docker web server image
|
||||
run: make build-webserver
|
||||
|
||||
- name: Build Docker nginx proxy test image
|
||||
run: make build-nginx-proxy-test-${{ matrix.base_docker_image }}
|
||||
|
||||
- name: Run tests
|
||||
run: pytest
|
||||
working-directory: test
|
||||
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
**/__pycache__/
|
||||
**/.cache/
|
||||
.idea/
|
||||
22
.travis.yml
22
.travis.yml
@ -1,22 +0,0 @@
|
||||
sudo: required
|
||||
services:
|
||||
- docker
|
||||
|
||||
env:
|
||||
global:
|
||||
- DOCKER_VERSION=1.12.1-0~trusty
|
||||
|
||||
before_install:
|
||||
# list docker-engine versions
|
||||
- apt-cache madison docker-engine
|
||||
# upgrade docker-engine to specific version
|
||||
- sudo apt-get -o Dpkg::Options::="--force-confnew" install -y docker-engine=${DOCKER_VERSION}
|
||||
- docker version
|
||||
- docker info
|
||||
- sudo add-apt-repository ppa:duggan/bats --yes
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq bats
|
||||
- make update-dependencies
|
||||
|
||||
script:
|
||||
- make test
|
||||
84
Dockerfile
84
Dockerfile
@ -1,34 +1,74 @@
|
||||
FROM nginx:1.11.3
|
||||
MAINTAINER Jason Wilder mail@jasonwilder.com
|
||||
# setup build arguments for version of dependencies to use
|
||||
ARG DOCKER_GEN_VERSION=0.10.2
|
||||
ARG FOREGO_VERSION=v0.17.0
|
||||
|
||||
# Use a specific version of golang to build both binaries
|
||||
FROM golang:1.20.2 as gobuilder
|
||||
|
||||
# Build docker-gen from scratch
|
||||
FROM gobuilder as dockergen
|
||||
|
||||
ARG DOCKER_GEN_VERSION
|
||||
|
||||
RUN git clone https://github.com/nginx-proxy/docker-gen \
|
||||
&& cd /go/docker-gen \
|
||||
&& git -c advice.detachedHead=false checkout $DOCKER_GEN_VERSION \
|
||||
&& go mod download \
|
||||
&& CGO_ENABLED=0 GOOS=linux go build -ldflags "-X main.buildVersion=${DOCKER_GEN_VERSION}" ./cmd/docker-gen \
|
||||
&& go clean -cache \
|
||||
&& mv docker-gen /usr/local/bin/ \
|
||||
&& cd - \
|
||||
&& rm -rf /go/docker-gen
|
||||
|
||||
# Build forego from scratch
|
||||
FROM gobuilder as forego
|
||||
|
||||
ARG FOREGO_VERSION
|
||||
|
||||
RUN git clone https://github.com/nginx-proxy/forego/ \
|
||||
&& cd /go/forego \
|
||||
&& git -c advice.detachedHead=false checkout $FOREGO_VERSION \
|
||||
&& go mod download \
|
||||
&& CGO_ENABLED=0 GOOS=linux go build -o forego . \
|
||||
&& go clean -cache \
|
||||
&& mv forego /usr/local/bin/ \
|
||||
&& cd - \
|
||||
&& rm -rf /go/forego
|
||||
|
||||
# Build the final image
|
||||
FROM nginx:1.23.3
|
||||
|
||||
ARG NGINX_PROXY_VERSION
|
||||
# Add DOCKER_GEN_VERSION environment variable
|
||||
# Because some external projects rely on it
|
||||
ARG DOCKER_GEN_VERSION
|
||||
ENV NGINX_PROXY_VERSION=${NGINX_PROXY_VERSION} \
|
||||
DOCKER_GEN_VERSION=${DOCKER_GEN_VERSION} \
|
||||
DOCKER_HOST=unix:///tmp/docker.sock
|
||||
|
||||
# Install wget and install/updates certificates
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y -q --no-install-recommends \
|
||||
ca-certificates \
|
||||
wget \
|
||||
&& apt-get clean \
|
||||
&& rm -r /var/lib/apt/lists/*
|
||||
&& apt-get install -y -q --no-install-recommends \
|
||||
ca-certificates \
|
||||
wget \
|
||||
&& apt-get clean \
|
||||
&& rm -r /var/lib/apt/lists/*
|
||||
|
||||
# Configure Nginx and apply fix for very long server names
|
||||
|
||||
# Configure Nginx
|
||||
RUN echo "daemon off;" >> /etc/nginx/nginx.conf \
|
||||
&& sed -i 's/^http {/&\n server_names_hash_bucket_size 128;/g' /etc/nginx/nginx.conf
|
||||
&& sed -i 's/worker_processes 1/worker_processes auto/' /etc/nginx/nginx.conf \
|
||||
&& sed -i 's/worker_connections 1024/worker_connections 10240/' /etc/nginx/nginx.conf \
|
||||
&& mkdir -p '/etc/nginx/dhparam'
|
||||
|
||||
# Install Forego
|
||||
ADD https://github.com/jwilder/forego/releases/download/v0.16.1/forego /usr/local/bin/forego
|
||||
RUN chmod u+x /usr/local/bin/forego
|
||||
# Install Forego + docker-gen
|
||||
COPY --from=forego /usr/local/bin/forego /usr/local/bin/forego
|
||||
COPY --from=dockergen /usr/local/bin/docker-gen /usr/local/bin/docker-gen
|
||||
|
||||
ENV DOCKER_GEN_VERSION 0.7.3
|
||||
COPY network_internal.conf /etc/nginx/
|
||||
|
||||
RUN wget https://github.com/jwilder/docker-gen/releases/download/$DOCKER_GEN_VERSION/docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz \
|
||||
&& tar -C /usr/local/bin -xvzf docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz \
|
||||
&& rm /docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz
|
||||
|
||||
COPY . /app/
|
||||
COPY app nginx.tmpl LICENSE /app/
|
||||
WORKDIR /app/
|
||||
|
||||
ENV DOCKER_HOST unix:///tmp/docker.sock
|
||||
|
||||
VOLUME ["/etc/nginx/certs"]
|
||||
|
||||
ENTRYPOINT ["/app/docker-entrypoint.sh"]
|
||||
CMD ["forego", "start", "-r"]
|
||||
|
||||
71
Dockerfile.alpine
Normal file
71
Dockerfile.alpine
Normal file
@ -0,0 +1,71 @@
|
||||
# setup build arguments for version of dependencies to use
|
||||
ARG DOCKER_GEN_VERSION=0.10.2
|
||||
ARG FOREGO_VERSION=v0.17.0
|
||||
|
||||
# Use a specific version of golang to build both binaries
|
||||
FROM golang:1.20.2-alpine as gobuilder
|
||||
RUN apk add --no-cache git musl-dev
|
||||
|
||||
# Build docker-gen from scratch
|
||||
FROM gobuilder as dockergen
|
||||
|
||||
ARG DOCKER_GEN_VERSION
|
||||
|
||||
RUN git clone https://github.com/nginx-proxy/docker-gen \
|
||||
&& cd /go/docker-gen \
|
||||
&& git -c advice.detachedHead=false checkout $DOCKER_GEN_VERSION \
|
||||
&& go mod download \
|
||||
&& CGO_ENABLED=0 go build -ldflags "-X main.buildVersion=${DOCKER_GEN_VERSION}" ./cmd/docker-gen \
|
||||
&& go clean -cache \
|
||||
&& mv docker-gen /usr/local/bin/ \
|
||||
&& cd - \
|
||||
&& rm -rf /go/docker-gen
|
||||
|
||||
# Build forego from scratch
|
||||
FROM gobuilder as forego
|
||||
|
||||
ARG FOREGO_VERSION
|
||||
|
||||
RUN git clone https://github.com/nginx-proxy/forego/ \
|
||||
&& cd /go/forego \
|
||||
&& git -c advice.detachedHead=false checkout $FOREGO_VERSION \
|
||||
&& go mod download \
|
||||
&& CGO_ENABLED=0 go build -o forego . \
|
||||
&& go clean -cache \
|
||||
&& mv forego /usr/local/bin/ \
|
||||
&& cd - \
|
||||
&& rm -rf /go/forego
|
||||
|
||||
# Build the final image
|
||||
FROM nginx:1.23.3-alpine
|
||||
|
||||
ARG NGINX_PROXY_VERSION
|
||||
# Add DOCKER_GEN_VERSION environment variable
|
||||
# Because some external projects rely on it
|
||||
ARG DOCKER_GEN_VERSION
|
||||
ENV NGINX_PROXY_VERSION=${NGINX_PROXY_VERSION} \
|
||||
DOCKER_GEN_VERSION=${DOCKER_GEN_VERSION} \
|
||||
DOCKER_HOST=unix:///tmp/docker.sock
|
||||
|
||||
# Install wget and install/updates certificates
|
||||
RUN apk add --no-cache --virtual .run-deps \
|
||||
ca-certificates bash wget openssl \
|
||||
&& update-ca-certificates
|
||||
|
||||
# Configure Nginx
|
||||
RUN echo "daemon off;" >> /etc/nginx/nginx.conf \
|
||||
&& sed -i 's/worker_processes 1/worker_processes auto/' /etc/nginx/nginx.conf \
|
||||
&& sed -i 's/worker_connections 1024/worker_connections 10240/' /etc/nginx/nginx.conf \
|
||||
&& mkdir -p '/etc/nginx/dhparam'
|
||||
|
||||
# Install Forego + docker-gen
|
||||
COPY --from=forego /usr/local/bin/forego /usr/local/bin/forego
|
||||
COPY --from=dockergen /usr/local/bin/docker-gen /usr/local/bin/docker-gen
|
||||
|
||||
COPY network_internal.conf /etc/nginx/
|
||||
|
||||
COPY app nginx.tmpl LICENSE /app/
|
||||
WORKDIR /app/
|
||||
|
||||
ENTRYPOINT ["/app/docker-entrypoint.sh"]
|
||||
CMD ["forego", "start", "-r"]
|
||||
3
LICENSE
3
LICENSE
@ -1,6 +1,7 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Jason Wilder
|
||||
Copyright (c) 2014-2020 Jason Wilder
|
||||
Copyright (c) 2021-2022 Nicolas Duchon
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
28
Makefile
28
Makefile
@ -1,14 +1,20 @@
|
||||
.SILENT :
|
||||
.PHONY : test
|
||||
.PHONY : test-debian test-alpine test
|
||||
|
||||
update-dependencies:
|
||||
docker pull jwilder/docker-gen:0.7.3
|
||||
docker pull nginx:1.11.3
|
||||
docker pull python:3
|
||||
docker pull rancher/socat-docker:latest
|
||||
docker pull appropriate/curl:latest
|
||||
docker pull docker:1.10
|
||||
|
||||
test:
|
||||
docker build -t jwilder/nginx-proxy:bats .
|
||||
bats test
|
||||
build-webserver:
|
||||
docker build --pull -t web test/requirements/web
|
||||
|
||||
build-nginx-proxy-test-debian:
|
||||
docker build --pull --build-arg NGINX_PROXY_VERSION="test" -t nginxproxy/nginx-proxy:test .
|
||||
|
||||
build-nginx-proxy-test-alpine:
|
||||
docker build --pull --build-arg NGINX_PROXY_VERSION="test" -f Dockerfile.alpine -t nginxproxy/nginx-proxy:test .
|
||||
|
||||
test-debian: build-webserver build-nginx-proxy-test-debian
|
||||
test/pytest.sh
|
||||
|
||||
test-alpine: build-webserver build-nginx-proxy-test-alpine
|
||||
test/pytest.sh
|
||||
|
||||
test: test-debian test-alpine
|
||||
|
||||
540
README.md
540
README.md
@ -1,32 +1,63 @@
|
||||
  [](https://travis-ci.org/jwilder/nginx-proxy) [](https://hub.docker.com/r/jwilder/nginx-proxy 'DockerHub') [](https://hub.docker.com/r/jwilder/nginx-proxy 'DockerHub')
|
||||
[](https://github.com/nginx-proxy/nginx-proxy/actions/workflows/test.yml)
|
||||
[](https://github.com/nginx-proxy/nginx-proxy/releases)
|
||||

|
||||
[](https://hub.docker.com/r/nginxproxy/nginx-proxy "Click to view the image on Docker Hub")
|
||||
[](https://hub.docker.com/r/nginxproxy/nginx-proxy 'DockerHub')
|
||||
[](https://hub.docker.com/r/nginxproxy/nginx-proxy 'DockerHub')
|
||||
|
||||
|
||||
nginx-proxy sets up a container running nginx and [docker-gen][1]. docker-gen generates reverse proxy configs for nginx and reloads nginx when containers are started and stopped.
|
||||
nginx-proxy sets up a container running nginx and [docker-gen](https://github.com/nginx-proxy/docker-gen). docker-gen generates reverse proxy configs for nginx and reloads nginx when containers are started and stopped.
|
||||
|
||||
See [Automated Nginx Reverse Proxy for Docker][2] for why you might want to use this.
|
||||
See [Automated Nginx Reverse Proxy for Docker](http://jasonwilder.com/blog/2014/03/25/automated-nginx-reverse-proxy-for-docker/) for why you might want to use this.
|
||||
|
||||
### Usage
|
||||
|
||||
To run it:
|
||||
|
||||
$ docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy
|
||||
```console
|
||||
docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro nginxproxy/nginx-proxy
|
||||
```
|
||||
|
||||
Then start any containers you want proxied with an env var `VIRTUAL_HOST=subdomain.youdomain.com`
|
||||
|
||||
$ docker run -e VIRTUAL_HOST=foo.bar.com ...
|
||||
```console
|
||||
docker run -e VIRTUAL_HOST=foo.bar.com ...
|
||||
```
|
||||
|
||||
The containers being proxied must [expose](https://docs.docker.com/reference/run/#expose-incoming-ports) the port to be proxied, either by using the `EXPOSE` directive in their `Dockerfile` or by using the `--expose` flag to `docker run` or `docker create`.
|
||||
The containers being proxied must [expose](https://docs.docker.com/engine/reference/run/#expose-incoming-ports) the port to be proxied, either by using the `EXPOSE` directive in their `Dockerfile` or by using the `--expose` flag to `docker run` or `docker create` and be in the same network. By default, if you don't pass the --net flag when your nginx-proxy container is created, it will only be attached to the default bridge network. This means that it will not be able to connect to containers on networks other than bridge.
|
||||
|
||||
Provided your DNS is setup to forward foo.bar.com to the a host running nginx-proxy, the request will be routed to a container with the VIRTUAL_HOST env var set.
|
||||
Provided your DNS is setup to forward foo.bar.com to the host running nginx-proxy, the request will be routed to a container with the `VIRTUAL_HOST` env var set.
|
||||
|
||||
Note: providing a port number in `VIRTUAL_HOST` isn't suported, please see [virtual ports](https://github.com/nginx-proxy/nginx-proxy#virtual-ports) or [custom external HTTP/HTTPS ports](https://github.com/nginx-proxy/nginx-proxy#custom-external-httphttps-ports) depending on what you want to achieve.
|
||||
|
||||
### Image variants
|
||||
|
||||
The nginx-proxy images are available in two flavors.
|
||||
|
||||
#### nginxproxy/nginx-proxy:latest
|
||||
|
||||
This image uses the debian:buster based nginx image.
|
||||
|
||||
```console
|
||||
docker pull nginxproxy/nginx-proxy:latest
|
||||
```
|
||||
|
||||
#### nginxproxy/nginx-proxy:alpine
|
||||
|
||||
This image is based on the nginx:alpine image. Use this image to fully support HTTP/2 (including ALPN required by recent Chrome versions). A valid certificate is required as well (see eg. below "SSL Support using an ACME CA" for more info).
|
||||
|
||||
```console
|
||||
docker pull nginxproxy/nginx-proxy:alpine
|
||||
```
|
||||
|
||||
### Docker Compose
|
||||
|
||||
```yaml
|
||||
version: '2'
|
||||
|
||||
services:
|
||||
nginx-proxy:
|
||||
image: jwilder/nginx-proxy
|
||||
container_name: nginx-proxy
|
||||
image: nginxproxy/nginx-proxy
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
@ -34,31 +65,108 @@ services:
|
||||
|
||||
whoami:
|
||||
image: jwilder/whoami
|
||||
container_name: whoami
|
||||
expose:
|
||||
- "8000"
|
||||
environment:
|
||||
- VIRTUAL_HOST=whoami.local
|
||||
- VIRTUAL_PORT=8000
|
||||
```
|
||||
|
||||
```shell
|
||||
$ docker-compose up
|
||||
$ curl -H "Host: whoami.local" localhost
|
||||
```console
|
||||
docker-compose up
|
||||
curl -H "Host: whoami.local" localhost
|
||||
```
|
||||
|
||||
Example output:
|
||||
```console
|
||||
I'm 5b129ab83266
|
||||
```
|
||||
|
||||
### Multiple Ports
|
||||
### IPv6 support
|
||||
|
||||
If your container exposes multiple ports, nginx-proxy will default to the service running on port 80. If you need to specify a different port, you can set a VIRTUAL_PORT env var to select a different one. If your container only exposes one port and it has a VIRTUAL_HOST env var set, that port will be selected.
|
||||
You can activate the IPv6 support for the nginx-proxy container by passing the value `true` to the `ENABLE_IPV6` environment variable:
|
||||
|
||||
[1]: https://github.com/jwilder/docker-gen
|
||||
[2]: http://jasonwilder.com/blog/2014/03/25/automated-nginx-reverse-proxy-for-docker/
|
||||
```console
|
||||
docker run -d -p 80:80 -e ENABLE_IPV6=true -v /var/run/docker.sock:/tmp/docker.sock:ro nginxproxy/nginx-proxy
|
||||
```
|
||||
|
||||
#### Scoped IPv6 Resolvers
|
||||
|
||||
NginX does not support scoped IPv6 resolvers. In [docker-entrypoint.sh](./docker-entrypoint.sh) the resolvers are parsed from resolv.conf, but any scoped IPv6 addreses will be removed.
|
||||
|
||||
#### IPv6 NAT
|
||||
|
||||
By default, docker uses IPv6-to-IPv4 NAT. This means all client connections from IPv6 addresses will show docker's internal IPv4 host address. To see true IPv6 client IP addresses, you must [enable IPv6](https://docs.docker.com/config/daemon/ipv6/) and use [ipv6nat](https://github.com/robbertkl/docker-ipv6nat). You must also disable the userland proxy by adding `"userland-proxy": false` to `/etc/docker/daemon.json` and restarting the daemon.
|
||||
|
||||
### Multiple Hosts
|
||||
|
||||
If you need to support multiple virtual hosts for a container, you can separate each entry with commas. For example, `foo.bar.com,baz.bar.com,bar.com` and each host will be setup the same.
|
||||
|
||||
### Virtual Ports
|
||||
|
||||
When your container exposes only one port, nginx-proxy will default to this port, else to port 80.
|
||||
|
||||
If you need to specify a different port, you can set a `VIRTUAL_PORT` env var to select a different one. This variable cannot be set to more than one port.
|
||||
|
||||
For each host defined into `VIRTUAL_HOST`, the associated virtual port is retrieved by order of precedence:
|
||||
1. From the `VIRTUAL_PORT` environment variable
|
||||
1. From the container's exposed port if there is only one
|
||||
1. From the default port 80 when none of the above methods apply
|
||||
|
||||
### Wildcard Hosts
|
||||
|
||||
You can also use wildcards at the beginning and the end of host name, like `*.bar.com` or `foo.bar.*`. Or even a regular expression, which can be very useful in conjunction with a wildcard DNS service like [xip.io](http://xip.io), using `~^foo\.bar\..*\.xip\.io` will match `foo.bar.127.0.0.1.xip.io`, `foo.bar.10.0.2.2.xip.io` and all other given IPs. More information about this topic can be found in the nginx documentation about [`server_names`](http://nginx.org/en/docs/http/server_names.html).
|
||||
You can also use wildcards at the beginning and the end of host name, like `*.bar.com` or `foo.bar.*`. Or even a regular expression, which can be very useful in conjunction with a wildcard DNS service like [nip.io](https://nip.io) or [sslip.io](https://sslip.io), using `~^foo\.bar\..*\.nip\.io` will match `foo.bar.127.0.0.1.nip.io`, `foo.bar.10.0.2.2.nip.io` and all other given IPs. More information about this topic can be found in the nginx documentation about [`server_names`](http://nginx.org/en/docs/http/server_names.html).
|
||||
|
||||
### Path-based Routing
|
||||
|
||||
You can have multiple containers proxied by the same `VIRTUAL_HOST` by adding a `VIRTUAL_PATH` environment variable containing the absolute path to where the container should be mounted. For example with `VIRTUAL_HOST=foo.example.com` and `VIRTUAL_PATH=/api/v2/service`, then requests to http://foo.example.com/api/v2/service will be routed to the container. If you wish to have a container serve the root while other containers serve other paths, give the root container a `VIRTUAL_PATH` of `/`. Unmatched paths will be served by the container at `/` or will return the default nginx error page if no container has been assigned `/`.
|
||||
It is also possible to specify multiple paths with regex locations like `VIRTUAL_PATH=~^/(app1|alternative1)/`. For further details see the nginx documentation on location blocks. This is not compatible with `VIRTUAL_DEST`.
|
||||
|
||||
The full request URI will be forwarded to the serving container in the `X-Original-URI` header.
|
||||
|
||||
**NOTE**: Your application needs to be able to generate links starting with `VIRTUAL_PATH`. This can be achieved by it being natively on this path or having an option to prepend this path. The application does not need to expect this path in the request.
|
||||
|
||||
#### VIRTUAL_DEST
|
||||
|
||||
This environment variable can be used to rewrite the `VIRTUAL_PATH` part of the requested URL to proxied application. The default value is empty (off).
|
||||
Make sure that your settings won't result in the slash missing or being doubled. Both these versions can cause troubles.
|
||||
|
||||
If the application runs natively on this sub-path or has a setting to do so, `VIRTUAL_DEST` should not be set or empty.
|
||||
If the requests are expected to not contain a sub-path and the generated links contain the sub-path, `VIRTUAL_DEST=/` should be used.
|
||||
|
||||
```console
|
||||
$ docker run -d -e VIRTUAL_HOST=example.tld -e VIRTUAL_PATH=/app1/ -e VIRTUAL_DEST=/ --name app1 app
|
||||
```
|
||||
|
||||
In this example, the incoming request `http://example.tld/app1/foo` will be proxied as `http://app1/foo` instead of `http://app1/app1/foo`.
|
||||
|
||||
#### Per-VIRTUAL_PATH location configuration
|
||||
|
||||
The same options as from [Per-VIRTUAL_HOST location configuration](#Per-VIRTUAL_HOST-location-configuration) are available on a `VIRTUAL_PATH` basis.
|
||||
The only difference is that the filename gets an additional block `HASH=$(echo -n $VIRTUAL_PATH | sha1sum | awk '{ print $1 }')`. This is the sha1-hash of the `VIRTUAL_PATH` (no newline). This is done filename sanitization purposes.
|
||||
The used filename is `${VIRTUAL_HOST}_${HASH}_location`
|
||||
|
||||
The filename of the previous example would be `example.tld_8610f6c344b4096614eab6e09d58885349f42faf_location`.
|
||||
|
||||
#### DEFAULT_ROOT
|
||||
|
||||
This environment variable of the nginx proxy container can be used to customize the return error page if no matching path is found. Furthermore it is possible to use anything which is compatible with the `return` statement of nginx.
|
||||
|
||||
Exception: If this is set to the string `none`, no default `location /` directive will be generated. This makes it possible for you to provide your own `location /` directive in your [`/etc/nginx/vhost.d/VIRTUAL_HOST`](#per-virtual_host) or [`/etc/nginx/vhost.d/default`](#per-virtual_host-default-configuration) files.
|
||||
|
||||
If unspecified, `DEFAULT_ROOT` defaults to `404`.
|
||||
|
||||
Examples (YAML syntax):
|
||||
|
||||
* `DEFAULT_ROOT: "none"` prevents `nginx-proxy` from generating a default `location /` directive.
|
||||
* `DEFAULT_ROOT: "418"` returns a 418 error page instead of the normal 404 one.
|
||||
* `DEFAULT_ROOT: "301 https://github.com/nginx-proxy/nginx-proxy/blob/main/README.md"` redirects the client to this documentation.
|
||||
|
||||
Nginx variables such as `$scheme`, `$host`, and `$request_uri` can be used. However, care must be taken to make sure the `$` signs are escaped properly. For example, if you want to use `301 $scheme://$host/myapp1$request_uri` you should use:
|
||||
|
||||
* Bash: `DEFAULT_ROOT='301 $scheme://$host/myapp1$request_uri'`
|
||||
* Docker Compose yaml: `- DEFAULT_ROOT: 301 $$scheme://$$host/myapp1$$request_uri`
|
||||
|
||||
|
||||
### Multiple Networks
|
||||
|
||||
@ -67,151 +175,301 @@ With the addition of [overlay networking](https://docs.docker.com/engine/usergui
|
||||
If you want your `nginx-proxy` container to be attached to a different network, you must pass the `--net=my-network` option in your `docker create` or `docker run` command. At the time of this writing, only a single network can be specified at container creation time. To attach to other networks, you can use the `docker network connect` command after your container is created:
|
||||
|
||||
```console
|
||||
$ docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro \
|
||||
--name my-nginx-proxy --net my-network jwilder/nginx-proxy
|
||||
$ docker network connect my-other-network my-nginx-proxy
|
||||
docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro \
|
||||
--name my-nginx-proxy --net my-network nginxproxy/nginx-proxy
|
||||
docker network connect my-other-network my-nginx-proxy
|
||||
```
|
||||
|
||||
In this example, the `my-nginx-proxy` container will be connected to `my-network` and `my-other-network` and will be able to proxy to other containers attached to those networks.
|
||||
|
||||
### Custom external HTTP/HTTPS ports
|
||||
|
||||
If you want to use `nginx-proxy` with different external ports that the default ones of `80` for `HTTP` traffic and `443` for `HTTPS` traffic, you'll have to use the environment variable(s) `HTTP_PORT` and/or `HTTPS_PORT` in addition to the changes to the Docker port mapping. If you change the `HTTPS` port, the redirect for `HTTPS` traffic will also be configured to redirect to the custom port. Typical usage, here with the custom ports `1080` and `10443`:
|
||||
|
||||
```console
|
||||
docker run -d -p 1080:1080 -p 10443:10443 -e HTTP_PORT=1080 -e HTTPS_PORT=10443 -v /var/run/docker.sock:/tmp/docker.sock:ro nginxproxy/nginx-proxy
|
||||
```
|
||||
|
||||
### Internet vs. Local Network Access
|
||||
|
||||
If you allow traffic from the public internet to access your `nginx-proxy` container, you may want to restrict some containers to the internal network only, so they cannot be accessed from the public internet. On containers that should be restricted to the internal network, you should set the environment variable `NETWORK_ACCESS=internal`. By default, the *internal* network is defined as `127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16`. To change the list of networks considered internal, mount a file on the `nginx-proxy` at `/etc/nginx/network_internal.conf` with these contents, edited to suit your needs:
|
||||
|
||||
```Nginx
|
||||
# These networks are considered "internal"
|
||||
allow 127.0.0.0/8;
|
||||
allow 10.0.0.0/8;
|
||||
allow 192.168.0.0/16;
|
||||
allow 172.16.0.0/12;
|
||||
|
||||
# Traffic from all other networks will be rejected
|
||||
deny all;
|
||||
```
|
||||
|
||||
When internal-only access is enabled, external clients will be denied with an `HTTP 403 Forbidden`
|
||||
|
||||
> If there is a load-balancer / reverse proxy in front of `nginx-proxy` that hides the client IP (example: AWS Application/Elastic Load Balancer), you will need to use the nginx `realip` module (already installed) to extract the client's IP from the HTTP request headers. Please see the [nginx realip module configuration](http://nginx.org/en/docs/http/ngx_http_realip_module.html) for more details. This configuration can be added to a new config file and mounted in `/etc/nginx/conf.d/`.
|
||||
|
||||
### SSL Backends
|
||||
|
||||
If you would like the reverse proxy to connect to your backend using HTTPS instead of HTTP, set `VIRTUAL_PROTO=https` on the backend container.
|
||||
|
||||
> Note: If you use `VIRTUAL_PROTO=https` and your backend container exposes port 80 and 443, `nginx-proxy` will use HTTPS on port 80. This is almost certainly not what you want, so you should also include `VIRTUAL_PORT=443`.
|
||||
|
||||
### uWSGI Backends
|
||||
|
||||
If you would like to connect to uWSGI backend, set `VIRTUAL_PROTO=uwsgi` on the
|
||||
backend container. Your backend container should than listen on a port rather
|
||||
than a socket and expose that port.
|
||||
If you would like to connect to uWSGI backend, set `VIRTUAL_PROTO=uwsgi` on the backend container. Your backend container should then listen on a port rather than a socket and expose that port.
|
||||
|
||||
### FastCGI Backends
|
||||
|
||||
If you would like to connect to FastCGI backend, set `VIRTUAL_PROTO=fastcgi` on the backend container. Your backend container should then listen on a port rather than a socket and expose that port.
|
||||
|
||||
### FastCGI File Root Directory
|
||||
|
||||
If you use fastcgi,you can set `VIRTUAL_ROOT=xxx` for your root directory
|
||||
|
||||
### Custom log format
|
||||
|
||||
If you want to use a custom log format, you can set `LOG_FORMAT=xxx` on the proxy container.
|
||||
|
||||
With docker compose take care to escape the `$` character with `$$` to avoid variable interpolation. Example: `$remote_addr` becomes `$$remote_addr`.
|
||||
|
||||
### Default Host
|
||||
|
||||
To set the default host for nginx use the env var `DEFAULT_HOST=foo.bar.com` for example
|
||||
|
||||
$ docker run -d -p 80:80 -e DEFAULT_HOST=foo.bar.com -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy
|
||||
```console
|
||||
docker run -d -p 80:80 -e DEFAULT_HOST=foo.bar.com -v /var/run/docker.sock:/tmp/docker.sock:ro nginxproxy/nginx-proxy
|
||||
```
|
||||
|
||||
nginx-proxy will then redirect all requests to a container where `VIRTUAL_HOST` is set to `DEFAULT_HOST`, if they don't match any (other) `VIRTUAL_HOST`. Using the example above requests without matching `VIRTUAL_HOST` will be redirected to a plain nginx instance after running the following command:
|
||||
|
||||
```console
|
||||
docker run -d -e VIRTUAL_HOST=foo.bar.com nginx
|
||||
```
|
||||
|
||||
### Separate Containers
|
||||
|
||||
nginx-proxy can also be run as two separate containers using the [jwilder/docker-gen](https://index.docker.io/u/jwilder/docker-gen/)
|
||||
image and the official [nginx](https://registry.hub.docker.com/_/nginx/) image.
|
||||
nginx-proxy can also be run as two separate containers using the [nginxproxy/docker-gen](https://hub.docker.com/r/nginxproxy/docker-gen) image and the official [nginx](https://registry.hub.docker.com/_/nginx/) image.
|
||||
|
||||
You may want to do this to prevent having the docker socket bound to a publicly exposed container service.
|
||||
|
||||
You can demo this pattern with docker-compose:
|
||||
|
||||
```console
|
||||
$ docker-compose --file docker-compose-separate-containers.yml up
|
||||
$ curl -H "Host: whoami.local" localhost
|
||||
docker-compose --file docker-compose-separate-containers.yml up
|
||||
curl -H "Host: whoami.local" localhost
|
||||
```
|
||||
|
||||
Example output:
|
||||
```console
|
||||
I'm 5b129ab83266
|
||||
```
|
||||
|
||||
To run nginx proxy as a separate container you'll need to have [nginx.tmpl](https://github.com/jwilder/nginx-proxy/blob/master/nginx.tmpl) on your host system.
|
||||
To run nginx proxy as a separate container you'll need to have [nginx.tmpl](https://github.com/nginx-proxy/nginx-proxy/blob/main/nginx.tmpl) on your host system.
|
||||
|
||||
First start nginx with a volume:
|
||||
|
||||
|
||||
$ docker run -d -p 80:80 --name nginx -v /tmp/nginx:/etc/nginx/conf.d -t nginx
|
||||
```console
|
||||
docker run -d -p 80:80 --name nginx -v /tmp/nginx:/etc/nginx/conf.d -t nginx
|
||||
```
|
||||
|
||||
Then start the docker-gen container with the shared volume and template:
|
||||
|
||||
```
|
||||
$ docker run --volumes-from nginx \
|
||||
```console
|
||||
docker run --volumes-from nginx \
|
||||
-v /var/run/docker.sock:/tmp/docker.sock:ro \
|
||||
-v $(pwd):/etc/docker-gen/templates \
|
||||
-t jwilder/docker-gen -notify-sighup nginx -watch /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
|
||||
-t nginxproxy/docker-gen -notify-sighup nginx -watch /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
|
||||
```
|
||||
|
||||
Finally, start your containers with `VIRTUAL_HOST` environment variables.
|
||||
|
||||
$ docker run -e VIRTUAL_HOST=foo.bar.com ...
|
||||
```console
|
||||
docker run -e VIRTUAL_HOST=foo.bar.com ...
|
||||
```
|
||||
|
||||
### SSL Support using an ACME CA
|
||||
|
||||
[acme-companion](https://github.com/nginx-proxy/acme-companion) is a lightweight companion container for the nginx-proxy. It allows the automated creation/renewal of SSL certificates using the ACME protocol.
|
||||
|
||||
### SSL Support
|
||||
|
||||
SSL is supported using single host, wildcard and SNI certificates using naming conventions for
|
||||
certificates or optionally specifying a cert name (for SNI) as an environment variable.
|
||||
SSL is supported using single host, wildcard and SNI certificates using naming conventions for certificates or optionally specifying a cert name (for SNI) as an environment variable.
|
||||
|
||||
To enable SSL:
|
||||
|
||||
$ docker run -d -p 80:80 -p 443:443 -v /path/to/certs:/etc/nginx/certs -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy
|
||||
```console
|
||||
docker run -d -p 80:80 -p 443:443 -v /path/to/certs:/etc/nginx/certs -v /var/run/docker.sock:/tmp/docker.sock:ro nginxproxy/nginx-proxy
|
||||
```
|
||||
|
||||
The contents of `/path/to/certs` should contain the certificates and private keys for any virtual
|
||||
hosts in use. The certificate and keys should be named after the virtual host with a `.crt` and
|
||||
`.key` extension. For example, a container with `VIRTUAL_HOST=foo.bar.com` should have a
|
||||
`foo.bar.com.crt` and `foo.bar.com.key` file in the certs directory.
|
||||
The contents of `/path/to/certs` should contain the certificates and private keys for any virtual hosts in use. The certificate and keys should be named after the virtual host with a `.crt` and `.key` extension. For example, a container with `VIRTUAL_HOST=foo.bar.com` should have a `foo.bar.com.crt` and `foo.bar.com.key` file in the certs directory.
|
||||
|
||||
If you are running the container in a virtualized environment (Hyper-V, VirtualBox, etc...),
|
||||
/path/to/certs must exist in that environment or be made accessible to that environment.
|
||||
By default, Docker is not able to mount directories on the host machine to containers running in a virtual machine.
|
||||
If you are running the container in a virtualized environment (Hyper-V, VirtualBox, etc...), /path/to/certs must exist in that environment or be made accessible to that environment. By default, Docker is not able to mount directories on the host machine to containers running in a virtual machine.
|
||||
|
||||
#### Diffie-Hellman Groups
|
||||
|
||||
If you have Diffie-Hellman groups enabled, the files should be named after the virtual host with a
|
||||
`dhparam` suffix and `.pem` extension. For example, a container with `VIRTUAL_HOST=foo.bar.com`
|
||||
should have a `foo.bar.com.dhparam.pem` file in the certs directory.
|
||||
[RFC7919 groups](https://datatracker.ietf.org/doc/html/rfc7919#appendix-A) with key lengths of 2048, 3072, and 4096 bits are [provided by `nginx-proxy`](https://github.com/nginx-proxy/nginx-proxy/dhparam). The ENV `DHPARAM_BITS` can be set to `2048` or `3072` to change from the default 4096-bit key. The DH key file will be located in the container at `/etc/nginx/dhparam/dhparam.pem`. Mounting a different `dhparam.pem` file at that location will override the RFC7919 key.
|
||||
|
||||
To use custom `dhparam.pem` files per-virtual-host, the files should be named after the virtual host with a `dhparam` suffix and `.pem` extension. For example, a container with `VIRTUAL_HOST=foo.bar.com` should have a `foo.bar.com.dhparam.pem` file in the `/etc/nginx/certs` directory.
|
||||
|
||||
> COMPATIBILITY WARNING: The default generated `dhparam.pem` key is 4096 bits for A+ security. Some older clients (like Java 6 and 7) do not support DH keys with over 1024 bits. In order to support these clients, you must provide your own `dhparam.pem`.
|
||||
|
||||
In the separate container setup, no pre-generated key will be available and neither the [nginxproxy/docker-gen](https://hub.docker.com/r/nginxproxy/docker-gen) image, nor the offical [nginx](https://registry.hub.docker.com/_/nginx/) image will provide one. If you still want A+ security in a separate container setup, you should mount an RFC7919 DH key file to the nginx container at `/etc/nginx/dhparam/dhparam.pem`.
|
||||
|
||||
Set `DHPARAM_SKIP` environment variable to `true` to disable using default Diffie-Hellman parameters. The default value is `false`.
|
||||
|
||||
```console
|
||||
docker run -e DHPARAM_SKIP=true ....
|
||||
```
|
||||
|
||||
#### Wildcard Certificates
|
||||
|
||||
Wildcard certificates and keys should be named after the domain name with a `.crt` and `.key` extension.
|
||||
For example `VIRTUAL_HOST=foo.bar.com` would use cert name `bar.com.crt` and `bar.com.key`.
|
||||
Wildcard certificates and keys should be named after the domain name with a `.crt` and `.key` extension. For example `VIRTUAL_HOST=foo.bar.com` would use cert name `bar.com.crt` and `bar.com.key`.
|
||||
|
||||
#### SNI
|
||||
|
||||
If your certificate(s) supports multiple domain names, you can start a container with `CERT_NAME=<name>`
|
||||
to identify the certificate to be used. For example, a certificate for `*.foo.com` and `*.bar.com`
|
||||
could be named `shared.crt` and `shared.key`. A container running with `VIRTUAL_HOST=foo.bar.com`
|
||||
and `CERT_NAME=shared` will then use this shared cert.
|
||||
If your certificate(s) supports multiple domain names, you can start a container with `CERT_NAME=<name>` to identify the certificate to be used. For example, a certificate for `*.foo.com` and `*.bar.com` could be named `shared.crt` and `shared.key`. A container running with `VIRTUAL_HOST=foo.bar.com` and `CERT_NAME=shared` will then use this shared cert.
|
||||
|
||||
#### OCSP Stapling
|
||||
|
||||
To enable OCSP Stapling for a domain, `nginx-proxy` looks for a PEM certificate containing the trusted CA certificate chain at `/etc/nginx/certs/<domain>.chain.pem`, where `<domain>` is the domain name in the `VIRTUAL_HOST` directive. The format of this file is a concatenation of the public PEM CA certificates starting with the intermediate CA most near the SSL certificate, down to the root CA. This is often referred to as the "SSL Certificate Chain". If found, this filename is passed to the NGINX [`ssl_trusted_certificate` directive](http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_trusted_certificate) and OCSP Stapling is enabled.
|
||||
|
||||
#### How SSL Support Works
|
||||
|
||||
The SSL cipher configuration is based on [mozilla nginx intermediate profile](https://wiki.mozilla.org/Security/Server_Side_TLS#Nginx) which
|
||||
should provide compatibility with clients back to Firefox 1, Chrome 1, IE 7, Opera 5, Safari 1,
|
||||
Windows XP IE8, Android 2.3, Java 7. The configuration also enables HSTS, and SSL
|
||||
session caches.
|
||||
The default SSL cipher configuration is based on the [Mozilla intermediate profile](https://wiki.mozilla.org/Security/Server_Side_TLS#Intermediate_compatibility_.28recommended.29) version 5.0 which should provide compatibility with clients back to Firefox 27, Android 4.4.2, Chrome 31, Edge, IE 11 on Windows 7, Java 8u31, OpenSSL 1.0.1, Opera 20, and Safari 9. Note that the DES-based TLS ciphers were removed for security. The configuration also enables HSTS, PFS, OCSP stapling and SSL session caches. Currently TLS 1.2 and 1.3 are supported.
|
||||
|
||||
If you don't require backward compatibility, you can use the [Mozilla modern profile](https://wiki.mozilla.org/Security/Server_Side_TLS#Modern_compatibility) profile instead by including the environment variable `SSL_POLICY=Mozilla-Modern` to the nginx-proxy container or to your container. This profile is compatible with clients back to Firefox 63, Android 10.0, Chrome 70, Edge 75, Java 11, OpenSSL 1.1.1, Opera 57, and Safari 12.1. Note that this profile is **not** compatible with any version of Internet Explorer.
|
||||
|
||||
Other policies available through the `SSL_POLICY` environment variable are [`Mozilla-Old`](https://wiki.mozilla.org/Security/Server_Side_TLS#Old_backward_compatibility) and the [AWS ELB Security Policies](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-security-policy-table.html) `AWS-TLS-1-2-2017-01`, `AWS-TLS-1-1-2017-01`, `AWS-2016-08`, `AWS-2015-05`, `AWS-2015-03` and `AWS-2015-02`.
|
||||
|
||||
Note that the `Mozilla-Old` policy should use a 1024 bits DH key for compatibility but this container provides a 4096 bits key. The [Diffie-Hellman Groups](#diffie-hellman-groups) section details different methods of bypassing this, either globally or per virtual-host.
|
||||
|
||||
The default behavior for the proxy when port 80 and 443 are exposed is as follows:
|
||||
|
||||
* If a container has a usable cert, port 80 will redirect to 443 for that container so that HTTPS
|
||||
is always preferred when available.
|
||||
* If the container does not have a usable cert, a 503 will be returned.
|
||||
* If a virtual host has a usable cert, port 80 will redirect to 443 for that virtual host so that HTTPS is always preferred when available.
|
||||
* If the virtual host does not have a usable cert, but `default.crt` and `default.key` exist, those will be used as the virtual host's certificate and the client browser will receive a 500 error.
|
||||
* If the virtual host does not have a usable cert, and `default.crt` and `default.key` do not exist, TLS negotiation will fail (see [Missing Certificate](#missing-certificate) below).
|
||||
|
||||
Note that in the latter case, a browser may get an connection error as no certificate is available
|
||||
to establish a connection. A self-signed or generic cert named `default.crt` and `default.key`
|
||||
will allow a client browser to make a SSL connection (likely w/ a warning) and subsequently receive
|
||||
a 503.
|
||||
To serve traffic in both SSL and non-SSL modes without redirecting to SSL, you can include the environment variable `HTTPS_METHOD=noredirect` (the default is `HTTPS_METHOD=redirect`). You can also disable the non-SSL site entirely with `HTTPS_METHOD=nohttp`, or disable the HTTPS site with `HTTPS_METHOD=nohttps`. `HTTPS_METHOD` can be specified on each container for which you want to override the default behavior or on the proxy container to set it globally. If `HTTPS_METHOD=noredirect` is used, Strict Transport Security (HSTS) is disabled to prevent HTTPS users from being redirected by the client. If you cannot get to the HTTP site after changing this setting, your browser has probably cached the HSTS policy and is automatically redirecting you back to HTTPS. You will need to clear your browser's HSTS cache or use an incognito window / different browser.
|
||||
|
||||
To serve traffic in both SSL and non-SSL modes without redirecting to SSL, you can include the
|
||||
environment variable `HTTPS_METHOD=noredirect` (the default is `HTTPS_METHOD=redirect`). You can also
|
||||
disable the non-SSL site entirely with `HTTPS_METHOD=nohttp`. `HTTPS_METHOD` must be specified
|
||||
on each container for which you want to override the default behavior. If `HTTPS_METHOD=noredirect` is
|
||||
used, Strict Transport Security (HSTS) is disabled to prevent HTTPS users from being redirected by the
|
||||
client. If you cannot get to the HTTP site after changing this setting, your browser has probably cached
|
||||
the HSTS policy and is automatically redirecting you back to HTTPS. You will need to clear your browser's
|
||||
HSTS cache or use an incognito window / different browser.
|
||||
By default, [HTTP Strict Transport Security (HSTS)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security) is enabled with `max-age=31536000` for HTTPS sites. You can disable HSTS with the environment variable `HSTS=off` or use a custom HSTS configuration like `HSTS=max-age=31536000; includeSubDomains; preload`.
|
||||
|
||||
*WARNING*: HSTS will force your users to visit the HTTPS version of your site for the `max-age` time - even if they type in `http://` manually. The only way to get to an HTTP site after receiving an HSTS response is to clear your browser's HSTS cache.
|
||||
|
||||
#### Missing Certificate
|
||||
|
||||
If HTTPS is enabled for a virtual host but its certificate is missing, nginx-proxy will configure nginx to use the default certificate (`default.crt` with `default.key`) and return a 500 error.
|
||||
|
||||
If the default certificate is also missing, nginx-proxy will configure nginx to accept HTTPS connections but fail the TLS negotiation. Client browsers will render a TLS error page. As of March 2023, web browsers display the following error messages:
|
||||
|
||||
* Chrome:
|
||||
|
||||
> This site can't provide a secure connection
|
||||
>
|
||||
> example.test sent an invalid response.
|
||||
>
|
||||
> Try running Connectivity Diagnostics.
|
||||
>
|
||||
> `ERR_SSL_PROTOCOL_ERROR`
|
||||
|
||||
* Firefox:
|
||||
|
||||
> Secure Connection Failed
|
||||
>
|
||||
> An error occurred during a connection to example.test.
|
||||
> Peer reports it experienced an internal error.
|
||||
>
|
||||
> Error code: `SSL_ERROR_INTERNAL_ERROR_ALERT` "TLS error".
|
||||
|
||||
### Basic Authentication Support
|
||||
|
||||
In order to be able to secure your virtual host, you have to create a file named as its equivalent VIRTUAL_HOST variable on directory
|
||||
/etc/nginx/htpasswd/$VIRTUAL_HOST
|
||||
|
||||
```
|
||||
$ docker run -d -p 80:80 -p 443:443 \
|
||||
```console
|
||||
docker run -d -p 80:80 -p 443:443 \
|
||||
-v /path/to/htpasswd:/etc/nginx/htpasswd \
|
||||
-v /path/to/certs:/etc/nginx/certs \
|
||||
-v /var/run/docker.sock:/tmp/docker.sock:ro \
|
||||
jwilder/nginx-proxy
|
||||
nginxproxy/nginx-proxy
|
||||
```
|
||||
|
||||
You'll need apache2-utils on the machine where you plan to create the htpasswd file. Follow these [instructions](http://httpd.apache.org/docs/2.2/programs/htpasswd.html)
|
||||
|
||||
### Upstream (Backend) Server HTTP Load Balancing Support
|
||||
|
||||
> **Warning**
|
||||
> This feature is experimental. The behavior may change (or the feature may be removed entirely) without warning in a future release, even if the release is not a new major version. If you use this feature, or if you would like to use this feature but you require changes to it first, please [provide feedback in #2195](https://github.com/nginx-proxy/nginx-proxy/discussions/2195). Once we have collected enough feedback we will promote this feature to officially supported.
|
||||
|
||||
If you have multiple containers with the same `VIRTUAL_HOST` and `VIRTUAL_PATH` settings, nginx will spread the load across all of them. To change the load balancing algorithm from nginx's default (round-robin), set the `com.github.nginx-proxy.nginx-proxy.loadbalance` label on one or more of your application containers to the desired load balancing directive. See the [`ngx_http_upstream_module` documentation](https://nginx.org/en/docs/http/ngx_http_upstream_module.html) for available directives.
|
||||
|
||||
> **Note**
|
||||
> * Don't forget the terminating semicolon (`;`).
|
||||
> * If you are using Docker Compose, remember to escape any dollar sign (`$`) characters (`$` becomes `$$`).
|
||||
|
||||
Docker Compose example:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
nginx-proxy:
|
||||
image: nginxproxy/nginx-proxy
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
environment:
|
||||
HTTPS_METHOD: nohttps
|
||||
myapp:
|
||||
image: jwilder/whoami
|
||||
expose:
|
||||
- "8000"
|
||||
environment:
|
||||
VIRTUAL_HOST: myapp.example
|
||||
VIRTUAL_PORT: "8000"
|
||||
labels:
|
||||
com.github.nginx-proxy.nginx-proxy.loadbalance: "hash $$remote_addr;"
|
||||
deploy:
|
||||
replicas: 4
|
||||
```
|
||||
|
||||
### Upstream (Backend) Server HTTP Keep-Alive Support
|
||||
|
||||
> **Warning**
|
||||
> This feature is experimental. The behavior may change (or the feature may be removed entirely) without warning in a future release, even if the release is not a new major version. If you use this feature, or if you would like to use this feature but you require changes to it first, please [provide feedback in #2194](https://github.com/nginx-proxy/nginx-proxy/discussions/2194). Once we have collected enough feedback we will promote this feature to officially supported.
|
||||
|
||||
To enable HTTP keep-alive between `nginx-proxy` and a backend server, set the `com.github.nginx-proxy.nginx-proxy.keepalive` label on the server's container to the desired maximum number of idle connections. See the [nginx keepalive documentation](https://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive) and the [Docker label documentation](https://docs.docker.com/config/labels-custom-metadata/) for details.
|
||||
|
||||
### Headers
|
||||
|
||||
By default, `nginx-proxy` forwards all incoming request headers from the client to the backend server unmodified, with the following exceptions:
|
||||
|
||||
* `Connection`: Set to `upgrade` if the client sets the `Upgrade` header, otherwise set to `close`. (Keep-alive between `nginx-proxy` and the backend server is not supported.)
|
||||
* `Proxy`: Always removed if present. This prevents attackers from using the so-called [httpoxy attack](http://httpoxy.org). There is no legitimate reason for a client to send this header, and there are many vulnerable languages / platforms (`CVE-2016-5385`, `CVE-2016-5386`, `CVE-2016-5387`, `CVE-2016-5388`, `CVE-2016-1000109`, `CVE-2016-1000110`, `CERT-VU#797896`).
|
||||
* `X-Real-IP`: Set to the client's IP address.
|
||||
* `X-Forwarded-For`: The client's IP address is appended to the value provided by the client. (If the client did not provide this header, it is set to the client's IP address.)
|
||||
* `X-Forwarded-Host`: If the client did not provide this header or if the `TRUST_DOWNSTREAM_PROXY` environment variable is set to `false` (see below), this is set to the value of the `Host` header provided by the client. Otherwise, the header is forwarded to the backend server unmodified.
|
||||
* `X-Forwarded-Proto`: If the client did not provide this header or if the `TRUST_DOWNSTREAM_PROXY` environment variable is set to `false` (see below), this is set to `http` for plain HTTP connections and `https` for TLS connections. Otherwise, the header is forwarded to the backend server unmodified.
|
||||
* `X-Forwarded-Ssl`: Set to `on` if the `X-Forwarded-Proto` header sent to the backend server is `https`, otherwise set to `off`.
|
||||
* `X-Forwarded-Port`: If the client did not provide this header or if the `TRUST_DOWNSTREAM_PROXY` environment variable is set to `false` (see below), this is set to the port of the server that accepted the client's request. Otherwise, the header is forwarded to the backend server unmodified.
|
||||
* `X-Original-URI`: Set to the original request URI.
|
||||
|
||||
#### Trusting Downstream Proxy Headers
|
||||
|
||||
For legacy compatibility reasons, `nginx-proxy` forwards any client-supplied `X-Forwarded-Proto` (which affects the value of `X-Forwarded-Ssl`), `X-Forwarded-Host`, and `X-Forwarded-Port` headers unchecked and unmodified. To prevent malicious clients from spoofing the protocol, hostname, or port that is perceived by your backend server, you are encouraged to set the `TRUST_DOWNSTREAM_PROXY` value to `false` if:
|
||||
|
||||
* you do not operate a second reverse proxy downstream of `nginx-proxy`, or
|
||||
* you do operate a second reverse proxy downstream of `nginx-proxy` but that proxy forwards those headers unchecked from untrusted clients.
|
||||
|
||||
The default for `TRUST_DOWNSTREAM_PROXY` may change to `false` in a future version of `nginx-proxy`. If you require it to be enabled, you are encouraged to explicitly set it to `true` to avoid compatibility problems when upgrading.
|
||||
|
||||
### Custom Nginx Configuration
|
||||
|
||||
If you need to configure Nginx beyond what is possible using environment variables, you can provide custom configuration files on either a proxy-wide or per-`VIRTUAL_HOST` basis.
|
||||
|
||||
#### Replacing default proxy settings
|
||||
|
||||
If you want to replace the default proxy settings for the nginx container, add a configuration file at `/etc/nginx/proxy.conf`. A file with the default settings would
|
||||
look like this:
|
||||
If you want to replace the default proxy settings for the nginx container, add a configuration file at `/etc/nginx/proxy.conf`. A file with the default settings would look like this:
|
||||
|
||||
```Nginx
|
||||
# HTTP 1.1 support
|
||||
@ -222,7 +480,11 @@ proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $proxy_connection;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Host $proxy_x_forwarded_host;
|
||||
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
|
||||
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
|
||||
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
|
||||
proxy_set_header X-Original-URI $request_uri;
|
||||
|
||||
# Mitigate httpoxy attack (see README for details)
|
||||
proxy_set_header Proxy "";
|
||||
@ -230,8 +492,6 @@ proxy_set_header Proxy "";
|
||||
|
||||
***NOTE***: If you provide this file it will replace the defaults; you may want to check the .tmpl file to make sure you have all of the needed options.
|
||||
|
||||
***NOTE***: The default configuration blocks the `Proxy` HTTP request header from being sent to downstream servers. This prevents attackers from using the so-called [httpoxy attack](http://httpoxy.org). There is no legitimate reason for a client to send this header, and there are many vulnerable languages / platforms (`CVE-2016-5385`, `CVE-2016-5386`, `CVE-2016-5387`, `CVE-2016-5388`, `CVE-2016-1000109`, `CVE-2016-1000110`, `CERT-VU#797896`).
|
||||
|
||||
#### Proxy-wide
|
||||
|
||||
To add settings on a proxy-wide basis, add your configuration file under `/etc/nginx/conf.d` using a name ending in `.conf`.
|
||||
@ -239,7 +499,7 @@ To add settings on a proxy-wide basis, add your configuration file under `/etc/n
|
||||
This can be done in a derived image by creating the file in a `RUN` command or by `COPY`ing the file into `conf.d`:
|
||||
|
||||
```Dockerfile
|
||||
FROM jwilder/nginx-proxy
|
||||
FROM nginxproxy/nginx-proxy
|
||||
RUN { \
|
||||
echo 'server_tokens off;'; \
|
||||
echo 'client_max_body_size 100m;'; \
|
||||
@ -248,7 +508,9 @@ RUN { \
|
||||
|
||||
Or it can be done by mounting in your custom configuration in your `docker run` command:
|
||||
|
||||
$ docker run -d -p 80:80 -p 443:443 -v /path/to/my_proxy.conf:/etc/nginx/conf.d/my_proxy.conf:ro -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy
|
||||
```console
|
||||
docker run -d -p 80:80 -p 443:443 -v /path/to/my_proxy.conf:/etc/nginx/conf.d/my_proxy.conf:ro -v /var/run/docker.sock:/tmp/docker.sock:ro nginxproxy/nginx-proxy
|
||||
```
|
||||
|
||||
#### Per-VIRTUAL_HOST
|
||||
|
||||
@ -258,38 +520,107 @@ In order to allow virtual hosts to be dynamically configured as backends are add
|
||||
|
||||
For example, if you have a virtual host named `app.example.com`, you could provide a custom configuration for that host as follows:
|
||||
|
||||
$ docker run -d -p 80:80 -p 443:443 -v /path/to/vhost.d:/etc/nginx/vhost.d:ro -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy
|
||||
$ { echo 'server_tokens off;'; echo 'client_max_body_size 100m;'; } > /path/to/vhost.d/app.example.com
|
||||
```console
|
||||
docker run -d -p 80:80 -p 443:443 -v /path/to/vhost.d:/etc/nginx/vhost.d:ro -v /var/run/docker.sock:/tmp/docker.sock:ro nginxproxy/nginx-proxy
|
||||
{ echo 'server_tokens off;'; echo 'client_max_body_size 100m;'; } > /path/to/vhost.d/app.example.com
|
||||
```
|
||||
|
||||
If you are using multiple hostnames for a single container (e.g. `VIRTUAL_HOST=example.com,www.example.com`), the virtual host configuration file must exist for each hostname. If you would like to use the same configuration for multiple virtual host names, you can use a symlink:
|
||||
|
||||
$ { echo 'server_tokens off;'; echo 'client_max_body_size 100m;'; } > /path/to/vhost.d/www.example.com
|
||||
$ ln -s /path/to/vhost.d/www.example.com /path/to/vhost.d/example.com
|
||||
```console
|
||||
{ echo 'server_tokens off;'; echo 'client_max_body_size 100m;'; } > /path/to/vhost.d/www.example.com
|
||||
ln -s /path/to/vhost.d/www.example.com /path/to/vhost.d/example.com
|
||||
```
|
||||
|
||||
#### Per-VIRTUAL_HOST default configuration
|
||||
|
||||
If you want most of your virtual hosts to use a default single configuration and then override on a few specific ones, add those settings to the `/etc/nginx/vhost.d/default` file. This file
|
||||
will be used on any virtual host which does not have a `/etc/nginx/vhost.d/{VIRTUAL_HOST}` file associated with it.
|
||||
If you want most of your virtual hosts to use a default single configuration and then override on a few specific ones, add those settings to the `/etc/nginx/vhost.d/default` file. This file will be used on any virtual host which does not have a `/etc/nginx/vhost.d/{VIRTUAL_HOST}` file associated with it.
|
||||
|
||||
#### Per-VIRTUAL_HOST location configuration
|
||||
|
||||
To add settings to the "location" block on a per-`VIRTUAL_HOST` basis, add your configuration file under `/etc/nginx/vhost.d`
|
||||
just like the previous section except with the suffix `_location`.
|
||||
To add settings to the "location" block on a per-`VIRTUAL_HOST` basis, add your configuration file under `/etc/nginx/vhost.d` just like the previous section except with the suffix `_location`.
|
||||
|
||||
For example, if you have a virtual host named `app.example.com` and you have configured a proxy_cache `my-cache` in another custom file, you could tell it to use a proxy cache as follows:
|
||||
|
||||
$ docker run -d -p 80:80 -p 443:443 -v /path/to/vhost.d:/etc/nginx/vhost.d:ro -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy
|
||||
$ { echo 'proxy_cache my-cache;'; echo 'proxy_cache_valid 200 302 60m;'; echo 'proxy_cache_valid 404 1m;' } > /path/to/vhost.d/app.example.com_location
|
||||
```console
|
||||
docker run -d -p 80:80 -p 443:443 -v /path/to/vhost.d:/etc/nginx/vhost.d:ro -v /var/run/docker.sock:/tmp/docker.sock:ro nginxproxy/nginx-proxy
|
||||
{ echo 'proxy_cache my-cache;'; echo 'proxy_cache_valid 200 302 60m;'; echo 'proxy_cache_valid 404 1m;' } > /path/to/vhost.d/app.example.com_location
|
||||
```
|
||||
|
||||
If you are using multiple hostnames for a single container (e.g. `VIRTUAL_HOST=example.com,www.example.com`), the virtual host configuration file must exist for each hostname. If you would like to use the same configuration for multiple virtual host names, you can use a symlink:
|
||||
|
||||
$ { echo 'proxy_cache my-cache;'; echo 'proxy_cache_valid 200 302 60m;'; echo 'proxy_cache_valid 404 1m;' } > /path/to/vhost.d/app.example.com_location
|
||||
$ ln -s /path/to/vhost.d/www.example.com /path/to/vhost.d/example.com
|
||||
```console
|
||||
{ echo 'proxy_cache my-cache;'; echo 'proxy_cache_valid 200 302 60m;'; echo 'proxy_cache_valid 404 1m;' } > /path/to/vhost.d/app.example.com_location
|
||||
ln -s /path/to/vhost.d/www.example.com /path/to/vhost.d/example.com
|
||||
```
|
||||
|
||||
#### Per-VIRTUAL_HOST location default configuration
|
||||
|
||||
If you want most of your virtual hosts to use a default single `location` block configuration and then override on a few specific ones, add those settings to the `/etc/nginx/vhost.d/default_location` file. This file
|
||||
will be used on any virtual host which does not have a `/etc/nginx/vhost.d/{VIRTUAL_HOST}` file associated with it.
|
||||
If you want most of your virtual hosts to use a default single `location` block configuration and then override on a few specific ones, add those settings to the `/etc/nginx/vhost.d/default_location` file. This file will be used on any virtual host which does not have a `/etc/nginx/vhost.d/{VIRTUAL_HOST}_location` file associated with it.
|
||||
|
||||
#### Overriding `location` blocks
|
||||
|
||||
The `${VIRTUAL_HOST}_${PATH_HASH}_location`, `${VIRTUAL_HOST}_location`, and `default_location` files documented above make it possible to *augment* the generated [`location` block(s)](https://nginx.org/en/docs/http/ngx_http_core_module.html#location) in a virtual host. In some circumstances, you may need to *completely override* the `location` block for a particular combination of virtual host and path. To do this, create a file whose name follows this pattern:
|
||||
|
||||
```
|
||||
/etc/nginx/vhost.d/${VIRTUAL_HOST}_${PATH_HASH}_location_override
|
||||
```
|
||||
|
||||
where `${VIRTUAL_HOST}` is the name of the virtual host (the `VIRTUAL_HOST` environment variable) and `${PATH_HASH}` is the SHA-1 hash of the path, as [described above](#per-virtual_path-location-configuration).
|
||||
|
||||
For convenience, the `_${PATH_HASH}` part can be omitted if the path is `/`:
|
||||
|
||||
```
|
||||
/etc/nginx/vhost.d/${VIRTUAL_HOST}_location_override
|
||||
```
|
||||
|
||||
When an override file exists, the `location` block that is normally created by `nginx-proxy` is not generated. Instead, the override file is included via the [nginx `include` directive](https://nginx.org/en/docs/ngx_core_module.html#include).
|
||||
|
||||
You are responsible for providing a suitable `location` block in your override file as required for your service. By default, `nginx-proxy` uses the `VIRTUAL_HOST` name as the upstream name for your application's Docker container; see [here](#unhashed-vs-sha1-upstream-names) for details. As an example, if your container has a `VIRTUAL_HOST` value of `app.example.com`, then to override the location block for `/` you would create a file named `/etc/nginx/vhost.d/app.example.com_location_override` that contains something like this:
|
||||
|
||||
```
|
||||
location / {
|
||||
proxy_pass http://app.example.com;
|
||||
}
|
||||
```
|
||||
|
||||
#### Per-VIRTUAL_HOST `server_tokens` configuration
|
||||
Per virtual-host `servers_tokens` directive can be configured by passing appropriate value to the `SERVER_TOKENS` environment variable. Please see the [nginx http_core module configuration](https://nginx.org/en/docs/http/ngx_http_core_module.html#server_tokens) for more details.
|
||||
|
||||
### Unhashed vs SHA1 upstream names
|
||||
|
||||
By default the nginx configuration `upstream` blocks will use this block's corresponding hostname as a predictable name. However, this can cause issues in some setups (see [this issue](https://github.com/nginx-proxy/nginx-proxy/issues/1162)). In those cases you might want to switch to SHA1 names for the `upstream` blocks by setting the `SHA1_UPSTREAM_NAME` environment variable to `true` on the nginx-proxy container.
|
||||
|
||||
Please note that using regular expressions in `VIRTUAL_HOST` will always result in a corresponding `upstream` block with an SHA1 name.
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
If you can't access your `VIRTUAL_HOST`, inspect the generated nginx configuration:
|
||||
|
||||
```console
|
||||
docker exec <nginx-proxy-instance> nginx -T
|
||||
```
|
||||
|
||||
Pay attention to the `upstream` definition blocks, which should look like this:
|
||||
|
||||
```Nginx
|
||||
# foo.example.com
|
||||
upstream foo.example.com {
|
||||
## Can be connected with "my_network" network
|
||||
# Exposed ports: [{ <exposed_port1> tcp } { <exposed_port2> tcp } ...]
|
||||
# Default virtual port: <exposed_port|80>
|
||||
# VIRTUAL_PORT: <VIRTUAL_PORT>
|
||||
# foo
|
||||
server 172.18.0.9:<Port>;
|
||||
# Fallback entry
|
||||
server 127.0.0.1 down;
|
||||
}
|
||||
```
|
||||
|
||||
The effective `Port` is retrieved by order of precedence:
|
||||
1. From the `VIRTUAL_PORT` environment variable
|
||||
1. From the container's exposed port if there is only one
|
||||
1. From the default port 80 when none of the above methods apply
|
||||
|
||||
### Contributing
|
||||
|
||||
@ -297,6 +628,19 @@ Before submitting pull requests or issues, please check github to make sure an e
|
||||
|
||||
#### Running Tests Locally
|
||||
|
||||
To run tests, you'll need to install [bats 0.4.0](https://github.com/sstephenson/bats).
|
||||
To run tests, you just need to run the command below:
|
||||
|
||||
make test
|
||||
```console
|
||||
make test
|
||||
```
|
||||
|
||||
This commands run tests on two variants of the nginx-proxy docker image: Debian and Alpine.
|
||||
|
||||
You can run the tests for each of these images with their respective commands:
|
||||
|
||||
```console
|
||||
make test-debian
|
||||
make test-alpine
|
||||
```
|
||||
|
||||
You can learn more about how the test suite works and how to write new tests in the [test/README.md](test/README.md) file.
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
nginx: nginx
|
||||
dockergen: docker-gen -watch -notify "nginx -s reload" /app/nginx.tmpl /etc/nginx/conf.d/default.conf
|
||||
nginx: nginx
|
||||
8
app/dhparam/ffdhe2048.pem
Normal file
8
app/dhparam/ffdhe2048.pem
Normal file
@ -0,0 +1,8 @@
|
||||
-----BEGIN DH PARAMETERS-----
|
||||
MIIBCAKCAQEA//////////+t+FRYortKmq/cViAnPTzx2LnFg84tNpWp4TZBFGQz
|
||||
+8yTnc4kmz75fS/jY2MMddj2gbICrsRhetPfHtXV/WVhJDP1H18GbtCFY2VVPe0a
|
||||
87VXE15/V8k1mE8McODmi3fipona8+/och3xWKE2rec1MKzKT0g6eXq8CrGCsyT7
|
||||
YdEIqUuyyOP7uWrat2DX9GgdT0Kj3jlN9K5W7edjcrsZCwenyO4KbXCeAvzhzffi
|
||||
7MA0BM0oNC9hkXL+nOmFg/+OTxIy7vKBg8P+OxtMb61zO7X8vC7CIAXFjvGDfRaD
|
||||
ssbzSibBsu/6iGtCOGEoXJf//////////wIBAg==
|
||||
-----END DH PARAMETERS-----
|
||||
11
app/dhparam/ffdhe3072.pem
Normal file
11
app/dhparam/ffdhe3072.pem
Normal file
@ -0,0 +1,11 @@
|
||||
-----BEGIN DH PARAMETERS-----
|
||||
MIIBiAKCAYEA//////////+t+FRYortKmq/cViAnPTzx2LnFg84tNpWp4TZBFGQz
|
||||
+8yTnc4kmz75fS/jY2MMddj2gbICrsRhetPfHtXV/WVhJDP1H18GbtCFY2VVPe0a
|
||||
87VXE15/V8k1mE8McODmi3fipona8+/och3xWKE2rec1MKzKT0g6eXq8CrGCsyT7
|
||||
YdEIqUuyyOP7uWrat2DX9GgdT0Kj3jlN9K5W7edjcrsZCwenyO4KbXCeAvzhzffi
|
||||
7MA0BM0oNC9hkXL+nOmFg/+OTxIy7vKBg8P+OxtMb61zO7X8vC7CIAXFjvGDfRaD
|
||||
ssbzSibBsu/6iGtCOGEfz9zeNVs7ZRkDW7w09N75nAI4YbRvydbmyQd62R0mkff3
|
||||
7lmMsPrBhtkcrv4TCYUTknC0EwyTvEN5RPT9RFLi103TZPLiHnH1S/9croKrnJ32
|
||||
nuhtK8UiNjoNq8Uhl5sN6todv5pC1cRITgq80Gv6U93vPBsg7j/VnXwl5B0rZsYu
|
||||
N///////////AgEC
|
||||
-----END DH PARAMETERS-----
|
||||
13
app/dhparam/ffdhe4096.pem
Normal file
13
app/dhparam/ffdhe4096.pem
Normal file
@ -0,0 +1,13 @@
|
||||
-----BEGIN DH PARAMETERS-----
|
||||
MIICCAKCAgEA//////////+t+FRYortKmq/cViAnPTzx2LnFg84tNpWp4TZBFGQz
|
||||
+8yTnc4kmz75fS/jY2MMddj2gbICrsRhetPfHtXV/WVhJDP1H18GbtCFY2VVPe0a
|
||||
87VXE15/V8k1mE8McODmi3fipona8+/och3xWKE2rec1MKzKT0g6eXq8CrGCsyT7
|
||||
YdEIqUuyyOP7uWrat2DX9GgdT0Kj3jlN9K5W7edjcrsZCwenyO4KbXCeAvzhzffi
|
||||
7MA0BM0oNC9hkXL+nOmFg/+OTxIy7vKBg8P+OxtMb61zO7X8vC7CIAXFjvGDfRaD
|
||||
ssbzSibBsu/6iGtCOGEfz9zeNVs7ZRkDW7w09N75nAI4YbRvydbmyQd62R0mkff3
|
||||
7lmMsPrBhtkcrv4TCYUTknC0EwyTvEN5RPT9RFLi103TZPLiHnH1S/9croKrnJ32
|
||||
nuhtK8UiNjoNq8Uhl5sN6todv5pC1cRITgq80Gv6U93vPBsg7j/VnXwl5B0rZp4e
|
||||
8W5vUsMWTfT7eTDp5OWIV7asfV9C1p9tGHdjzx1VA0AEh/VbpX4xzHpxNciG77Qx
|
||||
iu1qHgEtnmgyqQdgCpGBMMRtx3j5ca0AOAkpmaMzy4t6Gh25PXFAADwqTs6p+Y0K
|
||||
zAqCkc3OyX3Pjsm1Wn+IpGtNtahR9EGC4caKAH5eZV9q//////////8CAQI=
|
||||
-----END DH PARAMETERS-----
|
||||
121
app/docker-entrypoint.sh
Executable file
121
app/docker-entrypoint.sh
Executable file
@ -0,0 +1,121 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
function _parse_true() {
|
||||
case "$1" in
|
||||
|
||||
true | True | TRUE | 1)
|
||||
return 0
|
||||
;;
|
||||
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
|
||||
esac
|
||||
}
|
||||
|
||||
function _parse_false() {
|
||||
case "$1" in
|
||||
|
||||
false | False | FALSE | 0)
|
||||
return 0
|
||||
;;
|
||||
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
|
||||
esac
|
||||
}
|
||||
|
||||
function _print_version {
|
||||
if [[ -n "${NGINX_PROXY_VERSION:-}" ]]; then
|
||||
echo "Info: running nginx-proxy version ${NGINX_PROXY_VERSION}"
|
||||
fi
|
||||
}
|
||||
|
||||
function _check_unix_socket() {
|
||||
# Warn if the DOCKER_HOST socket does not exist
|
||||
if [[ ${DOCKER_HOST} == unix://* ]]; then
|
||||
local SOCKET_FILE="${DOCKER_HOST#unix://}"
|
||||
|
||||
if [[ ! -S ${SOCKET_FILE} ]]; then
|
||||
cat >&2 <<-EOT
|
||||
ERROR: you need to share your Docker host socket with a volume at ${SOCKET_FILE}
|
||||
Typically you should run your nginxproxy/nginx-proxy with: \`-v /var/run/docker.sock:${SOCKET_FILE}:ro\`
|
||||
See the documentation at: https://github.com/nginx-proxy/nginx-proxy/#usage
|
||||
EOT
|
||||
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function _resolvers() {
|
||||
# Compute the DNS resolvers for use in the templates - if the IP contains ":", it's IPv6 and must be enclosed in []
|
||||
RESOLVERS=$(awk '$1 == "nameserver" {print ($2 ~ ":")? "["$2"]": $2}' ORS=' ' /etc/resolv.conf | sed 's/ *$//g'); export RESOLVERS
|
||||
|
||||
SCOPED_IPV6_REGEX='\[fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}\]'
|
||||
|
||||
if [[ -z ${RESOLVERS} ]]; then
|
||||
echo 'Warning: unable to determine DNS resolvers for nginx' >&2
|
||||
unset RESOLVERS
|
||||
elif [[ ${RESOLVERS} =~ ${SCOPED_IPV6_REGEX} ]]; then
|
||||
echo -n 'Warning: Scoped IPv6 addresses removed from resolvers: ' >&2
|
||||
echo "${RESOLVERS}" | grep -Eo "$SCOPED_IPV6_REGEX" | paste -s -d ' ' >&2
|
||||
RESOLVERS=$(echo "${RESOLVERS}" | sed -r "s/${SCOPED_IPV6_REGEX}//g" | xargs echo -n); export RESOLVERS
|
||||
fi
|
||||
}
|
||||
|
||||
function _setup_dhparam() {
|
||||
# DH params will be supplied for nginx here:
|
||||
local DHPARAM_FILE='/etc/nginx/dhparam/dhparam.pem'
|
||||
|
||||
# Should be 2048, 3072, or 4096 (default):
|
||||
local FFDHE_GROUP="${DHPARAM_BITS:=4096}"
|
||||
|
||||
# DH params may be provided by the user (rarely necessary)
|
||||
if [[ -f ${DHPARAM_FILE} ]]; then
|
||||
echo 'Warning: A custom dhparam.pem file was provided. Best practice is to use standardized RFC7919 DHE groups instead.' >&2
|
||||
return 0
|
||||
elif _parse_true "${DHPARAM_SKIP:=false}"; then
|
||||
echo 'Skipping Diffie-Hellman parameters setup.'
|
||||
return 0
|
||||
elif _parse_false "${DHPARAM_GENERATION:=true}"; then
|
||||
echo 'Warning: The DHPARAM_GENERATION environment variable is deprecated, please consider using DHPARAM_SKIP set to true instead.' >&2
|
||||
echo 'Skipping Diffie-Hellman parameters setup.'
|
||||
return 0
|
||||
elif [[ ! ${DHPARAM_BITS} =~ ^(2048|3072|4096)$ ]]; then
|
||||
echo "ERROR: Unsupported DHPARAM_BITS size: ${DHPARAM_BITS}. Use: 2048, 3072, or 4096 (default)." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo 'Setting up DH Parameters..'
|
||||
|
||||
# Use an existing pre-generated DH group from RFC7919 (https://datatracker.ietf.org/doc/html/rfc7919#appendix-A):
|
||||
local RFC7919_DHPARAM_FILE="/app/dhparam/ffdhe${FFDHE_GROUP}.pem"
|
||||
|
||||
# Provide the DH params file to nginx:
|
||||
cp "${RFC7919_DHPARAM_FILE}" "${DHPARAM_FILE}"
|
||||
}
|
||||
|
||||
# Run the init logic if the default CMD was provided
|
||||
if [[ $* == 'forego start -r' ]]; then
|
||||
_print_version
|
||||
|
||||
_check_unix_socket
|
||||
|
||||
_resolvers
|
||||
|
||||
_setup_dhparam
|
||||
|
||||
if [ -z "${TRUST_DOWNSTREAM_PROXY}" ]; then
|
||||
cat >&2 <<-EOT
|
||||
Warning: TRUST_DOWNSTREAM_PROXY is not set; defaulting to "true". For security, you should explicitly set TRUST_DOWNSTREAM_PROXY to "false" if there is not a trusted reverse proxy in front of this proxy.
|
||||
Warning: The default value of TRUST_DOWNSTREAM_PROXY might change to "false" in a future version of nginx-proxy. If you require TRUST_DOWNSTREAM_PROXY to be enabled, explicitly set it to "true".
|
||||
EOT
|
||||
fi
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
@ -9,8 +9,9 @@ services:
|
||||
- /etc/nginx/conf.d
|
||||
|
||||
dockergen:
|
||||
image: jwilder/docker-gen
|
||||
command: -notify-sighup nginx -watch /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
|
||||
image: nginxproxy/docker-gen
|
||||
command: -notify-sighup nginx -watch /etc/docker-gen/templates/nginx.tmpl
|
||||
/etc/nginx/conf.d/default.conf
|
||||
volumes_from:
|
||||
- nginx
|
||||
volumes:
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
version: '2'
|
||||
services:
|
||||
nginx-proxy:
|
||||
image: jwilder/nginx-proxy
|
||||
image: nginxproxy/nginx-proxy
|
||||
container_name: nginx-proxy
|
||||
ports:
|
||||
- "80:80"
|
||||
@ -12,4 +12,3 @@ services:
|
||||
image: jwilder/whoami
|
||||
environment:
|
||||
- VIRTUAL_HOST=whoami.local
|
||||
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Warn if the DOCKER_HOST socket does not exist
|
||||
if [[ $DOCKER_HOST == unix://* ]]; then
|
||||
socket_file=${DOCKER_HOST#unix://}
|
||||
if ! [ -S $socket_file ]; then
|
||||
cat >&2 <<-EOT
|
||||
ERROR: you need to share your Docker host socket with a volume at $socket_file
|
||||
Typically you should run your jwilder/nginx-proxy with: \`-v /var/run/docker.sock:$socket_file:ro\`
|
||||
See the documentation at http://git.io/vZaGJ
|
||||
EOT
|
||||
socketMissing=1
|
||||
fi
|
||||
fi
|
||||
|
||||
# If the user has run the default command and the socket doesn't exist, fail
|
||||
if [ "$socketMissing" = 1 -a "$1" = forego -a "$2" = start -a "$3" = '-r' ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
7
network_internal.conf
Normal file
7
network_internal.conf
Normal file
@ -0,0 +1,7 @@
|
||||
# Only allow traffic from internal clients
|
||||
allow 127.0.0.0/8;
|
||||
allow 10.0.0.0/8;
|
||||
allow 192.168.0.0/16;
|
||||
allow 172.16.0.0/12;
|
||||
allow fc00::/7; # IPv6 local address range
|
||||
deny all;
|
||||
802
nginx.tmpl
802
nginx.tmpl
@ -1,47 +1,334 @@
|
||||
{{ $CurrentContainer := where $ "ID" .Docker.CurrentContainerID | first }}
|
||||
# nginx-proxy{{ if $.Env.NGINX_PROXY_VERSION }} version : {{ $.Env.NGINX_PROXY_VERSION }}{{ end }}
|
||||
|
||||
{{ define "upstream" }}
|
||||
{{ if .Address }}
|
||||
{{/* If we got the containers from swarm and this container's port is published to host, use host IP:PORT */}}
|
||||
{{ if and .Container.Node.ID .Address.HostPort }}
|
||||
# {{ .Container.Node.Name }}/{{ .Container.Name }}
|
||||
server {{ .Container.Node.Address.IP }}:{{ .Address.HostPort }};
|
||||
{{/* If there is no swarm node or the port is not published on host, use container's IP:PORT */}}
|
||||
{{ else if .Network }}
|
||||
# {{ .Container.Name }}
|
||||
server {{ .Network.IP }}:{{ .Address.Port }};
|
||||
{{ end }}
|
||||
{{ else if .Network }}
|
||||
# {{ .Container.Name }}
|
||||
server {{ .Network.IP }} down;
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{- /*
|
||||
* Global values. Values are stored in this map rather than in individual
|
||||
* global variables so that the values can be easily passed to embedded
|
||||
* templates. (Go templates cannot access variables outside of their own
|
||||
* scope.)
|
||||
*/}}
|
||||
{{- $globals := dict }}
|
||||
{{- $_ := set $globals "containers" $ }}
|
||||
{{- $_ := set $globals "Env" $.Env }}
|
||||
{{- $_ := set $globals "Docker" $.Docker }}
|
||||
{{- $_ := set $globals "CurrentContainer" (where $globals.containers "ID" $globals.Docker.CurrentContainerID | first) }}
|
||||
{{- $_ := set $globals "default_cert_ok" (and (exists "/etc/nginx/certs/default.crt") (exists "/etc/nginx/certs/default.key")) }}
|
||||
{{- $_ := set $globals "external_http_port" (coalesce $globals.Env.HTTP_PORT "80") }}
|
||||
{{- $_ := set $globals "external_https_port" (coalesce $globals.Env.HTTPS_PORT "443") }}
|
||||
{{- $_ := set $globals "sha1_upstream_name" (parseBool (coalesce $globals.Env.SHA1_UPSTREAM_NAME "false")) }}
|
||||
{{- $_ := set $globals "default_root_response" (coalesce $globals.Env.DEFAULT_ROOT "404") }}
|
||||
{{- $_ := set $globals "trust_downstream_proxy" (parseBool (coalesce $globals.Env.TRUST_DOWNSTREAM_PROXY "true")) }}
|
||||
{{- $_ := set $globals "access_log" (or (and (not $globals.Env.DISABLE_ACCESS_LOGS) "access_log /var/log/nginx/access.log vhost;") "") }}
|
||||
{{- $_ := set $globals "enable_ipv6" (parseBool (coalesce $globals.Env.ENABLE_IPV6 "false")) }}
|
||||
{{- $_ := set $globals "ssl_policy" (or ($globals.Env.SSL_POLICY) "Mozilla-Intermediate") }}
|
||||
{{- $_ := set $globals "vhosts" (dict) }}
|
||||
{{- $_ := set $globals "networks" (dict) }}
|
||||
# Networks available to the container running docker-gen (which are assumed to
|
||||
# match the networks available to the container running nginx):
|
||||
{{- /*
|
||||
* Note: $globals.CurrentContainer may be nil in some circumstances due to
|
||||
* <https://github.com/nginx-proxy/docker-gen/issues/458>. For more context
|
||||
* see <https://github.com/nginx-proxy/nginx-proxy/issues/2189>.
|
||||
*/}}
|
||||
{{- if $globals.CurrentContainer }}
|
||||
{{- range sortObjectsByKeysAsc $globals.CurrentContainer.Networks "Name" }}
|
||||
{{- $_ := set $globals.networks .Name . }}
|
||||
# {{ .Name }}
|
||||
{{- else }}
|
||||
# (none)
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
# /!\ WARNING: Failed to find the Docker container running docker-gen. All
|
||||
# upstream (backend) application containers will appear to be
|
||||
# unreachable. Try removing the -only-exposed and -only-published
|
||||
# arguments to docker-gen if you pass either of those. See
|
||||
# <https://github.com/nginx-proxy/docker-gen/issues/458>.
|
||||
{{- end }}
|
||||
|
||||
{{- /*
|
||||
* Template used as a function to get a container's IP address. This
|
||||
* template only outputs debug comments; the IP address is "returned" by
|
||||
* storing the value in the provided dot dict.
|
||||
*
|
||||
* The provided dot dict is expected to have the following entries:
|
||||
* - "globals": Global values.
|
||||
* - "container": The container's RuntimeContainer struct.
|
||||
*
|
||||
* The return value will be added to the dot dict with key "ip".
|
||||
*/}}
|
||||
{{- define "container_ip" }}
|
||||
{{- $ip := "" }}
|
||||
# networks:
|
||||
{{- range sortObjectsByKeysAsc $.container.Networks "Name" }}
|
||||
{{- /*
|
||||
* TODO: Only ignore the "ingress" network for Swarm tasks (in case
|
||||
* the user is not using Swarm mode and names a network "ingress").
|
||||
*/}}
|
||||
{{- if eq .Name "ingress" }}
|
||||
# {{ .Name }} (ignored)
|
||||
{{- continue }}
|
||||
{{- end }}
|
||||
{{- if and (not (index $.globals.networks .Name)) (not $.globals.networks.host) }}
|
||||
# {{ .Name }} (unreachable)
|
||||
{{- continue }}
|
||||
{{- end }}
|
||||
{{- /*
|
||||
* Do not emit multiple `server` directives for this container if it
|
||||
* is reachable over multiple networks. This avoids accidentally
|
||||
* inflating the effective round-robin weight of a server due to the
|
||||
* redundant upstream addresses that nginx sees as belonging to
|
||||
* distinct servers.
|
||||
*/}}
|
||||
{{- if $ip }}
|
||||
# {{ .Name }} (ignored; reachable but redundant)
|
||||
{{- continue }}
|
||||
{{- end }}
|
||||
# {{ .Name }} (reachable)
|
||||
{{- if and . .IP }}
|
||||
{{- $ip = .IP }}
|
||||
{{- else }}
|
||||
# /!\ No IP for this network!
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
# (none)
|
||||
{{- end }}
|
||||
# IP address: {{ if $ip }}{{ $ip }}{{ else }}(none usable){{ end }}
|
||||
{{- $_ := set $ "ip" $ip }}
|
||||
{{- end }}
|
||||
|
||||
{{- /*
|
||||
* Template used as a function to get the port of the server in the given
|
||||
* container. This template only outputs debug comments; the port is
|
||||
* "returned" by storing the value in the provided dot dict.
|
||||
*
|
||||
* The provided dot dict is expected to have the following entries:
|
||||
* - "container": The container's RuntimeContainer struct.
|
||||
*
|
||||
* The return value will be added to the dot dict with key "port".
|
||||
*/}}
|
||||
{{- define "container_port" }}
|
||||
{{- /* If only 1 port exposed, use that as a default, else 80. */}}
|
||||
# exposed ports:{{ range sortObjectsByKeysAsc $.container.Addresses "Port" }} {{ .Port }}/{{ .Proto }}{{ else }} (none){{ end }}
|
||||
{{- $default_port := when (eq (len $.container.Addresses) 1) (first $.container.Addresses).Port "80" }}
|
||||
# default port: {{ $default_port }}
|
||||
{{- $port := or $.container.Env.VIRTUAL_PORT $default_port }}
|
||||
# using port: {{ $port }}
|
||||
{{- $addr_obj := where $.container.Addresses "Port" $port | first }}
|
||||
{{- if and $addr_obj $addr_obj.HostPort }}
|
||||
# /!\ WARNING: Virtual port published on host. Clients
|
||||
# might be able to bypass nginx-proxy and
|
||||
# access the container's server directly.
|
||||
{{- end }}
|
||||
{{- $_ := set $ "port" $port }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "ssl_policy" }}
|
||||
{{- if eq .ssl_policy "Mozilla-Modern" }}
|
||||
ssl_protocols TLSv1.3;
|
||||
{{- /*
|
||||
* nginx currently lacks ability to choose ciphers in TLS 1.3 in
|
||||
* configuration; see https://trac.nginx.org/nginx/ticket/1529. A
|
||||
* possible workaround can be modify /etc/ssl/openssl.cnf to change
|
||||
* it globally (see
|
||||
* https://trac.nginx.org/nginx/ticket/1529#comment:12). Explicitly
|
||||
* set ngnix default value in order to allow single servers to
|
||||
* override the global http value.
|
||||
*/}}
|
||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
ssl_prefer_server_ciphers off;
|
||||
{{- else if eq .ssl_policy "Mozilla-Intermediate" }}
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384';
|
||||
ssl_prefer_server_ciphers off;
|
||||
{{- else if eq .ssl_policy "Mozilla-Old" }}
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA';
|
||||
ssl_prefer_server_ciphers on;
|
||||
{{- else if eq .ssl_policy "AWS-TLS-1-2-2017-01" }}
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES128-SHA256:AES256-GCM-SHA384:AES256-SHA256';
|
||||
ssl_prefer_server_ciphers on;
|
||||
{{- else if eq .ssl_policy "AWS-TLS-1-1-2017-01" }}
|
||||
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA';
|
||||
ssl_prefer_server_ciphers on;
|
||||
{{- else if eq .ssl_policy "AWS-2016-08" }}
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA';
|
||||
ssl_prefer_server_ciphers on;
|
||||
{{- else if eq .ssl_policy "AWS-2015-05" }}
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:DES-CBC3-SHA';
|
||||
ssl_prefer_server_ciphers on;
|
||||
{{- else if eq .ssl_policy "AWS-2015-03" }}
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:DHE-DSS-AES128-SHA:DES-CBC3-SHA';
|
||||
ssl_prefer_server_ciphers on;
|
||||
{{- else if eq .ssl_policy "AWS-2015-02" }}
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:DHE-DSS-AES128-SHA';
|
||||
ssl_prefer_server_ciphers on;
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "location" }}
|
||||
{{- $override := printf "/etc/nginx/vhost.d/%s_%s_location_override" .Host (sha1 .Path) }}
|
||||
{{- if and (eq .Path "/") (not (exists $override)) }}
|
||||
{{- $override = printf "/etc/nginx/vhost.d/%s_location_override" .Host }}
|
||||
{{- end }}
|
||||
{{- if exists $override }}
|
||||
include {{ $override }};
|
||||
{{- else }}
|
||||
{{- $keepalive := first (keys (groupByLabel .Containers "com.github.nginx-proxy.nginx-proxy.keepalive")) }}
|
||||
location {{ .Path }} {
|
||||
{{- if eq .NetworkTag "internal" }}
|
||||
# Only allow traffic from internal clients
|
||||
include /etc/nginx/network_internal.conf;
|
||||
{{- end }}
|
||||
|
||||
{{- if eq .Proto "uwsgi" }}
|
||||
include uwsgi_params;
|
||||
uwsgi_pass {{ trim .Proto }}://{{ trim .Upstream }};
|
||||
{{- else if eq .Proto "fastcgi" }}
|
||||
root {{ trim .VhostRoot }};
|
||||
include fastcgi_params;
|
||||
fastcgi_pass {{ trim .Upstream }};
|
||||
{{- if $keepalive }}
|
||||
fastcgi_keep_conn on;
|
||||
{{- end }}
|
||||
{{- else if eq .Proto "grpc" }}
|
||||
grpc_pass {{ trim .Proto }}://{{ trim .Upstream }};
|
||||
{{- else }}
|
||||
proxy_pass {{ trim .Proto }}://{{ trim .Upstream }}{{ trim .Dest }};
|
||||
set $upstream_keepalive {{ if $keepalive }}true{{ else }}false{{ end }};
|
||||
{{- end }}
|
||||
|
||||
{{- if (exists (printf "/etc/nginx/htpasswd/%s" .Host)) }}
|
||||
auth_basic "Restricted {{ .Host }}";
|
||||
auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" .Host) }};
|
||||
{{- end }}
|
||||
|
||||
{{- if (exists (printf "/etc/nginx/vhost.d/%s_%s_location" .Host (sha1 .Path) )) }}
|
||||
include {{ printf "/etc/nginx/vhost.d/%s_%s_location" .Host (sha1 .Path) }};
|
||||
{{- else if (exists (printf "/etc/nginx/vhost.d/%s_location" .Host)) }}
|
||||
include {{ printf "/etc/nginx/vhost.d/%s_location" .Host}};
|
||||
{{- else if (exists "/etc/nginx/vhost.d/default_location") }}
|
||||
include /etc/nginx/vhost.d/default_location;
|
||||
{{- end }}
|
||||
}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "upstream" }}
|
||||
upstream {{ .Upstream }} {
|
||||
{{- $server_found := false }}
|
||||
{{- $loadbalance := first (keys (groupByLabel .Containers "com.github.nginx-proxy.nginx-proxy.loadbalance")) }}
|
||||
{{- if $loadbalance }}
|
||||
# From the container's loadbalance label:
|
||||
{{ $loadbalance }}
|
||||
{{- end }}
|
||||
{{- range $container := .Containers }}
|
||||
# Container: {{ $container.Name }}
|
||||
{{- $args := dict "globals" $.globals "container" $container }}
|
||||
{{- template "container_ip" $args }}
|
||||
{{- $ip := $args.ip }}
|
||||
{{- $args := dict "container" $container }}
|
||||
{{- template "container_port" $args }}
|
||||
{{- $port := $args.port }}
|
||||
{{- if $ip }}
|
||||
{{- $server_found = true }}
|
||||
server {{ $ip }}:{{ $port }};
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- /* nginx-proxy/nginx-proxy#1105 */}}
|
||||
{{- if not $server_found }}
|
||||
# Fallback entry
|
||||
server 127.0.0.1 down;
|
||||
{{- end }}
|
||||
{{- $keepalive := first (keys (groupByLabel .Containers "com.github.nginx-proxy.nginx-proxy.keepalive")) }}
|
||||
{{- if $keepalive }}
|
||||
keepalive {{ $keepalive }};
|
||||
{{- end }}
|
||||
}
|
||||
{{- end }}
|
||||
|
||||
# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
|
||||
# scheme used to connect to this server
|
||||
map $http_x_forwarded_proto $proxy_x_forwarded_proto {
|
||||
default $http_x_forwarded_proto;
|
||||
'' $scheme;
|
||||
default {{ if $globals.trust_downstream_proxy }}$http_x_forwarded_proto{{ else }}$scheme{{ end }};
|
||||
'' $scheme;
|
||||
}
|
||||
|
||||
# If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any
|
||||
# Connection header that may have been passed to this server
|
||||
map $http_x_forwarded_host $proxy_x_forwarded_host {
|
||||
default {{ if $globals.trust_downstream_proxy }}$http_x_forwarded_host{{ else }}$http_host{{ end }};
|
||||
'' $http_host;
|
||||
}
|
||||
|
||||
# If we receive X-Forwarded-Port, pass it through; otherwise, pass along the
|
||||
# server port the client connected to
|
||||
map $http_x_forwarded_port $proxy_x_forwarded_port {
|
||||
default {{ if $globals.trust_downstream_proxy }}$http_x_forwarded_port{{ else }}$server_port{{ end }};
|
||||
'' $server_port;
|
||||
}
|
||||
|
||||
# If the request from the downstream client has an "Upgrade:" header (set to any
|
||||
# non-empty value), pass "Connection: upgrade" to the upstream (backend) server.
|
||||
# Otherwise, the value for the "Connection" header depends on whether the user
|
||||
# has enabled keepalive to the upstream server.
|
||||
map $http_upgrade $proxy_connection {
|
||||
default upgrade;
|
||||
'' close;
|
||||
default upgrade;
|
||||
'' $proxy_connection_noupgrade;
|
||||
}
|
||||
map $upstream_keepalive $proxy_connection_noupgrade {
|
||||
# Preserve nginx's default behavior (send "Connection: close").
|
||||
default close;
|
||||
# Use an empty string to cancel nginx's default behavior.
|
||||
true '';
|
||||
}
|
||||
# Abuse the map directive (see <https://stackoverflow.com/q/14433309>) to ensure
|
||||
# that $upstream_keepalive is always defined. This is necessary because:
|
||||
# - The $proxy_connection variable is indirectly derived from
|
||||
# $upstream_keepalive, so $upstream_keepalive must be defined whenever
|
||||
# $proxy_connection is resolved.
|
||||
# - The $proxy_connection variable is used in a proxy_set_header directive in
|
||||
# the http block, so it is always fully resolved for every request -- even
|
||||
# those where proxy_pass is not used (e.g., unknown virtual host).
|
||||
map "" $upstream_keepalive {
|
||||
# The value here should not matter because it should always be overridden in
|
||||
# a location block (see the "location" template) for all requests where the
|
||||
# value actually matters.
|
||||
default false;
|
||||
}
|
||||
|
||||
# Apply fix for very long server names
|
||||
server_names_hash_bucket_size 128;
|
||||
|
||||
# Default dhparam
|
||||
{{- if (exists "/etc/nginx/dhparam/dhparam.pem") }}
|
||||
ssl_dhparam /etc/nginx/dhparam/dhparam.pem;
|
||||
{{- end }}
|
||||
|
||||
# Set appropriate X-Forwarded-Ssl header based on $proxy_x_forwarded_proto
|
||||
map $proxy_x_forwarded_proto $proxy_x_forwarded_ssl {
|
||||
default off;
|
||||
https on;
|
||||
}
|
||||
|
||||
gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
log_format vhost '$host $remote_addr - $remote_user [$time_local] '
|
||||
'"$request" $status $body_bytes_sent '
|
||||
'"$http_referer" "$http_user_agent"';
|
||||
log_format vhost '{{ or $globals.Env.LOG_FORMAT "$host $remote_addr - $remote_user [$time_local] \"$request\" $status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$upstream_addr\"" }}';
|
||||
|
||||
access_log off;
|
||||
|
||||
{{ if (exists "/etc/nginx/proxy.conf") }}
|
||||
{{- template "ssl_policy" (dict "ssl_policy" $globals.ssl_policy) }}
|
||||
error_log /dev/stderr;
|
||||
|
||||
{{- if $globals.Env.RESOLVERS }}
|
||||
resolver {{ $globals.Env.RESOLVERS }};
|
||||
{{- end }}
|
||||
|
||||
{{- if (exists "/etc/nginx/proxy.conf") }}
|
||||
include /etc/nginx/proxy.conf;
|
||||
{{ else }}
|
||||
{{- else }}
|
||||
# HTTP 1.1 support
|
||||
proxy_http_version 1.1;
|
||||
proxy_buffering off;
|
||||
@ -50,188 +337,291 @@ proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $proxy_connection;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Host $proxy_x_forwarded_host;
|
||||
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
|
||||
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
|
||||
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
|
||||
proxy_set_header X-Original-URI $request_uri;
|
||||
|
||||
# Mitigate httpoxy attack (see README for details)
|
||||
proxy_set_header Proxy "";
|
||||
{{ end }}
|
||||
{{- end }}
|
||||
|
||||
{{- /*
|
||||
* Precompute some information about each vhost. This is done early because
|
||||
* the creation of fallback servers depends on DEFAULT_HOST, HTTPS_METHOD,
|
||||
* and whether there are any missing certs.
|
||||
*/}}
|
||||
{{- range $vhost, $containers := groupByMulti $globals.containers "Env.VIRTUAL_HOST" "," }}
|
||||
{{- $vhost := trim $vhost }}
|
||||
{{- if not $vhost }}
|
||||
{{- /* Ignore containers with VIRTUAL_HOST set to the empty string. */}}
|
||||
{{- continue }}
|
||||
{{- end }}
|
||||
{{- $certName := first (groupByKeys $containers "Env.CERT_NAME") }}
|
||||
{{- $vhostCert := closest (dir "/etc/nginx/certs") (printf "%s.crt" $vhost) }}
|
||||
{{- $vhostCert = trimSuffix ".crt" $vhostCert }}
|
||||
{{- $vhostCert = trimSuffix ".key" $vhostCert }}
|
||||
{{- $cert := or $certName $vhostCert }}
|
||||
{{- $cert_ok := and (ne $cert "") (exists (printf "/etc/nginx/certs/%s.crt" $cert)) (exists (printf "/etc/nginx/certs/%s.key" $cert)) }}
|
||||
{{- $default := eq $globals.Env.DEFAULT_HOST $vhost }}
|
||||
{{- $https_method := or (first (groupByKeys $containers "Env.HTTPS_METHOD")) $globals.Env.HTTPS_METHOD "redirect" }}
|
||||
{{- $_ := set $globals.vhosts $vhost (dict "cert" $cert "cert_ok" $cert_ok "containers" $containers "default" $default "https_method" $https_method) }}
|
||||
{{- end }}
|
||||
|
||||
{{- /*
|
||||
* If needed, create a catch-all fallback server to send an error code to
|
||||
* clients that request something from an unknown vhost.
|
||||
*/}}
|
||||
{{- block "fallback_server" $globals }}
|
||||
{{- $globals := . }}
|
||||
{{- $http_exists := false }}
|
||||
{{- $https_exists := false }}
|
||||
{{- $default_http_exists := false }}
|
||||
{{- $default_https_exists := false }}
|
||||
{{- range $vhost := $globals.vhosts }}
|
||||
{{- $http := or (ne $vhost.https_method "nohttp") (not $vhost.cert_ok) }}
|
||||
{{- $https := ne $vhost.https_method "nohttps" }}
|
||||
{{- $http_exists = or $http_exists $http }}
|
||||
{{- $https_exists = or $https_exists $https }}
|
||||
{{- $default_http_exists = or $default_http_exists (and $http $vhost.default) }}
|
||||
{{- $default_https_exists = or $default_https_exists (and $https $vhost.default) }}
|
||||
{{- end }}
|
||||
{{- $fallback_http := and $http_exists (not $default_http_exists) }}
|
||||
{{- $fallback_https := and $https_exists (not $default_https_exists) }}
|
||||
{{- /*
|
||||
* If there are no vhosts at all, create fallbacks for both plain http
|
||||
* and https so that clients get something more useful than a connection
|
||||
* refused error.
|
||||
*/}}
|
||||
{{- if and (not $http_exists) (not $https_exists) }}
|
||||
{{- $fallback_http = true }}
|
||||
{{- $fallback_https = true }}
|
||||
{{- end }}
|
||||
{{- if or $fallback_http $fallback_https }}
|
||||
server {
|
||||
server_name _; # This is just an invalid value which will never trigger on a real hostname.
|
||||
server_tokens off;
|
||||
{{- if $fallback_http }}
|
||||
listen {{ $globals.external_http_port }} default_server;
|
||||
{{- if $globals.enable_ipv6 }}
|
||||
listen [::]:{{ $globals.external_http_port }} default_server;
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if $fallback_https }}
|
||||
listen {{ $globals.external_https_port }} ssl http2 default_server;
|
||||
{{- if $globals.enable_ipv6 }}
|
||||
listen [::]:{{ $globals.external_https_port }} ssl http2 default_server;
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{ $globals.access_log }}
|
||||
{{- if $globals.default_cert_ok }}
|
||||
ssl_session_cache shared:SSL:50m;
|
||||
ssl_session_tickets off;
|
||||
ssl_certificate /etc/nginx/certs/default.crt;
|
||||
ssl_certificate_key /etc/nginx/certs/default.key;
|
||||
{{- else }}
|
||||
# No default.crt certificate found for this vhost, so force nginx to emit a
|
||||
# TLS error if the client connects via https.
|
||||
{{- /* See the comment in the main `server` directive for rationale. */}}
|
||||
ssl_ciphers aNULL;
|
||||
set $empty "";
|
||||
ssl_certificate data:$empty;
|
||||
ssl_certificate_key data:$empty;
|
||||
if ($https) {
|
||||
return 444;
|
||||
}
|
||||
{{- end }}
|
||||
return 503;
|
||||
}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- range $host, $vhost := $globals.vhosts }}
|
||||
{{- $cert := $vhost.cert }}
|
||||
{{- $cert_ok := $vhost.cert_ok }}
|
||||
{{- $containers := $vhost.containers }}
|
||||
{{- $default_server := when $vhost.default "default_server" "" }}
|
||||
{{- $https_method := $vhost.https_method }}
|
||||
|
||||
{{- $is_regexp := hasPrefix "~" $host }}
|
||||
{{- $upstream_name := when (or $is_regexp $globals.sha1_upstream_name) (sha1 $host) $host }}
|
||||
|
||||
{{- $paths := groupBy $containers "Env.VIRTUAL_PATH" }}
|
||||
{{- $nPaths := len $paths }}
|
||||
{{- if eq $nPaths 0 }}
|
||||
{{- $paths = dict "/" $containers }}
|
||||
{{- end }}
|
||||
|
||||
{{- range $path, $containers := $paths }}
|
||||
{{- $upstream := $upstream_name }}
|
||||
{{- if gt $nPaths 0 }}
|
||||
{{- $sum := sha1 $path }}
|
||||
{{- $upstream = printf "%s-%s" $upstream $sum }}
|
||||
{{- end }}
|
||||
# {{ $host }}{{ $path }}
|
||||
{{ template "upstream" (dict "globals" $globals "Upstream" $upstream "Containers" $containers) }}
|
||||
{{- end }}
|
||||
|
||||
{{- /*
|
||||
* Get the SERVER_TOKENS defined by containers w/ the same vhost,
|
||||
* falling back to "".
|
||||
*/}}
|
||||
{{- $server_tokens := trim (or (first (groupByKeys $containers "Env.SERVER_TOKENS")) "") }}
|
||||
|
||||
{{- /*
|
||||
* Get the SSL_POLICY defined by containers w/ the same vhost, falling
|
||||
* back to empty string (use default).
|
||||
*/}}
|
||||
{{- $ssl_policy := or (first (groupByKeys $containers "Env.SSL_POLICY")) "" }}
|
||||
|
||||
{{- /*
|
||||
* Get the HSTS defined by containers w/ the same vhost, falling back to
|
||||
* "max-age=31536000".
|
||||
*/}}
|
||||
{{- $hsts := or (first (groupByKeys $containers "Env.HSTS")) (or $globals.Env.HSTS "max-age=31536000") }}
|
||||
|
||||
{{- /* Get the VIRTUAL_ROOT By containers w/ use fastcgi root */}}
|
||||
{{- $vhost_root := or (first (groupByKeys $containers "Env.VIRTUAL_ROOT")) "/var/www/public" }}
|
||||
|
||||
{{- if and $cert_ok (eq $https_method "redirect") }}
|
||||
server {
|
||||
server_name {{ $host }};
|
||||
{{- if $server_tokens }}
|
||||
server_tokens {{ $server_tokens }};
|
||||
{{- end }}
|
||||
listen {{ $globals.external_http_port }} {{ $default_server }};
|
||||
{{- if $globals.enable_ipv6 }}
|
||||
listen [::]:{{ $globals.external_http_port }} {{ $default_server }};
|
||||
{{- end }}
|
||||
{{ $globals.access_log }}
|
||||
|
||||
# Do not HTTPS redirect Let's Encrypt ACME challenge
|
||||
location ^~ /.well-known/acme-challenge/ {
|
||||
auth_basic off;
|
||||
auth_request off;
|
||||
allow all;
|
||||
root /usr/share/nginx/html;
|
||||
try_files $uri =404;
|
||||
break;
|
||||
}
|
||||
|
||||
location / {
|
||||
{{- if eq $globals.external_https_port "443" }}
|
||||
return 301 https://$host$request_uri;
|
||||
{{- else }}
|
||||
return 301 https://$host:{{ $globals.external_https_port }}$request_uri;
|
||||
{{- end }}
|
||||
}
|
||||
}
|
||||
{{- end }}
|
||||
|
||||
server {
|
||||
server_name _; # This is just an invalid value which will never trigger on a real hostname.
|
||||
listen 80;
|
||||
access_log /var/log/nginx/access.log vhost;
|
||||
return 503;
|
||||
server_name {{ $host }};
|
||||
{{- if $server_tokens }}
|
||||
server_tokens {{ $server_tokens }};
|
||||
{{- end }}
|
||||
{{ $globals.access_log }}
|
||||
{{- if or (eq $https_method "nohttps") (not $cert_ok) (eq $https_method "noredirect") }}
|
||||
listen {{ $globals.external_http_port }} {{ $default_server }};
|
||||
{{- if $globals.enable_ipv6 }}
|
||||
listen [::]:{{ $globals.external_http_port }} {{ $default_server }};
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if ne $https_method "nohttps" }}
|
||||
listen {{ $globals.external_https_port }} ssl http2 {{ $default_server }};
|
||||
{{- if $globals.enable_ipv6 }}
|
||||
listen [::]:{{ $globals.external_https_port }} ssl http2 {{ $default_server }};
|
||||
{{- end }}
|
||||
|
||||
{{- if $cert_ok }}
|
||||
{{- template "ssl_policy" (dict "ssl_policy" $ssl_policy) }}
|
||||
|
||||
ssl_session_timeout 5m;
|
||||
ssl_session_cache shared:SSL:50m;
|
||||
ssl_session_tickets off;
|
||||
|
||||
ssl_certificate /etc/nginx/certs/{{ (printf "%s.crt" $cert) }};
|
||||
ssl_certificate_key /etc/nginx/certs/{{ (printf "%s.key" $cert) }};
|
||||
|
||||
{{- if (exists (printf "/etc/nginx/certs/%s.dhparam.pem" $cert)) }}
|
||||
ssl_dhparam {{ printf "/etc/nginx/certs/%s.dhparam.pem" $cert }};
|
||||
{{- end }}
|
||||
|
||||
{{- if (exists (printf "/etc/nginx/certs/%s.chain.pem" $cert)) }}
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
ssl_trusted_certificate {{ printf "/etc/nginx/certs/%s.chain.pem" $cert }};
|
||||
{{- end }}
|
||||
|
||||
{{- if (not (or (eq $https_method "noredirect") (eq $hsts "off"))) }}
|
||||
set $sts_header "";
|
||||
if ($https) {
|
||||
set $sts_header "{{ trim $hsts }}";
|
||||
}
|
||||
add_header Strict-Transport-Security $sts_header always;
|
||||
{{- end }}
|
||||
{{- else if $globals.default_cert_ok }}
|
||||
# No certificate found for this vhost, so use the default certificate and
|
||||
# return an error code if the user connects via https.
|
||||
ssl_certificate /etc/nginx/certs/default.crt;
|
||||
ssl_certificate_key /etc/nginx/certs/default.key;
|
||||
if ($https) {
|
||||
return 500;
|
||||
}
|
||||
{{- else }}
|
||||
# No certificate found for this vhost, so force nginx to emit a TLS error if
|
||||
# the client connects via https.
|
||||
{{- /*
|
||||
* The alternative is to not provide an https server for this
|
||||
* vhost, which would either cause the user to see the wrong
|
||||
* vhost (if there is another vhost with a certificate) or a
|
||||
* connection refused error (if there is no other vhost with a
|
||||
* certificate). A TLS error is easier to troubleshoot, and is
|
||||
* safer than serving the wrong vhost. Also see
|
||||
* <https://serverfault.com/a/1044022>.
|
||||
*/}}
|
||||
ssl_ciphers aNULL;
|
||||
set $empty "";
|
||||
ssl_certificate data:$empty;
|
||||
ssl_certificate_key data:$empty;
|
||||
if ($https) {
|
||||
return 444;
|
||||
}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- if (exists (printf "/etc/nginx/vhost.d/%s" $host)) }}
|
||||
include {{ printf "/etc/nginx/vhost.d/%s" $host }};
|
||||
{{- else if (exists "/etc/nginx/vhost.d/default") }}
|
||||
include /etc/nginx/vhost.d/default;
|
||||
{{- end }}
|
||||
|
||||
{{- range $path, $containers := $paths }}
|
||||
{{- /*
|
||||
* Get the VIRTUAL_PROTO defined by containers w/ the same
|
||||
* vhost-vpath, falling back to "http".
|
||||
*/}}
|
||||
{{- $proto := trim (or (first (groupByKeys $containers "Env.VIRTUAL_PROTO")) "http") }}
|
||||
|
||||
{{- /*
|
||||
* Get the NETWORK_ACCESS defined by containers w/ the same vhost,
|
||||
* falling back to "external".
|
||||
*/}}
|
||||
{{- $network_tag := or (first (groupByKeys $containers "Env.NETWORK_ACCESS")) "external" }}
|
||||
{{- $upstream := $upstream_name }}
|
||||
{{- $dest := "" }}
|
||||
{{- if gt $nPaths 0 }}
|
||||
{{- $sum := sha1 $path }}
|
||||
{{- $upstream = printf "%s-%s" $upstream $sum }}
|
||||
{{- $dest = (or (first (groupByKeys $containers "Env.VIRTUAL_DEST")) "") }}
|
||||
{{- end }}
|
||||
{{- template "location" (dict "Path" $path "Proto" $proto "Upstream" $upstream "Host" $host "VhostRoot" $vhost_root "Dest" $dest "NetworkTag" $network_tag "Containers" $containers) }}
|
||||
{{- end }}
|
||||
{{- if and (not (contains $paths "/")) (ne $globals.default_root_response "none")}}
|
||||
location / {
|
||||
return {{ $globals.default_root_response }};
|
||||
}
|
||||
{{- end }}
|
||||
}
|
||||
|
||||
{{ if (and (exists "/etc/nginx/certs/default.crt") (exists "/etc/nginx/certs/default.key")) }}
|
||||
server {
|
||||
server_name _; # This is just an invalid value which will never trigger on a real hostname.
|
||||
listen 443 ssl http2;
|
||||
access_log /var/log/nginx/access.log vhost;
|
||||
return 503;
|
||||
|
||||
ssl_session_tickets off;
|
||||
ssl_certificate /etc/nginx/certs/default.crt;
|
||||
ssl_certificate_key /etc/nginx/certs/default.key;
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
{{ range $host, $containers := groupByMulti $ "Env.VIRTUAL_HOST" "," }}
|
||||
|
||||
upstream {{ $host }} {
|
||||
{{ range $container := $containers }}
|
||||
{{ $addrLen := len $container.Addresses }}
|
||||
|
||||
{{ range $knownNetwork := $CurrentContainer.Networks }}
|
||||
{{ range $containerNetwork := $container.Networks }}
|
||||
{{ if eq $knownNetwork.Name $containerNetwork.Name }}
|
||||
## Can be connect with "{{ $containerNetwork.Name }}" network
|
||||
|
||||
{{/* If only 1 port exposed, use that */}}
|
||||
{{ if eq $addrLen 1 }}
|
||||
{{ $address := index $container.Addresses 0 }}
|
||||
{{ template "upstream" (dict "Container" $container "Address" $address "Network" $containerNetwork) }}
|
||||
{{/* If more than one port exposed, use the one matching VIRTUAL_PORT env var, falling back to standard web port 80 */}}
|
||||
{{ else }}
|
||||
{{ $port := coalesce $container.Env.VIRTUAL_PORT "80" }}
|
||||
{{ $address := where $container.Addresses "Port" $port | first }}
|
||||
{{ template "upstream" (dict "Container" $container "Address" $address "Network" $containerNetwork) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
}
|
||||
|
||||
{{ $default_host := or ($.Env.DEFAULT_HOST) "" }}
|
||||
{{ $default_server := index (dict $host "" $default_host "default_server") $host }}
|
||||
|
||||
{{/* Get the VIRTUAL_PROTO defined by containers w/ the same vhost, falling back to "http" */}}
|
||||
{{ $proto := or (first (groupByKeys $containers "Env.VIRTUAL_PROTO")) "http" }}
|
||||
|
||||
{{/* Get the HTTPS_METHOD defined by containers w/ the same vhost, falling back to "redirect" */}}
|
||||
{{ $https_method := or (first (groupByKeys $containers "Env.HTTPS_METHOD")) "redirect" }}
|
||||
|
||||
{{/* Get the first cert name defined by containers w/ the same vhost */}}
|
||||
{{ $certName := (first (groupByKeys $containers "Env.CERT_NAME")) }}
|
||||
|
||||
{{/* Get the best matching cert by name for the vhost. */}}
|
||||
{{ $vhostCert := (closest (dir "/etc/nginx/certs") (printf "%s.crt" $host))}}
|
||||
|
||||
{{/* vhostCert is actually a filename so remove any suffixes since they are added later */}}
|
||||
{{ $vhostCert := trimSuffix ".crt" $vhostCert }}
|
||||
{{ $vhostCert := trimSuffix ".key" $vhostCert }}
|
||||
|
||||
{{/* Use the cert specified on the container or fallback to the best vhost match */}}
|
||||
{{ $cert := (coalesce $certName $vhostCert) }}
|
||||
|
||||
{{ $is_https := (and (ne $cert "") (exists (printf "/etc/nginx/certs/%s.crt" $cert)) (exists (printf "/etc/nginx/certs/%s.key" $cert))) }}
|
||||
|
||||
{{ if $is_https }}
|
||||
|
||||
{{ if eq $https_method "redirect" }}
|
||||
server {
|
||||
server_name {{ $host }};
|
||||
listen 80 {{ $default_server }};
|
||||
access_log /var/log/nginx/access.log vhost;
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
server {
|
||||
server_name {{ $host }};
|
||||
listen 443 ssl http2 {{ $default_server }};
|
||||
access_log /var/log/nginx/access.log vhost;
|
||||
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
||||
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
|
||||
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_session_timeout 5m;
|
||||
ssl_session_cache shared:SSL:50m;
|
||||
ssl_session_tickets off;
|
||||
|
||||
ssl_certificate /etc/nginx/certs/{{ (printf "%s.crt" $cert) }};
|
||||
ssl_certificate_key /etc/nginx/certs/{{ (printf "%s.key" $cert) }};
|
||||
|
||||
{{ if (exists (printf "/etc/nginx/certs/%s.dhparam.pem" $cert)) }}
|
||||
ssl_dhparam {{ printf "/etc/nginx/certs/%s.dhparam.pem" $cert }};
|
||||
{{ end }}
|
||||
|
||||
{{ if (ne $https_method "noredirect") }}
|
||||
add_header Strict-Transport-Security "max-age=31536000";
|
||||
{{ end }}
|
||||
|
||||
{{ if (exists (printf "/etc/nginx/vhost.d/%s" $host)) }}
|
||||
include {{ printf "/etc/nginx/vhost.d/%s" $host }};
|
||||
{{ else if (exists "/etc/nginx/vhost.d/default") }}
|
||||
include /etc/nginx/vhost.d/default;
|
||||
{{ end }}
|
||||
|
||||
location / {
|
||||
{{ if eq $proto "uwsgi" }}
|
||||
include uwsgi_params;
|
||||
uwsgi_pass {{ trim $proto }}://{{ trim $host }};
|
||||
{{ else }}
|
||||
proxy_pass {{ trim $proto }}://{{ trim $host }};
|
||||
{{ end }}
|
||||
{{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
|
||||
auth_basic "Restricted {{ $host }}";
|
||||
auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};
|
||||
{{ end }}
|
||||
{{ if (exists (printf "/etc/nginx/vhost.d/%s_location" $host)) }}
|
||||
include {{ printf "/etc/nginx/vhost.d/%s_location" $host}};
|
||||
{{ else if (exists "/etc/nginx/vhost.d/default_location") }}
|
||||
include /etc/nginx/vhost.d/default_location;
|
||||
{{ end }}
|
||||
}
|
||||
}
|
||||
|
||||
{{ end }}
|
||||
|
||||
{{ if or (not $is_https) (eq $https_method "noredirect") }}
|
||||
|
||||
server {
|
||||
server_name {{ $host }};
|
||||
listen 80 {{ $default_server }};
|
||||
access_log /var/log/nginx/access.log vhost;
|
||||
|
||||
{{ if (exists (printf "/etc/nginx/vhost.d/%s" $host)) }}
|
||||
include {{ printf "/etc/nginx/vhost.d/%s" $host }};
|
||||
{{ else if (exists "/etc/nginx/vhost.d/default") }}
|
||||
include /etc/nginx/vhost.d/default;
|
||||
{{ end }}
|
||||
|
||||
location / {
|
||||
{{ if eq $proto "uwsgi" }}
|
||||
include uwsgi_params;
|
||||
uwsgi_pass {{ trim $proto }}://{{ trim $host }};
|
||||
{{ else }}
|
||||
proxy_pass {{ trim $proto }}://{{ trim $host }};
|
||||
{{ end }}
|
||||
{{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
|
||||
auth_basic "Restricted {{ $host }}";
|
||||
auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};
|
||||
{{ end }}
|
||||
{{ if (exists (printf "/etc/nginx/vhost.d/%s_location" $host)) }}
|
||||
include {{ printf "/etc/nginx/vhost.d/%s_location" $host}};
|
||||
{{ else if (exists "/etc/nginx/vhost.d/default_location") }}
|
||||
include /etc/nginx/vhost.d/default_location;
|
||||
{{ end }}
|
||||
}
|
||||
}
|
||||
|
||||
{{ if (and (not $is_https) (exists "/etc/nginx/certs/default.crt") (exists "/etc/nginx/certs/default.key")) }}
|
||||
server {
|
||||
server_name {{ $host }};
|
||||
listen 443 ssl http2 {{ $default_server }};
|
||||
access_log /var/log/nginx/access.log vhost;
|
||||
return 500;
|
||||
|
||||
ssl_certificate /etc/nginx/certs/default.crt;
|
||||
ssl_certificate_key /etc/nginx/certs/default.key;
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{- end }}
|
||||
|
||||
115
test/README.md
115
test/README.md
@ -1,14 +1,101 @@
|
||||
Test suite
|
||||
==========
|
||||
|
||||
This test suite is implemented on top of the [Bats](https://github.com/sstephenson/bats/blob/master/README.md) test framework.
|
||||
|
||||
It is intended to verify the correct behavior of the Docker image `jwilder/nginx-proxy:bats`.
|
||||
|
||||
Running the test suite
|
||||
----------------------
|
||||
|
||||
Make sure you have Bats installed, then run:
|
||||
|
||||
docker build -t jwilder/nginx-proxy:bats .
|
||||
bats test/
|
||||
Nginx proxy test suite
|
||||
======================
|
||||
|
||||
Install requirements
|
||||
--------------------
|
||||
|
||||
You need [python 3.9](https://www.python.org/) and [pip](https://pip.pypa.io/en/stable/installing/) installed. Then run the commands:
|
||||
|
||||
pip install -r requirements/python-requirements.txt
|
||||
|
||||
|
||||
|
||||
Prepare the nginx-proxy test image
|
||||
----------------------------------
|
||||
|
||||
make build-nginx-proxy-test-debian
|
||||
|
||||
or if you want to test the alpine flavor:
|
||||
|
||||
make build-nginx-proxy-test-alpine
|
||||
|
||||
Run the test suite
|
||||
------------------
|
||||
|
||||
pytest
|
||||
|
||||
need more verbosity ?
|
||||
|
||||
pytest -s
|
||||
|
||||
|
||||
Run one single test module
|
||||
--------------------------
|
||||
|
||||
pytest test_nominal.py
|
||||
|
||||
|
||||
Write a test module
|
||||
-------------------
|
||||
|
||||
This test suite uses [pytest](http://doc.pytest.org/en/latest/). The [conftest.py](conftest.py) file will be automatically loaded by pytest and will provide you with two useful pytest [fixtures](https://docs.pytest.org/en/latest/explanation/fixtures.html):
|
||||
|
||||
- docker_compose
|
||||
- nginxproxy
|
||||
|
||||
|
||||
### docker_compose fixture
|
||||
|
||||
When using the `docker_compose` fixture in a test, pytest will try to find a yml file named after your test module filename. For instance, if your test module is `test_example.py`, then the `docker_compose` fixture will try to load a `test_example.yml` [docker compose file](https://docs.docker.com/compose/compose-file/).
|
||||
|
||||
Once the docker compose file found, the fixture will remove all containers, run `docker-compose up`, and finally your test will be executed.
|
||||
|
||||
The fixture will run the _docker-compose_ command with the `-f` option to load the given compose file. So you can test your docker compose file syntax by running it yourself with:
|
||||
|
||||
docker-compose -f test_example.yml up -d
|
||||
|
||||
In the case you are running pytest from within a docker container, the `docker_compose` fixture will make sure the container running pytest is attached to all docker networks. That way, your test will be able to reach any of them.
|
||||
|
||||
In your tests, you can use the `docker_compose` variable to query and command the docker daemon as it provides you with a [client from the docker python module](https://docker-py.readthedocs.io/en/4.4.4/client.html#client-reference).
|
||||
|
||||
Also this fixture alters the way the python interpreter resolves domain names to IP addresses in the following ways:
|
||||
|
||||
Any domain name containing the substring `nginx-proxy` will resolve to the IP address of the container that was created from the `nginxproxy/nginx-proxy:test` image. So all the following domain names will resolve to the nginx-proxy container in tests:
|
||||
- `nginx-proxy`
|
||||
- `nginx-proxy.com`
|
||||
- `www.nginx-proxy.com`
|
||||
- `www.nginx-proxy.test`
|
||||
- `www.nginx-proxy`
|
||||
- `whatever.nginx-proxyooooooo`
|
||||
- ...
|
||||
|
||||
Any domain name ending with `XXX.container.docker` will resolve to the IP address of the XXX container.
|
||||
- `web1.container.docker` will resolve to the IP address of the `web1` container
|
||||
- `f00.web1.container.docker` will resolve to the IP address of the `web1` container
|
||||
- `anything.whatever.web2.container.docker` will resolve to the IP address of the `web2` container
|
||||
|
||||
Otherwise, domain names are resoved as usual using your system DNS resolver.
|
||||
|
||||
|
||||
### nginxproxy fixture
|
||||
|
||||
The `nginxproxy` fixture will provide you with a replacement for the python [requests](https://pypi.python.org/pypi/requests/) module. This replacement will just repeat up to 30 times a requests if it receives the HTTP error 404 or 502. This error occurs when you try to send queries to nginx-proxy too early after the container creation.
|
||||
|
||||
Also this requests replacement is preconfigured to use the Certificate Authority root certificate [certs/ca-root.crt](certs/) to validate https connections.
|
||||
|
||||
Furthermore, the nginxproxy methods accept an additional keyword parameter: `ipv6` which forces requests made against containers to use the containers IPv6 address when set to `True`. If IPv6 is not supported by the system or docker, that particular test will be skipped.
|
||||
|
||||
def test_forwards_to_web1_ipv6(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://web1.nginx-proxy.tld/port", ipv6=True)
|
||||
assert r.status_code == 200
|
||||
assert r.text == "answer from port 81\n"
|
||||
|
||||
|
||||
|
||||
### The web docker image
|
||||
|
||||
When you run the `make build-webserver` command, you built a [`web`](requirements/README.md) docker image which is convenient for running a small web server in a container. This image can produce containers that listens on multiple ports at the same time.
|
||||
|
||||
### Testing TLS
|
||||
|
||||
If you need to create server certificates, use the [`certs/create_server_certificate.sh`](certs/) script. Pytest will be able to validate any certificate issued from this script.
|
||||
|
||||
81
test/certs/README.md
Normal file
81
test/certs/README.md
Normal file
@ -0,0 +1,81 @@
|
||||
create_server_certificate.sh
|
||||
============================
|
||||
|
||||
`create_server_certificate.sh` is a script helping with issuing server certificates that can be used to provide TLS on web servers.
|
||||
|
||||
It also creates a Certificate Authority (CA) root key and certificate. This CA root certificate can be used to validate the server certificates it generates.
|
||||
|
||||
For instance, with _curl_:
|
||||
|
||||
curl --cacert /somewhere/ca-root.crt https://www.example.com/
|
||||
|
||||
or with _wget_:
|
||||
|
||||
wget --certificate=/somewhere/ca-root.crt https://www.example.com/
|
||||
|
||||
or with the python _requests_ module:
|
||||
|
||||
import requests
|
||||
r = requests.get("https://www.example.com", verify="/somewhere/ca-root.crt")
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
### Simple domain
|
||||
|
||||
Create a server certificate for domain `www.example.com`:
|
||||
|
||||
./create_server_certificate.sh www.example.com
|
||||
|
||||
Will produce:
|
||||
- `www.example.com.key`
|
||||
- `www.example.com.crt`
|
||||
|
||||
|
||||
### Multiple domains
|
||||
|
||||
Create a server certificate for main domain `www.example.com` and alternative domains `example.com`, `foo.com` and `bar.com`:
|
||||
|
||||
./create_server_certificate.sh www.example.com foo.com bar.com
|
||||
|
||||
Will produce:
|
||||
- `www.example.com.key`
|
||||
- `www.example.com.crt`
|
||||
|
||||
### Wildcard domain
|
||||
|
||||
Create a server certificate for wildcard domain `*.example.com`:
|
||||
|
||||
./create_server_certificate.sh "*.example.com"
|
||||
|
||||
Note that you need to use quotes around the domain string or the shell would expand `*`.
|
||||
|
||||
Will produce:
|
||||
- `*.example.com.key`
|
||||
- `*.example.com.crt`
|
||||
|
||||
Again, to prevent your shell from expanding `*`, use quotes. i.e.: `cat "*.example.com.crt"`.
|
||||
|
||||
Such a server certificate would be valid for domains:
|
||||
- `foo.example.com`
|
||||
- `bar.example.com`
|
||||
|
||||
but not for domains:
|
||||
- `example.com`
|
||||
- `foo.bar.example.com`
|
||||
|
||||
|
||||
### Wildcard domain on multiple levels
|
||||
|
||||
While you can technically create a server certificate for wildcard domain `*.example.com` and alternative name `*.*.example.com`, client implementations generally do not support multiple wildcards in a domain name.
|
||||
|
||||
For instance, a python script using urllib3 would fail to validate domain `foo.bar.example.com` presenting a certificate with name `*.*.example.com`. It is advised to stay away from producing such certificates.
|
||||
|
||||
If you want to give it a try:
|
||||
|
||||
./create_server_certificate.sh "*.example.com" "*.*.example.com"
|
||||
|
||||
Such a server certificate would be valid for domains:
|
||||
- `foo.example.com`
|
||||
- `bar.example.com`
|
||||
- `foo.bar.example.com`
|
||||
21
test/certs/ca-root.crt
Normal file
21
test/certs/ca-root.crt
Normal file
@ -0,0 +1,21 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDZDCCAkygAwIBAgIJAJmW6Ju6iJNNMA0GCSqGSIb3DQEBCwUAMD8xHzAdBgNV
|
||||
BAoMFm5naW54LXByb3h5IHRlc3Qgc3VpdGUxHDAaBgNVBAMME3d3dy5uZ2lueC1w
|
||||
cm94eS50bGQwHhcNMTcwMTEwMDAwODUxWhcNMjcwMTA4MDAwODUxWjA/MR8wHQYD
|
||||
VQQKDBZuZ2lueC1wcm94eSB0ZXN0IHN1aXRlMRwwGgYDVQQDDBN3d3cubmdpbngt
|
||||
cHJveHkudGxkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAndjE3OPr
|
||||
48hIOQigk/HejrowsQDLNfkkc6vej0J983rJitGTgBfxqq27fOPfqhE5bi1M5JDk
|
||||
KkrOrSitxCJLgpq+4Ls9/RXg8skZFHRAQbNwuKBehaDkPdamJ0i3dv6e4kZy41oI
|
||||
RqxQ/MKdminC4LShFZvPoKeh9ae7w1MgB2/4E68LO66bYiHlLNL7ENViSHhLyCmt
|
||||
qIE7kdV9jgn2NuVJ37m6/6SNQ3GBiIjEW+ooRQ3HEVKBCismcwq80+BD5VS/yW18
|
||||
KqX8m4sBM+IgZbcOqrV+APMbGvd8iNJgQSSQC/r0Wscgt7UeggVYKDazjDSPvLUE
|
||||
FUN5wEmydkP2AQIDAQABo2MwYTAdBgNVHQ4EFgQUJL59pHomt+8dUNxv8HgrYjKf
|
||||
OA8wHwYDVR0jBBgwFoAUJL59pHomt+8dUNxv8HgrYjKfOA8wDwYDVR0TAQH/BAUw
|
||||
AwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQELBQADggEBABALxY96YqsZ
|
||||
CL2crzY0FIGhfjLE7P3mtUGklUpFu7xyI6mGUyL1nJYSnHB5IEV6QLhVVUE/CojI
|
||||
crXorQWBDkx26AgCt/eIOdvPYC0JDeXiIhH6sld3yH7JGwGqJkfXaUUfUkuwMae7
|
||||
mMIEG9e6vfSh/YNTRxs0KBjBcXHHl5K+Dz4h9r14OqnQFqVFZaR6T6td44tDDNhn
|
||||
beW8iIfCWRqDsnvIcJzLa2QR4onmJSw5DaSeFFaKefhdHEzEBZntLfyFbjRYHT/O
|
||||
+BRdewhg6rSDkGLcL8n/ZnRLOa+xmegjQ/Op94OmWO3TfXOITJAtkaO2YVZoyek8
|
||||
T6ckVovq4zU=
|
||||
-----END CERTIFICATE-----
|
||||
27
test/certs/ca-root.key
Normal file
27
test/certs/ca-root.key
Normal file
@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEpQIBAAKCAQEAndjE3OPr48hIOQigk/HejrowsQDLNfkkc6vej0J983rJitGT
|
||||
gBfxqq27fOPfqhE5bi1M5JDkKkrOrSitxCJLgpq+4Ls9/RXg8skZFHRAQbNwuKBe
|
||||
haDkPdamJ0i3dv6e4kZy41oIRqxQ/MKdminC4LShFZvPoKeh9ae7w1MgB2/4E68L
|
||||
O66bYiHlLNL7ENViSHhLyCmtqIE7kdV9jgn2NuVJ37m6/6SNQ3GBiIjEW+ooRQ3H
|
||||
EVKBCismcwq80+BD5VS/yW18KqX8m4sBM+IgZbcOqrV+APMbGvd8iNJgQSSQC/r0
|
||||
Wscgt7UeggVYKDazjDSPvLUEFUN5wEmydkP2AQIDAQABAoIBAQCDM4zetix6lx1B
|
||||
GuSuVFrTc/vJBInkgQRFiVRi67fZS/R+CJl73WsonWO7+YUNzWdZJxpE2hJs/OUx
|
||||
lSBqaL8u/gUuszRhS3BBHdpU4BQRCF/ndpVaqVNN+z78ZDrrE9Vo63nPdCRw6gYf
|
||||
MnzhiVjMghdq6Kn6NZwvno45WrzCsIbrrQ4zU+S2PhG8MTA53jzqqQ8mUSJX0lAl
|
||||
6b9+1aWA0d0Jnk3M3doaFU/Dlnz3n6kkx0AdqNe8bdsFrPfwsrF+dwGx04SGgLmK
|
||||
V2OjIDFYYGtiHp3PJ9IYIA32ij+UloSDDZ2BxXkma8Zilw04ytY5l8tlk2ZDWTD9
|
||||
U2MXxjmBAoGBAMmmI19I/asTPjljlqzrOsrdRkklJvnCHgy/yw9u3nMfkJ0lLGAp
|
||||
mZoCqJIEsAqlLGM5bOjKy3KQ3n2SBX3mz7/RajnpJRTnNLeJIPAAXHN9TDyKcWRo
|
||||
Los6xHN7YMSLYKs4HMihXp9Yu4Ms88/8nO/01nufjN0rTgFnWdL0WfxJAoGBAMhk
|
||||
Qm92ukMmbrXSrV0WF+eFooHwgPmUWZ1oZY5ZHmO3FCuSBHiICGrWKmdbcG6H5zmZ
|
||||
oFZ0unsvk2Yjl+/+tntxr/dwp6Q+chsqkLms8GE76NWEO8qn4hQNywkFgpKlPci3
|
||||
n5IqpuQ2DpJ1PAQkwgZD/5rSscNidNMezXO5Uvv5AoGBALR291kjXcJpKlr6AbMn
|
||||
oipD9c8obMVBMNuAGh7pvjORoD7DMf+tu0XV8z8a6uHcCOmUTx/XvlP9yuDeegO/
|
||||
OVYV+NdzDDi04r0PAGdKK3NAQ6Y60Fhn1J/OLFqdpHDBu/X/9eKoaKJ7KvWumVUe
|
||||
YuVtXTauB8c4JkujTwQ4ov/hAoGAHxvhbGhkFhSbT0K7gx3w7BJE3iM2AojTOKqC
|
||||
SYzwOM6tJO5wHz4PAHbq8kyxsZcLgFenGoTYhlMmcM7JwYorThKiHKmyfL7s++ap
|
||||
vQlp785bIPp8RcO2RyK1CFuAn79jTgujjA9vBTKXJIlqncIPFOXtgl1/FzPrqvK3
|
||||
NmXoyhECgYEAje9hM9RYO0jbfmTZoQh+onMRz34SM9XWLH+NQGgfvsGtjeRnrUKK
|
||||
GuWQz/GQGJLy/Uc1KHIdrfPDjvQhZXmPL1v7pNfCrqyj+EnKCNDPPnYq5Zq4WLsB
|
||||
x1hKPH0LmfEBkXOiFGrD3h3KAuBK5nb0/EFBDR4JuMaySC5CpbOds9o=
|
||||
-----END RSA PRIVATE KEY-----
|
||||
183
test/certs/create_server_certificate.sh
Executable file
183
test/certs/create_server_certificate.sh
Executable file
@ -0,0 +1,183 @@
|
||||
#!/bin/bash
|
||||
set -u
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
if [[ "$#" -eq 0 ]]; then
|
||||
cat <<-EOF
|
||||
|
||||
To generate a server certificate, provide the domain name as a parameter:
|
||||
$(basename $0) www.my-domain.tdl
|
||||
$(basename $0) www.my-domain.tdl alternate.domain.tld
|
||||
|
||||
You can also create certificates for wildcard domains:
|
||||
$(basename $0) '*.my-domain.tdl'
|
||||
|
||||
EOF
|
||||
exit 0
|
||||
else
|
||||
DOMAIN="$1"
|
||||
ALTERNATE_DOMAINS="DNS:$( echo "$@" | sed 's/ /,DNS:/g')"
|
||||
fi
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Create a nginx container (which conveniently provides the `openssl` command)
|
||||
###############################################################################
|
||||
|
||||
CONTAINER=$(docker run -d -v $DIR:/work -w /work -e SAN="$ALTERNATE_DOMAINS" nginx:1.19.10)
|
||||
# Configure openssl
|
||||
docker exec $CONTAINER bash -c '
|
||||
mkdir -p /ca/{certs,crl,private,newcerts} 2>/dev/null
|
||||
echo 1000 > /ca/serial
|
||||
touch /ca/index.txt
|
||||
cat > /ca/openssl.cnf <<-"OESCRIPT"
|
||||
[ ca ]
|
||||
# `man ca`
|
||||
default_ca = CA_default
|
||||
|
||||
[ CA_default ]
|
||||
# Directory and file locations.
|
||||
dir = /ca
|
||||
certs = $dir/certs
|
||||
crl_dir = $dir/crl
|
||||
new_certs_dir = $dir/newcerts
|
||||
database = $dir/index.txt
|
||||
serial = $dir/serial
|
||||
RANDFILE = $dir/private/.rand
|
||||
|
||||
# The root key and root certificate.
|
||||
private_key = /work/ca-root.key
|
||||
certificate = /work/ca-root.crt
|
||||
|
||||
# SHA-1 is deprecated, so use SHA-2 instead.
|
||||
default_md = sha256
|
||||
|
||||
name_opt = ca_default
|
||||
cert_opt = ca_default
|
||||
default_days = 10000
|
||||
preserve = no
|
||||
policy = policy_loose
|
||||
|
||||
[ policy_loose ]
|
||||
countryName = optional
|
||||
stateOrProvinceName = optional
|
||||
localityName = optional
|
||||
organizationName = optional
|
||||
organizationalUnitName = optional
|
||||
commonName = supplied
|
||||
emailAddress = optional
|
||||
|
||||
[ req ]
|
||||
# Options for the `req` tool (`man req`).
|
||||
default_bits = 2048
|
||||
distinguished_name = req_distinguished_name
|
||||
string_mask = utf8only
|
||||
|
||||
# SHA-1 is deprecated, so use SHA-2 instead.
|
||||
default_md = sha256
|
||||
|
||||
# Extension to add when the -x509 option is used.
|
||||
x509_extensions = v3_ca
|
||||
|
||||
[ req_distinguished_name ]
|
||||
# See <https://en.wikipedia.org/wiki/Certificate_signing_request>.
|
||||
countryName = Country Name (2 letter code)
|
||||
stateOrProvinceName = State or Province Name
|
||||
localityName = Locality Name
|
||||
0.organizationName = Organization Name
|
||||
organizationalUnitName = Organizational Unit Name
|
||||
commonName = Common Name
|
||||
emailAddress = Email Address
|
||||
|
||||
[ v3_ca ]
|
||||
# Extensions for a typical CA (`man x509v3_config`).
|
||||
subjectKeyIdentifier = hash
|
||||
authorityKeyIdentifier = keyid:always,issuer
|
||||
basicConstraints = critical, CA:true
|
||||
keyUsage = critical, digitalSignature, cRLSign, keyCertSign
|
||||
|
||||
[ server_cert ]
|
||||
# Extensions for server certificates (`man x509v3_config`).
|
||||
basicConstraints = CA:FALSE
|
||||
nsCertType = server
|
||||
nsComment = server certificate generated for test purpose (nginx-proxy test suite)
|
||||
subjectKeyIdentifier = hash
|
||||
authorityKeyIdentifier = keyid,issuer:always
|
||||
keyUsage = critical, digitalSignature, keyEncipherment
|
||||
extendedKeyUsage = serverAuth
|
||||
|
||||
[ san_env ]
|
||||
subjectAltName=${ENV::SAN}
|
||||
OESCRIPT
|
||||
'
|
||||
|
||||
# shortcut for calling `openssl` inside the container
|
||||
function openssl {
|
||||
docker exec $CONTAINER openssl "$@"
|
||||
}
|
||||
|
||||
function exitfail {
|
||||
echo
|
||||
echo ERROR: "$@"
|
||||
docker rm -f $CONTAINER
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Setup Certificate authority
|
||||
###############################################################################
|
||||
|
||||
if ! [[ -f "$DIR/ca-root.key" ]]; then
|
||||
echo
|
||||
echo "> Create a Certificate Authority root key: $DIR/ca-root.key"
|
||||
openssl genrsa -out ca-root.key 2048
|
||||
[[ $? -eq 0 ]] || exitfail failed to generate CA root key
|
||||
fi
|
||||
|
||||
# Create a CA root certificate
|
||||
if ! [[ -f "$DIR/ca-root.crt" ]]; then
|
||||
echo
|
||||
echo "> Create a CA root certificate: $DIR/ca-root.crt"
|
||||
openssl req -config /ca/openssl.cnf \
|
||||
-key ca-root.key \
|
||||
-new -x509 -days 3650 -subj "/O=nginx-proxy test suite/CN=www.nginx-proxy.tld" -extensions v3_ca \
|
||||
-out ca-root.crt
|
||||
[[ $? -eq 0 ]] || exitfail failed to generate CA root certificate
|
||||
|
||||
# Verify certificate
|
||||
openssl x509 -noout -text -in ca-root.crt
|
||||
fi
|
||||
|
||||
|
||||
###############################################################################
|
||||
# create server key and certificate signed by the certificate authority
|
||||
###############################################################################
|
||||
|
||||
echo
|
||||
echo "> Create a host key: $DIR/$DOMAIN.key"
|
||||
openssl genrsa -out "$DOMAIN.key" 2048
|
||||
|
||||
echo
|
||||
echo "> Create a host certificate signing request"
|
||||
|
||||
SAN="$ALTERNATE_DOMAINS" openssl req -config /ca/openssl.cnf \
|
||||
-key "$DOMAIN.key" \
|
||||
-new -out "/ca/$DOMAIN.csr" -days 1000 -extensions san_env -subj "/CN=$DOMAIN"
|
||||
[[ $? -eq 0 ]] || exitfail failed to generate server certificate signing request
|
||||
|
||||
echo
|
||||
echo "> Create server certificate: $DIR/$DOMAIN.crt"
|
||||
SAN="$ALTERNATE_DOMAINS" openssl ca -config /ca/openssl.cnf -batch \
|
||||
-extensions server_cert \
|
||||
-extensions san_env \
|
||||
-in "/ca/$DOMAIN.csr" \
|
||||
-out "$DOMAIN.crt"
|
||||
[[ $? -eq 0 ]] || exitfail failed to generate server certificate
|
||||
|
||||
|
||||
# Verify host certificate
|
||||
#openssl x509 -noout -text -in "$DOMAIN.crt"
|
||||
|
||||
|
||||
docker rm -f $CONTAINER >/dev/null
|
||||
545
test/conftest.py
Normal file
545
test/conftest.py
Normal file
@ -0,0 +1,545 @@
|
||||
import contextlib
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
import socket
|
||||
import subprocess
|
||||
import time
|
||||
from typing import List
|
||||
|
||||
import backoff
|
||||
import docker
|
||||
import pytest
|
||||
import requests
|
||||
from _pytest._code.code import ReprExceptionInfo
|
||||
from distutils.version import LooseVersion
|
||||
from docker.models.containers import Container
|
||||
from requests.packages.urllib3.util.connection import HAS_IPV6
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logging.getLogger('backoff').setLevel(logging.INFO)
|
||||
logging.getLogger('DNS').setLevel(logging.DEBUG)
|
||||
logging.getLogger('requests.packages.urllib3.connectionpool').setLevel(logging.WARN)
|
||||
|
||||
CA_ROOT_CERTIFICATE = os.path.join(os.path.dirname(__file__), 'certs/ca-root.crt')
|
||||
PYTEST_RUNNING_IN_CONTAINER = os.environ.get('PYTEST_RUNNING_IN_CONTAINER') == "1"
|
||||
FORCE_CONTAINER_IPV6 = False # ugly global state to consider containers' IPv6 address instead of IPv4
|
||||
|
||||
|
||||
docker_client = docker.from_env()
|
||||
|
||||
# Name of pytest container to reference if it's being used for running tests
|
||||
test_container = 'nginx-proxy-pytest'
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# utilities
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
@contextlib.contextmanager
|
||||
def ipv6(force_ipv6=True):
|
||||
"""
|
||||
Meant to be used as a context manager to force IPv6 sockets:
|
||||
|
||||
with ipv6():
|
||||
nginxproxy.get("http://something.nginx-proxy.local") # force use of IPv6
|
||||
|
||||
with ipv6(False):
|
||||
nginxproxy.get("http://something.nginx-proxy.local") # legacy behavior
|
||||
|
||||
|
||||
"""
|
||||
global FORCE_CONTAINER_IPV6
|
||||
FORCE_CONTAINER_IPV6 = force_ipv6
|
||||
yield
|
||||
FORCE_CONTAINER_IPV6 = False
|
||||
|
||||
|
||||
class requests_for_docker(object):
|
||||
"""
|
||||
Proxy for calling methods of the requests module.
|
||||
When a HTTP response failed due to HTTP Error 404 or 502, retry a few times.
|
||||
Provides method `get_conf` to extract the nginx-proxy configuration content.
|
||||
"""
|
||||
def __init__(self):
|
||||
self.session = requests.Session()
|
||||
if os.path.isfile(CA_ROOT_CERTIFICATE):
|
||||
self.session.verify = CA_ROOT_CERTIFICATE
|
||||
|
||||
@staticmethod
|
||||
def get_nginx_proxy_containers() -> List[Container]:
|
||||
"""
|
||||
Return list of containers
|
||||
"""
|
||||
nginx_proxy_containers = docker_client.containers.list(filters={"ancestor": "nginxproxy/nginx-proxy:test"})
|
||||
if len(nginx_proxy_containers) > 1:
|
||||
pytest.fail("Too many running nginxproxy/nginx-proxy:test containers", pytrace=False)
|
||||
elif len(nginx_proxy_containers) == 0:
|
||||
pytest.fail("No running nginxproxy/nginx-proxy:test container", pytrace=False)
|
||||
return nginx_proxy_containers
|
||||
|
||||
def get_conf(self):
|
||||
"""
|
||||
Return the nginx config file
|
||||
"""
|
||||
nginx_proxy_containers = self.get_nginx_proxy_containers()
|
||||
return get_nginx_conf_from_container(nginx_proxy_containers[0])
|
||||
|
||||
def get_ip(self) -> str:
|
||||
"""
|
||||
Return the nginx container ip address
|
||||
"""
|
||||
nginx_proxy_containers = self.get_nginx_proxy_containers()
|
||||
return container_ip(nginx_proxy_containers[0])
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
with ipv6(kwargs.pop('ipv6', False)):
|
||||
@backoff.on_predicate(backoff.constant, lambda r: r.status_code in (404, 502), interval=.3, max_tries=30, jitter=None)
|
||||
def _get(*args, **kwargs):
|
||||
return self.session.get(*args, **kwargs)
|
||||
return _get(*args, **kwargs)
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
with ipv6(kwargs.pop('ipv6', False)):
|
||||
@backoff.on_predicate(backoff.constant, lambda r: r.status_code in (404, 502), interval=.3, max_tries=30, jitter=None)
|
||||
def _post(*args, **kwargs):
|
||||
return self.session.post(*args, **kwargs)
|
||||
return _post(*args, **kwargs)
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
with ipv6(kwargs.pop('ipv6', False)):
|
||||
@backoff.on_predicate(backoff.constant, lambda r: r.status_code in (404, 502), interval=.3, max_tries=30, jitter=None)
|
||||
def _put(*args, **kwargs):
|
||||
return self.session.put(*args, **kwargs)
|
||||
return _put(*args, **kwargs)
|
||||
|
||||
def head(self, *args, **kwargs):
|
||||
with ipv6(kwargs.pop('ipv6', False)):
|
||||
@backoff.on_predicate(backoff.constant, lambda r: r.status_code in (404, 502), interval=.3, max_tries=30, jitter=None)
|
||||
def _head(*args, **kwargs):
|
||||
return self.session.head(*args, **kwargs)
|
||||
return _head(*args, **kwargs)
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
with ipv6(kwargs.pop('ipv6', False)):
|
||||
@backoff.on_predicate(backoff.constant, lambda r: r.status_code in (404, 502), interval=.3, max_tries=30, jitter=None)
|
||||
def _delete(*args, **kwargs):
|
||||
return self.session.delete(*args, **kwargs)
|
||||
return _delete(*args, **kwargs)
|
||||
|
||||
def options(self, *args, **kwargs):
|
||||
with ipv6(kwargs.pop('ipv6', False)):
|
||||
@backoff.on_predicate(backoff.constant, lambda r: r.status_code in (404, 502), interval=.3, max_tries=30, jitter=None)
|
||||
def _options(*args, **kwargs):
|
||||
return self.session.options(*args, **kwargs)
|
||||
return _options(*args, **kwargs)
|
||||
|
||||
def __getattr__(self, name):
|
||||
return getattr(requests, name)
|
||||
|
||||
|
||||
def container_ip(container: Container):
|
||||
"""
|
||||
return the IP address of a container.
|
||||
|
||||
If the global FORCE_CONTAINER_IPV6 flag is set, return the IPv6 address
|
||||
"""
|
||||
global FORCE_CONTAINER_IPV6
|
||||
if FORCE_CONTAINER_IPV6:
|
||||
if not HAS_IPV6:
|
||||
pytest.skip("This system does not support IPv6")
|
||||
ip = container_ipv6(container)
|
||||
if ip == '':
|
||||
pytest.skip(f"Container {container.name} has no IPv6 address")
|
||||
else:
|
||||
return ip
|
||||
else:
|
||||
net_info = container.attrs["NetworkSettings"]["Networks"]
|
||||
if "bridge" in net_info:
|
||||
return net_info["bridge"]["IPAddress"]
|
||||
|
||||
# not default bridge network, fallback on first network defined
|
||||
network_name = list(net_info.keys())[0]
|
||||
return net_info[network_name]["IPAddress"]
|
||||
|
||||
|
||||
def container_ipv6(container):
|
||||
"""
|
||||
return the IPv6 address of a container.
|
||||
"""
|
||||
net_info = container.attrs["NetworkSettings"]["Networks"]
|
||||
if "bridge" in net_info:
|
||||
return net_info["bridge"]["GlobalIPv6Address"]
|
||||
|
||||
# not default bridge network, fallback on first network defined
|
||||
network_name = list(net_info.keys())[0]
|
||||
return net_info[network_name]["GlobalIPv6Address"]
|
||||
|
||||
|
||||
def nginx_proxy_dns_resolver(domain_name):
|
||||
"""
|
||||
if "nginx-proxy" if found in host, return the ip address of the docker container
|
||||
issued from the docker image nginxproxy/nginx-proxy:test.
|
||||
|
||||
:return: IP or None
|
||||
"""
|
||||
log = logging.getLogger('DNS')
|
||||
log.debug(f"nginx_proxy_dns_resolver({domain_name!r})")
|
||||
if 'nginx-proxy' in domain_name:
|
||||
nginxproxy_containers = docker_client.containers.list(filters={"status": "running", "ancestor": "nginxproxy/nginx-proxy:test"})
|
||||
if len(nginxproxy_containers) == 0:
|
||||
log.warn(f"no container found from image nginxproxy/nginx-proxy:test while resolving {domain_name!r}")
|
||||
exited_nginxproxy_containers = docker_client.containers.list(filters={"status": "exited", "ancestor": "nginxproxy/nginx-proxy:test"})
|
||||
if len(exited_nginxproxy_containers) > 0:
|
||||
exited_nginxproxy_container_logs = exited_nginxproxy_containers[0].logs()
|
||||
log.warn(f"nginxproxy/nginx-proxy:test container might have exited unexpectedly. Container logs: " + "\n" + exited_nginxproxy_container_logs.decode())
|
||||
return
|
||||
nginxproxy_container = nginxproxy_containers[0]
|
||||
ip = container_ip(nginxproxy_container)
|
||||
log.info(f"resolving domain name {domain_name!r} as IP address {ip} of nginx-proxy container {nginxproxy_container.name}")
|
||||
return ip
|
||||
|
||||
def docker_container_dns_resolver(domain_name):
|
||||
"""
|
||||
if domain name is of the form "XXX.container.docker" or "anything.XXX.container.docker", return the ip address of the docker container
|
||||
named XXX.
|
||||
|
||||
:return: IP or None
|
||||
"""
|
||||
log = logging.getLogger('DNS')
|
||||
log.debug(f"docker_container_dns_resolver({domain_name!r})")
|
||||
|
||||
match = re.search(r'(^|.+\.)(?P<container>[^.]+)\.container\.docker$', domain_name)
|
||||
if not match:
|
||||
log.debug(f"{domain_name!r} does not match")
|
||||
return
|
||||
|
||||
container_name = match.group('container')
|
||||
log.debug(f"looking for container {container_name!r}")
|
||||
try:
|
||||
container = docker_client.containers.get(container_name)
|
||||
except docker.errors.NotFound:
|
||||
log.warn(f"container named {container_name!r} not found while resolving {domain_name!r}")
|
||||
return
|
||||
log.debug(f"container {container.name!r} found ({container.short_id})")
|
||||
|
||||
ip = container_ip(container)
|
||||
log.info(f"resolving domain name {domain_name!r} as IP address {ip} of container {container.name}")
|
||||
return ip
|
||||
|
||||
|
||||
def monkey_patch_urllib_dns_resolver():
|
||||
"""
|
||||
Alter the behavior of the urllib DNS resolver so that any domain name
|
||||
containing substring 'nginx-proxy' will resolve to the IP address
|
||||
of the container created from image 'nginxproxy/nginx-proxy:test'.
|
||||
"""
|
||||
prv_getaddrinfo = socket.getaddrinfo
|
||||
dns_cache = {}
|
||||
def new_getaddrinfo(*args):
|
||||
logging.getLogger('DNS').debug(f"resolving domain name {repr(args)}")
|
||||
_args = list(args)
|
||||
|
||||
# Fail early when querying IP directly and it is forced ipv6 when not supported,
|
||||
# Otherwise a pytest container not using the host network fails to pass `test_raw-ip-vhost`.
|
||||
if FORCE_CONTAINER_IPV6 and not HAS_IPV6:
|
||||
pytest.skip("This system does not support IPv6")
|
||||
|
||||
# custom DNS resolvers
|
||||
ip = nginx_proxy_dns_resolver(args[0])
|
||||
if ip is None:
|
||||
ip = docker_container_dns_resolver(args[0])
|
||||
if ip is not None:
|
||||
_args[0] = ip
|
||||
|
||||
# call on original DNS resolver, with eventually the original host changed to the wanted IP address
|
||||
try:
|
||||
return dns_cache[tuple(_args)]
|
||||
except KeyError:
|
||||
res = prv_getaddrinfo(*_args)
|
||||
dns_cache[tuple(_args)] = res
|
||||
return res
|
||||
socket.getaddrinfo = new_getaddrinfo
|
||||
return prv_getaddrinfo
|
||||
|
||||
def restore_urllib_dns_resolver(getaddrinfo_func):
|
||||
socket.getaddrinfo = getaddrinfo_func
|
||||
|
||||
|
||||
def remove_all_containers():
|
||||
for container in docker_client.containers.list(all=True):
|
||||
if PYTEST_RUNNING_IN_CONTAINER and container.name == test_container:
|
||||
continue # pytest is running within a Docker container, so we do not want to remove that particular container
|
||||
logging.info(f"removing container {container.name}")
|
||||
container.remove(v=True, force=True)
|
||||
|
||||
|
||||
def get_nginx_conf_from_container(container):
|
||||
"""
|
||||
return the nginx /etc/nginx/conf.d/default.conf file content from a container
|
||||
"""
|
||||
import tarfile
|
||||
from io import BytesIO
|
||||
|
||||
strm_generator, stat = container.get_archive('/etc/nginx/conf.d/default.conf')
|
||||
strm_fileobj = BytesIO(b"".join(strm_generator))
|
||||
|
||||
with tarfile.open(fileobj=strm_fileobj) as tf:
|
||||
conffile = tf.extractfile('default.conf')
|
||||
return conffile.read()
|
||||
|
||||
|
||||
def docker_compose_up(compose_file='docker-compose.yml'):
|
||||
logging.info(f'docker-compose -f {compose_file} up -d')
|
||||
try:
|
||||
subprocess.check_output(shlex.split(f'docker-compose -f {compose_file} up -d'), stderr=subprocess.STDOUT)
|
||||
except subprocess.CalledProcessError as e:
|
||||
pytest.fail(f"Error while runninng 'docker-compose -f {compose_file} up -d':\n{e.output}", pytrace=False)
|
||||
|
||||
|
||||
def docker_compose_down(compose_file='docker-compose.yml'):
|
||||
logging.info(f'docker-compose -f {compose_file} down -v')
|
||||
try:
|
||||
subprocess.check_output(shlex.split(f'docker-compose -f {compose_file} down -v'), stderr=subprocess.STDOUT)
|
||||
except subprocess.CalledProcessError as e:
|
||||
pytest.fail(f"Error while runninng 'docker-compose -f {compose_file} down -v':\n{e.output}", pytrace=False)
|
||||
|
||||
|
||||
def wait_for_nginxproxy_to_be_ready():
|
||||
"""
|
||||
If one (and only one) container started from image nginxproxy/nginx-proxy:test is found,
|
||||
wait for its log to contain substring "Watching docker events"
|
||||
"""
|
||||
containers = docker_client.containers.list(filters={"ancestor": "nginxproxy/nginx-proxy:test"})
|
||||
if len(containers) != 1:
|
||||
return
|
||||
container = containers[0]
|
||||
for line in container.logs(stream=True):
|
||||
if b"Watching docker events" in line:
|
||||
logging.debug("nginx-proxy ready")
|
||||
break
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def docker_compose_file(request):
|
||||
"""Fixture naming the docker-compose file to consider.
|
||||
|
||||
If a YAML file exists with the same name as the test module (with the `.py` extension replaced
|
||||
with `.yml` or `.yaml`), use that. Otherwise, use `docker-compose.yml` in the same directory
|
||||
as the test module.
|
||||
|
||||
Tests can override this fixture to specify a custom location.
|
||||
"""
|
||||
test_module_dir = os.path.dirname(request.module.__file__)
|
||||
yml_file = os.path.join(test_module_dir, request.module.__name__ + '.yml')
|
||||
yaml_file = os.path.join(test_module_dir, request.module.__name__ + '.yaml')
|
||||
default_file = os.path.join(test_module_dir, 'docker-compose.yml')
|
||||
|
||||
if os.path.isfile(yml_file):
|
||||
docker_compose_file = yml_file
|
||||
elif os.path.isfile(yaml_file):
|
||||
docker_compose_file = yaml_file
|
||||
else:
|
||||
docker_compose_file = default_file
|
||||
|
||||
if not os.path.isfile(docker_compose_file):
|
||||
logging.error("Could not find any docker-compose file named either '{0}.yml', '{0}.yaml' or 'docker-compose.yml'".format(request.module.__name__))
|
||||
|
||||
logging.debug(f"using docker compose file {docker_compose_file}")
|
||||
return docker_compose_file
|
||||
|
||||
|
||||
def connect_to_network(network):
|
||||
"""
|
||||
If we are running from a container, connect our container to the given network
|
||||
|
||||
:return: the name of the network we were connected to, or None
|
||||
"""
|
||||
if PYTEST_RUNNING_IN_CONTAINER:
|
||||
try:
|
||||
my_container = docker_client.containers.get(test_container)
|
||||
except docker.errors.NotFound:
|
||||
logging.warn(f"container {test_container} not found")
|
||||
return
|
||||
|
||||
# figure out our container networks
|
||||
my_networks = list(my_container.attrs["NetworkSettings"]["Networks"].keys())
|
||||
|
||||
# If the pytest container is using host networking, it cannot connect to container networks (not required with host network)
|
||||
if 'host' in my_networks:
|
||||
return None
|
||||
|
||||
# Make sure our container is connected to the nginx-proxy's network,
|
||||
# but avoid connecting to `none` network (not valid) with `test_server-down` tests
|
||||
if network.name not in my_networks and network.name != 'none':
|
||||
logging.info(f"Connecting to docker network: {network.name}")
|
||||
network.connect(my_container)
|
||||
return network
|
||||
|
||||
|
||||
def disconnect_from_network(network=None):
|
||||
"""
|
||||
If we are running from a container, disconnect our container from the given network.
|
||||
|
||||
:param network: name of a docker network to disconnect from
|
||||
"""
|
||||
if PYTEST_RUNNING_IN_CONTAINER and network is not None:
|
||||
try:
|
||||
my_container = docker_client.containers.get(test_container)
|
||||
except docker.errors.NotFound:
|
||||
logging.warn(f"container {test_container} not found")
|
||||
return
|
||||
|
||||
# figure out our container networks
|
||||
my_networks_names = list(my_container.attrs["NetworkSettings"]["Networks"].keys())
|
||||
|
||||
# disconnect our container from the given network
|
||||
if network.name in my_networks_names:
|
||||
logging.info(f"Disconnecting from network {network.name}")
|
||||
network.disconnect(my_container)
|
||||
|
||||
|
||||
def connect_to_all_networks():
|
||||
"""
|
||||
If we are running from a container, connect our container to all current docker networks.
|
||||
|
||||
:return: a list of networks we connected to
|
||||
"""
|
||||
if not PYTEST_RUNNING_IN_CONTAINER:
|
||||
return []
|
||||
else:
|
||||
# find the list of docker networks
|
||||
networks = [network for network in docker_client.networks.list(greedy=True) if len(network.containers) > 0 and network.name != 'bridge']
|
||||
return [connect_to_network(network) for network in networks]
|
||||
|
||||
|
||||
class DockerComposer(contextlib.AbstractContextManager):
|
||||
def __init__(self):
|
||||
self._docker_compose_file = None
|
||||
|
||||
def __exit__(self, *exc_info):
|
||||
self._down()
|
||||
|
||||
def _down(self):
|
||||
if self._docker_compose_file is None:
|
||||
return
|
||||
for network in self._networks:
|
||||
disconnect_from_network(network)
|
||||
docker_compose_down(self._docker_compose_file)
|
||||
self._docker_compose_file = None
|
||||
|
||||
def compose(self, docker_compose_file):
|
||||
if docker_compose_file == self._docker_compose_file:
|
||||
return
|
||||
self._down()
|
||||
if docker_compose_file is None:
|
||||
return
|
||||
remove_all_containers()
|
||||
docker_compose_up(docker_compose_file)
|
||||
self._networks = connect_to_all_networks()
|
||||
wait_for_nginxproxy_to_be_ready()
|
||||
time.sleep(3) # give time to containers to be ready
|
||||
self._docker_compose_file = docker_compose_file
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Py.test fixtures
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def docker_composer():
|
||||
with DockerComposer() as d:
|
||||
yield d
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def ca_root_certificate():
|
||||
return CA_ROOT_CERTIFICATE
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def monkey_patched_dns():
|
||||
original_dns_resolver = monkey_patch_urllib_dns_resolver()
|
||||
yield
|
||||
restore_urllib_dns_resolver(original_dns_resolver)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def docker_compose(monkey_patched_dns, docker_composer, docker_compose_file):
|
||||
"""Ensures containers described in a docker compose file are started.
|
||||
|
||||
A custom docker compose file name can be specified by overriding the `docker_compose_file`
|
||||
fixture.
|
||||
|
||||
Also, in the case where pytest is running from a docker container, this fixture makes sure
|
||||
our container will be attached to all the docker networks.
|
||||
"""
|
||||
docker_composer.compose(docker_compose_file)
|
||||
yield docker_client
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def nginxproxy():
|
||||
"""
|
||||
Provides the `nginxproxy` object that can be used in the same way the requests module is:
|
||||
|
||||
r = nginxproxy.get("http://foo.com")
|
||||
|
||||
The difference is that in case an HTTP requests has status code 404 or 502 (which mostly
|
||||
indicates that nginx has just reloaded), we retry up to 30 times the query.
|
||||
|
||||
Also, the nginxproxy methods accept an additional keyword parameter: `ipv6` which forces requests
|
||||
made against containers to use the containers IPv6 address when set to `True`. If IPv6 is not
|
||||
supported by the system or docker, that particular test will be skipped.
|
||||
"""
|
||||
yield requests_for_docker()
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Py.test hooks
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
# pytest hook to display additionnal stuff in test report
|
||||
def pytest_runtest_logreport(report):
|
||||
if report.failed:
|
||||
if isinstance(report.longrepr, ReprExceptionInfo):
|
||||
test_containers = docker_client.containers.list(all=True, filters={"ancestor": "nginxproxy/nginx-proxy:test"})
|
||||
for container in test_containers:
|
||||
report.longrepr.addsection('nginx-proxy logs', container.logs())
|
||||
report.longrepr.addsection('nginx-proxy conf', get_nginx_conf_from_container(container))
|
||||
|
||||
|
||||
# Py.test `incremental` marker, see http://stackoverflow.com/a/12579625/107049
|
||||
def pytest_runtest_makereport(item, call):
|
||||
if "incremental" in item.keywords:
|
||||
if call.excinfo is not None:
|
||||
parent = item.parent
|
||||
parent._previousfailed = item
|
||||
|
||||
|
||||
def pytest_runtest_setup(item):
|
||||
previousfailed = getattr(item.parent, "_previousfailed", None)
|
||||
if previousfailed is not None:
|
||||
pytest.xfail(f"previous test failed ({previousfailed.name})")
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Check requirements
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
try:
|
||||
docker_client.images.get('nginxproxy/nginx-proxy:test')
|
||||
except docker.errors.ImageNotFound:
|
||||
pytest.exit("The docker image 'nginxproxy/nginx-proxy:test' is missing")
|
||||
|
||||
if LooseVersion(docker.__version__) < LooseVersion("5.0.0"):
|
||||
pytest.exit("This test suite is meant to work with the python docker module v5.0.0 or later")
|
||||
@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env bats
|
||||
load test_helpers
|
||||
|
||||
function setup {
|
||||
# make sure to stop any web container before each test so we don't
|
||||
# have any unexpected contaiener running with VIRTUAL_HOST or VIRUTAL_PORT set
|
||||
stop_bats_containers web
|
||||
}
|
||||
|
||||
|
||||
@test "[$TEST_FILE] DEFAULT_HOST=web1.bats" {
|
||||
SUT_CONTAINER=bats-nginx-proxy-${TEST_FILE}-1
|
||||
|
||||
# GIVEN a webserver with VIRTUAL_HOST set to web.bats
|
||||
prepare_web_container bats-web 80 -e VIRTUAL_HOST=web.bats
|
||||
|
||||
# WHEN nginx-proxy runs with DEFAULT_HOST set to web.bats
|
||||
run nginxproxy $SUT_CONTAINER -v /var/run/docker.sock:/tmp/docker.sock:ro -e DEFAULT_HOST=web.bats
|
||||
assert_success
|
||||
docker_wait_for_log $SUT_CONTAINER 9 "Watching docker events"
|
||||
|
||||
# THEN querying the proxy without Host header → 200
|
||||
run curl_container $SUT_CONTAINER / --head
|
||||
assert_output -l 0 $'HTTP/1.1 200 OK\r'
|
||||
|
||||
# THEN querying the proxy with any other Host header → 200
|
||||
run curl_container $SUT_CONTAINER / --head --header "Host: something.I.just.made.up"
|
||||
assert_output -l 0 $'HTTP/1.1 200 OK\r'
|
||||
}
|
||||
|
||||
@test "[$TEST_FILE] stop all bats containers" {
|
||||
stop_bats_containers
|
||||
}
|
||||
123
test/docker.bats
123
test/docker.bats
@ -1,123 +0,0 @@
|
||||
#!/usr/bin/env bats
|
||||
load test_helpers
|
||||
|
||||
|
||||
@test "[$TEST_FILE] start 2 web containers" {
|
||||
prepare_web_container bats-web1 81 -e VIRTUAL_HOST=web1.bats
|
||||
prepare_web_container bats-web2 82 -e VIRTUAL_HOST=web2.bats
|
||||
}
|
||||
|
||||
|
||||
@test "[$TEST_FILE] -v /var/run/docker.sock:/tmp/docker.sock:ro" {
|
||||
SUT_CONTAINER=bats-nginx-proxy-${TEST_FILE}-1
|
||||
|
||||
# WHEN nginx-proxy runs on our docker host using the default unix socket
|
||||
run nginxproxy $SUT_CONTAINER -v /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
assert_success
|
||||
docker_wait_for_log $SUT_CONTAINER 9 "Watching docker events"
|
||||
|
||||
# THEN
|
||||
assert_nginxproxy_behaves $SUT_CONTAINER
|
||||
}
|
||||
|
||||
|
||||
@test "[$TEST_FILE] -v /var/run/docker.sock:/f00.sock:ro -e DOCKER_HOST=unix:///f00.sock" {
|
||||
SUT_CONTAINER=bats-nginx-proxy-${TEST_FILE}-2
|
||||
|
||||
# WHEN nginx-proxy runs on our docker host using a custom unix socket
|
||||
run nginxproxy $SUT_CONTAINER -v /var/run/docker.sock:/f00.sock:ro -e DOCKER_HOST=unix:///f00.sock
|
||||
assert_success
|
||||
docker_wait_for_log $SUT_CONTAINER 9 "Watching docker events"
|
||||
|
||||
# THEN
|
||||
assert_nginxproxy_behaves $SUT_CONTAINER
|
||||
}
|
||||
|
||||
|
||||
@test "[$TEST_FILE] -e DOCKER_HOST=tcp://..." {
|
||||
SUT_CONTAINER=bats-nginx-proxy-${TEST_FILE}-3
|
||||
# GIVEN a container exposing our docker host over TCP
|
||||
run docker_tcp bats-docker-tcp
|
||||
assert_success
|
||||
sleep 1s
|
||||
|
||||
# WHEN nginx-proxy runs on our docker host using tcp to connect to our docker host
|
||||
run nginxproxy $SUT_CONTAINER -e DOCKER_HOST="tcp://bats-docker-tcp:2375" --link bats-docker-tcp:bats-docker-tcp
|
||||
assert_success
|
||||
docker_wait_for_log $SUT_CONTAINER 9 "Watching docker events"
|
||||
|
||||
# THEN
|
||||
assert_nginxproxy_behaves $SUT_CONTAINER
|
||||
}
|
||||
|
||||
|
||||
@test "[$TEST_FILE] separated containers (nginx + docker-gen + nginx.tmpl)" {
|
||||
docker_clean bats-nginx
|
||||
docker_clean bats-docker-gen
|
||||
|
||||
# GIVEN a simple nginx container
|
||||
run docker run -d \
|
||||
--label bats-type="nginx" \
|
||||
--name bats-nginx \
|
||||
-v /etc/nginx/conf.d/ \
|
||||
-v /etc/nginx/certs/ \
|
||||
nginx:latest
|
||||
assert_success
|
||||
run retry 5 1s docker run --label bats-type="curl" appropriate/curl --silent --fail --head http://$(docker_ip bats-nginx)/
|
||||
assert_output -l 0 $'HTTP/1.1 200 OK\r'
|
||||
|
||||
# WHEN docker-gen runs on our docker host
|
||||
run docker run -d \
|
||||
--label bats-type="docker-gen" \
|
||||
--name bats-docker-gen \
|
||||
-v /var/run/docker.sock:/tmp/docker.sock:ro \
|
||||
-v $BATS_TEST_DIRNAME/../nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro \
|
||||
--volumes-from bats-nginx \
|
||||
--expose 80 \
|
||||
jwilder/docker-gen:0.7.3 \
|
||||
-notify-sighup bats-nginx \
|
||||
-watch \
|
||||
-only-exposed \
|
||||
/etc/docker-gen/templates/nginx.tmpl \
|
||||
/etc/nginx/conf.d/default.conf
|
||||
assert_success
|
||||
docker_wait_for_log bats-docker-gen 9 "Watching docker events"
|
||||
|
||||
# Give some time to the docker-gen container to notify bats-nginx so it
|
||||
# reloads its config
|
||||
sleep 2s
|
||||
|
||||
run docker_running_state bats-nginx
|
||||
assert_output "true" || {
|
||||
docker logs bats-docker-gen
|
||||
false
|
||||
} >&2
|
||||
|
||||
# THEN
|
||||
assert_nginxproxy_behaves bats-nginx
|
||||
}
|
||||
|
||||
@test "[$TEST_FILE] stop all bats containers" {
|
||||
stop_bats_containers
|
||||
}
|
||||
|
||||
|
||||
# $1 nginx-proxy container
|
||||
function assert_nginxproxy_behaves {
|
||||
local -r container=$1
|
||||
|
||||
# Querying the proxy without Host header → 503
|
||||
run curl_container $container / --head
|
||||
assert_output -l 0 $'HTTP/1.1 503 Service Temporarily Unavailable\r'
|
||||
|
||||
# Querying the proxy with Host header → 200
|
||||
run curl_container $container /data --header "Host: web1.bats"
|
||||
assert_output "answer from port 81"
|
||||
|
||||
run curl_container $container /data --header "Host: web2.bats"
|
||||
assert_output "answer from port 82"
|
||||
|
||||
# Querying the proxy with unknown Host header → 503
|
||||
run curl_container $container /data --header "Host: webFOO.bats" --head
|
||||
assert_output -l 0 $'HTTP/1.1 503 Service Temporarily Unavailable\r'
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
bats lib
|
||||
========
|
||||
|
||||
found on https://github.com/sstephenson/bats/pull/110
|
||||
|
||||
When that pull request will be merged, the `test/lib/bats` won't be necessary anymore.
|
||||
@ -1,596 +0,0 @@
|
||||
#
|
||||
# batslib.bash
|
||||
# ------------
|
||||
#
|
||||
# The Standard Library is a collection of test helpers intended to
|
||||
# simplify testing. It contains the following types of test helpers.
|
||||
#
|
||||
# - Assertions are functions that perform a test and output relevant
|
||||
# information on failure to help debugging. They return 1 on failure
|
||||
# and 0 otherwise.
|
||||
#
|
||||
# All output is formatted for readability using the functions of
|
||||
# `output.bash' and sent to the standard error.
|
||||
#
|
||||
|
||||
source "${BATS_LIB}/batslib/output.bash"
|
||||
|
||||
|
||||
########################################################################
|
||||
# ASSERTIONS
|
||||
########################################################################
|
||||
|
||||
# Fail and display a message. When no parameters are specified, the
|
||||
# message is read from the standard input. Other functions use this to
|
||||
# report failure.
|
||||
#
|
||||
# Globals:
|
||||
# none
|
||||
# Arguments:
|
||||
# $@ - [=STDIN] message
|
||||
# Returns:
|
||||
# 1 - always
|
||||
# Inputs:
|
||||
# STDIN - [=$@] message
|
||||
# Outputs:
|
||||
# STDERR - message
|
||||
fail() {
|
||||
(( $# == 0 )) && batslib_err || batslib_err "$@"
|
||||
return 1
|
||||
}
|
||||
|
||||
# Fail and display details if the expression evaluates to false. Details
|
||||
# include the expression, `$status' and `$output'.
|
||||
#
|
||||
# NOTE: The expression must be a simple command. Compound commands, such
|
||||
# as `[[', can be used only when executed with `bash -c'.
|
||||
#
|
||||
# Globals:
|
||||
# status
|
||||
# output
|
||||
# Arguments:
|
||||
# $1 - expression
|
||||
# Returns:
|
||||
# 0 - expression evaluates to TRUE
|
||||
# 1 - otherwise
|
||||
# Outputs:
|
||||
# STDERR - details, on failure
|
||||
assert() {
|
||||
if ! "$@"; then
|
||||
{ local -ar single=(
|
||||
'expression' "$*"
|
||||
'status' "$status"
|
||||
)
|
||||
local -ar may_be_multi=(
|
||||
'output' "$output"
|
||||
)
|
||||
local -ir width="$( batslib_get_max_single_line_key_width \
|
||||
"${single[@]}" "${may_be_multi[@]}" )"
|
||||
batslib_print_kv_single "$width" "${single[@]}"
|
||||
batslib_print_kv_single_or_multi "$width" "${may_be_multi[@]}"
|
||||
} | batslib_decorate 'assertion failed' \
|
||||
| fail
|
||||
fi
|
||||
}
|
||||
|
||||
# Fail and display details if the expected and actual values do not
|
||||
# equal. Details include both values.
|
||||
#
|
||||
# Globals:
|
||||
# none
|
||||
# Arguments:
|
||||
# $1 - actual value
|
||||
# $2 - expected value
|
||||
# Returns:
|
||||
# 0 - values equal
|
||||
# 1 - otherwise
|
||||
# Outputs:
|
||||
# STDERR - details, on failure
|
||||
assert_equal() {
|
||||
if [[ $1 != "$2" ]]; then
|
||||
batslib_print_kv_single_or_multi 8 \
|
||||
'expected' "$2" \
|
||||
'actual' "$1" \
|
||||
| batslib_decorate 'values do not equal' \
|
||||
| fail
|
||||
fi
|
||||
}
|
||||
|
||||
# Fail and display details if `$status' is not 0. Details include
|
||||
# `$status' and `$output'.
|
||||
#
|
||||
# Globals:
|
||||
# status
|
||||
# output
|
||||
# Arguments:
|
||||
# none
|
||||
# Returns:
|
||||
# 0 - `$status' is 0
|
||||
# 1 - otherwise
|
||||
# Outputs:
|
||||
# STDERR - details, on failure
|
||||
assert_success() {
|
||||
if (( status != 0 )); then
|
||||
{ local -ir width=6
|
||||
batslib_print_kv_single "$width" 'status' "$status"
|
||||
batslib_print_kv_single_or_multi "$width" 'output' "$output"
|
||||
} | batslib_decorate 'command failed' \
|
||||
| fail
|
||||
fi
|
||||
}
|
||||
|
||||
# Fail and display details if `$status' is 0. Details include `$output'.
|
||||
#
|
||||
# Optionally, when the expected status is specified, fail when it does
|
||||
# not equal `$status'. In this case, details include the expected and
|
||||
# actual status, and `$output'.
|
||||
#
|
||||
# Globals:
|
||||
# status
|
||||
# output
|
||||
# Arguments:
|
||||
# $1 - [opt] expected status
|
||||
# Returns:
|
||||
# 0 - `$status' is not 0, or
|
||||
# `$status' equals the expected status
|
||||
# 1 - otherwise
|
||||
# Outputs:
|
||||
# STDERR - details, on failure
|
||||
assert_failure() {
|
||||
(( $# > 0 )) && local -r expected="$1"
|
||||
if (( status == 0 )); then
|
||||
batslib_print_kv_single_or_multi 6 'output' "$output" \
|
||||
| batslib_decorate 'command succeeded, but it was expected to fail' \
|
||||
| fail
|
||||
elif (( $# > 0 )) && (( status != expected )); then
|
||||
{ local -ir width=8
|
||||
batslib_print_kv_single "$width" \
|
||||
'expected' "$expected" \
|
||||
'actual' "$status"
|
||||
batslib_print_kv_single_or_multi "$width" \
|
||||
'output' "$output"
|
||||
} | batslib_decorate 'command failed as expected, but status differs' \
|
||||
| fail
|
||||
fi
|
||||
}
|
||||
|
||||
# Fail and display details if the expected does not match the actual
|
||||
# output or a fragment of it.
|
||||
#
|
||||
# By default, the entire output is matched. The assertion fails if the
|
||||
# expected output does not equal `$output'. Details include both values.
|
||||
#
|
||||
# When `-l <index>' is used, only the <index>-th line is matched. The
|
||||
# assertion fails if the expected line does not equal
|
||||
# `${lines[<index>}'. Details include the compared lines and <index>.
|
||||
#
|
||||
# When `-l' is used without the <index> argument, the output is searched
|
||||
# for the expected line. The expected line is matched against each line
|
||||
# in `${lines[@]}'. If no match is found the assertion fails. Details
|
||||
# include the expected line and `$output'.
|
||||
#
|
||||
# By default, literal matching is performed. Options `-p' and `-r'
|
||||
# enable partial (i.e. substring) and extended regular expression
|
||||
# matching, respectively. Specifying an invalid extended regular
|
||||
# expression with `-r' displays an error.
|
||||
#
|
||||
# Options `-p' and `-r' are mutually exclusive. When used
|
||||
# simultaneously, an error is displayed.
|
||||
#
|
||||
# Globals:
|
||||
# output
|
||||
# lines
|
||||
# Options:
|
||||
# -l <index> - match against the <index>-th element of `${lines[@]}'
|
||||
# -l - search `${lines[@]}' for the expected line
|
||||
# -p - partial matching
|
||||
# -r - extended regular expression matching
|
||||
# Arguments:
|
||||
# $1 - expected output
|
||||
# Returns:
|
||||
# 0 - expected matches the actual output
|
||||
# 1 - otherwise
|
||||
# Outputs:
|
||||
# STDERR - details, on failure
|
||||
# error message, on error
|
||||
assert_output() {
|
||||
local -i is_match_line=0
|
||||
local -i is_match_contained=0
|
||||
local -i is_mode_partial=0
|
||||
local -i is_mode_regex=0
|
||||
|
||||
# Handle options.
|
||||
while (( $# > 0 )); do
|
||||
case "$1" in
|
||||
-l)
|
||||
if (( $# > 2 )) && [[ $2 =~ ^([0-9]|[1-9][0-9]+)$ ]]; then
|
||||
is_match_line=1
|
||||
local -ri idx="$2"
|
||||
shift
|
||||
else
|
||||
is_match_contained=1;
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
-p) is_mode_partial=1; shift ;;
|
||||
-r) is_mode_regex=1; shift ;;
|
||||
--) break ;;
|
||||
*) break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if (( is_match_line )) && (( is_match_contained )); then
|
||||
echo "\`-l' and \`-l <index>' are mutually exclusive" \
|
||||
| batslib_decorate 'ERROR: assert_output' \
|
||||
| fail
|
||||
return $?
|
||||
fi
|
||||
|
||||
if (( is_mode_partial )) && (( is_mode_regex )); then
|
||||
echo "\`-p' and \`-r' are mutually exclusive" \
|
||||
| batslib_decorate 'ERROR: assert_output' \
|
||||
| fail
|
||||
return $?
|
||||
fi
|
||||
|
||||
# Arguments.
|
||||
local -r expected="$1"
|
||||
|
||||
if (( is_mode_regex == 1 )) && [[ '' =~ $expected ]] || (( $? == 2 )); then
|
||||
echo "Invalid extended regular expression: \`$expected'" \
|
||||
| batslib_decorate 'ERROR: assert_output' \
|
||||
| fail
|
||||
return $?
|
||||
fi
|
||||
|
||||
# Matching.
|
||||
if (( is_match_contained )); then
|
||||
# Line contained in output.
|
||||
if (( is_mode_regex )); then
|
||||
local -i idx
|
||||
for (( idx = 0; idx < ${#lines[@]}; ++idx )); do
|
||||
[[ ${lines[$idx]} =~ $expected ]] && return 0
|
||||
done
|
||||
{ local -ar single=(
|
||||
'regex' "$expected"
|
||||
)
|
||||
local -ar may_be_multi=(
|
||||
'output' "$output"
|
||||
)
|
||||
local -ir width="$( batslib_get_max_single_line_key_width \
|
||||
"${single[@]}" "${may_be_multi[@]}" )"
|
||||
batslib_print_kv_single "$width" "${single[@]}"
|
||||
batslib_print_kv_single_or_multi "$width" "${may_be_multi[@]}"
|
||||
} | batslib_decorate 'no output line matches regular expression' \
|
||||
| fail
|
||||
elif (( is_mode_partial )); then
|
||||
local -i idx
|
||||
for (( idx = 0; idx < ${#lines[@]}; ++idx )); do
|
||||
[[ ${lines[$idx]} == *"$expected"* ]] && return 0
|
||||
done
|
||||
{ local -ar single=(
|
||||
'substring' "$expected"
|
||||
)
|
||||
local -ar may_be_multi=(
|
||||
'output' "$output"
|
||||
)
|
||||
local -ir width="$( batslib_get_max_single_line_key_width \
|
||||
"${single[@]}" "${may_be_multi[@]}" )"
|
||||
batslib_print_kv_single "$width" "${single[@]}"
|
||||
batslib_print_kv_single_or_multi "$width" "${may_be_multi[@]}"
|
||||
} | batslib_decorate 'no output line contains substring' \
|
||||
| fail
|
||||
else
|
||||
local -i idx
|
||||
for (( idx = 0; idx < ${#lines[@]}; ++idx )); do
|
||||
[[ ${lines[$idx]} == "$expected" ]] && return 0
|
||||
done
|
||||
{ local -ar single=(
|
||||
'line' "$expected"
|
||||
)
|
||||
local -ar may_be_multi=(
|
||||
'output' "$output"
|
||||
)
|
||||
local -ir width="$( batslib_get_max_single_line_key_width \
|
||||
"${single[@]}" "${may_be_multi[@]}" )"
|
||||
batslib_print_kv_single "$width" "${single[@]}"
|
||||
batslib_print_kv_single_or_multi "$width" "${may_be_multi[@]}"
|
||||
} | batslib_decorate 'output does not contain line' \
|
||||
| fail
|
||||
fi
|
||||
elif (( is_match_line )); then
|
||||
# Specific line.
|
||||
if (( is_mode_regex )); then
|
||||
if ! [[ ${lines[$idx]} =~ $expected ]]; then
|
||||
batslib_print_kv_single 5 \
|
||||
'index' "$idx" \
|
||||
'regex' "$expected" \
|
||||
'line' "${lines[$idx]}" \
|
||||
| batslib_decorate 'regular expression does not match line' \
|
||||
| fail
|
||||
fi
|
||||
elif (( is_mode_partial )); then
|
||||
if [[ ${lines[$idx]} != *"$expected"* ]]; then
|
||||
batslib_print_kv_single 9 \
|
||||
'index' "$idx" \
|
||||
'substring' "$expected" \
|
||||
'line' "${lines[$idx]}" \
|
||||
| batslib_decorate 'line does not contain substring' \
|
||||
| fail
|
||||
fi
|
||||
else
|
||||
if [[ ${lines[$idx]} != "$expected" ]]; then
|
||||
batslib_print_kv_single 8 \
|
||||
'index' "$idx" \
|
||||
'expected' "$expected" \
|
||||
'actual' "${lines[$idx]}" \
|
||||
| batslib_decorate 'line differs' \
|
||||
| fail
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# Entire output.
|
||||
if (( is_mode_regex )); then
|
||||
if ! [[ $output =~ $expected ]]; then
|
||||
batslib_print_kv_single_or_multi 6 \
|
||||
'regex' "$expected" \
|
||||
'output' "$output" \
|
||||
| batslib_decorate 'regular expression does not match output' \
|
||||
| fail
|
||||
fi
|
||||
elif (( is_mode_partial )); then
|
||||
if [[ $output != *"$expected"* ]]; then
|
||||
batslib_print_kv_single_or_multi 9 \
|
||||
'substring' "$expected" \
|
||||
'output' "$output" \
|
||||
| batslib_decorate 'output does not contain substring' \
|
||||
| fail
|
||||
fi
|
||||
else
|
||||
if [[ $output != "$expected" ]]; then
|
||||
batslib_print_kv_single_or_multi 8 \
|
||||
'expected' "$expected" \
|
||||
'actual' "$output" \
|
||||
| batslib_decorate 'output differs' \
|
||||
| fail
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Fail and display details if the unexpected matches the actual output
|
||||
# or a fragment of it.
|
||||
#
|
||||
# By default, the entire output is matched. The assertion fails if the
|
||||
# unexpected output equals `$output'. Details include `$output'.
|
||||
#
|
||||
# When `-l <index>' is used, only the <index>-th line is matched. The
|
||||
# assertion fails if the unexpected line equals `${lines[<index>}'.
|
||||
# Details include the compared line and <index>.
|
||||
#
|
||||
# When `-l' is used without the <index> argument, the output is searched
|
||||
# for the unexpected line. The unexpected line is matched against each
|
||||
# line in `${lines[<index>]}'. If a match is found the assertion fails.
|
||||
# Details include the unexpected line, the index where it was found and
|
||||
# `$output' (with the unexpected line highlighted in it if `$output` is
|
||||
# longer than one line).
|
||||
#
|
||||
# By default, literal matching is performed. Options `-p' and `-r'
|
||||
# enable partial (i.e. substring) and extended regular expression
|
||||
# matching, respectively. On failure, the substring or the regular
|
||||
# expression is added to the details (if not already displayed).
|
||||
# Specifying an invalid extended regular expression with `-r' displays
|
||||
# an error.
|
||||
#
|
||||
# Options `-p' and `-r' are mutually exclusive. When used
|
||||
# simultaneously, an error is displayed.
|
||||
#
|
||||
# Globals:
|
||||
# output
|
||||
# lines
|
||||
# Options:
|
||||
# -l <index> - match against the <index>-th element of `${lines[@]}'
|
||||
# -l - search `${lines[@]}' for the unexpected line
|
||||
# -p - partial matching
|
||||
# -r - extended regular expression matching
|
||||
# Arguments:
|
||||
# $1 - unexpected output
|
||||
# Returns:
|
||||
# 0 - unexpected matches the actual output
|
||||
# 1 - otherwise
|
||||
# Outputs:
|
||||
# STDERR - details, on failure
|
||||
# error message, on error
|
||||
refute_output() {
|
||||
local -i is_match_line=0
|
||||
local -i is_match_contained=0
|
||||
local -i is_mode_partial=0
|
||||
local -i is_mode_regex=0
|
||||
|
||||
# Handle options.
|
||||
while (( $# > 0 )); do
|
||||
case "$1" in
|
||||
-l)
|
||||
if (( $# > 2 )) && [[ $2 =~ ^([0-9]|[1-9][0-9]+)$ ]]; then
|
||||
is_match_line=1
|
||||
local -ri idx="$2"
|
||||
shift
|
||||
else
|
||||
is_match_contained=1;
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
-L) is_match_contained=1; shift ;;
|
||||
-p) is_mode_partial=1; shift ;;
|
||||
-r) is_mode_regex=1; shift ;;
|
||||
--) break ;;
|
||||
*) break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if (( is_match_line )) && (( is_match_contained )); then
|
||||
echo "\`-l' and \`-l <index>' are mutually exclusive" \
|
||||
| batslib_decorate 'ERROR: refute_output' \
|
||||
| fail
|
||||
return $?
|
||||
fi
|
||||
|
||||
if (( is_mode_partial )) && (( is_mode_regex )); then
|
||||
echo "\`-p' and \`-r' are mutually exclusive" \
|
||||
| batslib_decorate 'ERROR: refute_output' \
|
||||
| fail
|
||||
return $?
|
||||
fi
|
||||
|
||||
# Arguments.
|
||||
local -r unexpected="$1"
|
||||
|
||||
if (( is_mode_regex == 1 )) && [[ '' =~ $unexpected ]] || (( $? == 2 )); then
|
||||
echo "Invalid extended regular expression: \`$unexpected'" \
|
||||
| batslib_decorate 'ERROR: refute_output' \
|
||||
| fail
|
||||
return $?
|
||||
fi
|
||||
|
||||
# Matching.
|
||||
if (( is_match_contained )); then
|
||||
# Line contained in output.
|
||||
if (( is_mode_regex )); then
|
||||
local -i idx
|
||||
for (( idx = 0; idx < ${#lines[@]}; ++idx )); do
|
||||
if [[ ${lines[$idx]} =~ $unexpected ]]; then
|
||||
{ local -ar single=(
|
||||
'regex' "$unexpected"
|
||||
'index' "$idx"
|
||||
)
|
||||
local -a may_be_multi=(
|
||||
'output' "$output"
|
||||
)
|
||||
local -ir width="$( batslib_get_max_single_line_key_width \
|
||||
"${single[@]}" "${may_be_multi[@]}" )"
|
||||
batslib_print_kv_single "$width" "${single[@]}"
|
||||
if batslib_is_single_line "${may_be_multi[1]}"; then
|
||||
batslib_print_kv_single "$width" "${may_be_multi[@]}"
|
||||
else
|
||||
may_be_multi[1]="$( printf '%s' "${may_be_multi[1]}" \
|
||||
| batslib_prefix \
|
||||
| batslib_mark '>' "$idx" )"
|
||||
batslib_print_kv_multi "${may_be_multi[@]}"
|
||||
fi
|
||||
} | batslib_decorate 'no line should match the regular expression' \
|
||||
| fail
|
||||
return $?
|
||||
fi
|
||||
done
|
||||
elif (( is_mode_partial )); then
|
||||
local -i idx
|
||||
for (( idx = 0; idx < ${#lines[@]}; ++idx )); do
|
||||
if [[ ${lines[$idx]} == *"$unexpected"* ]]; then
|
||||
{ local -ar single=(
|
||||
'substring' "$unexpected"
|
||||
'index' "$idx"
|
||||
)
|
||||
local -a may_be_multi=(
|
||||
'output' "$output"
|
||||
)
|
||||
local -ir width="$( batslib_get_max_single_line_key_width \
|
||||
"${single[@]}" "${may_be_multi[@]}" )"
|
||||
batslib_print_kv_single "$width" "${single[@]}"
|
||||
if batslib_is_single_line "${may_be_multi[1]}"; then
|
||||
batslib_print_kv_single "$width" "${may_be_multi[@]}"
|
||||
else
|
||||
may_be_multi[1]="$( printf '%s' "${may_be_multi[1]}" \
|
||||
| batslib_prefix \
|
||||
| batslib_mark '>' "$idx" )"
|
||||
batslib_print_kv_multi "${may_be_multi[@]}"
|
||||
fi
|
||||
} | batslib_decorate 'no line should contain substring' \
|
||||
| fail
|
||||
return $?
|
||||
fi
|
||||
done
|
||||
else
|
||||
local -i idx
|
||||
for (( idx = 0; idx < ${#lines[@]}; ++idx )); do
|
||||
if [[ ${lines[$idx]} == "$unexpected" ]]; then
|
||||
{ local -ar single=(
|
||||
'line' "$unexpected"
|
||||
'index' "$idx"
|
||||
)
|
||||
local -a may_be_multi=(
|
||||
'output' "$output"
|
||||
)
|
||||
local -ir width="$( batslib_get_max_single_line_key_width \
|
||||
"${single[@]}" "${may_be_multi[@]}" )"
|
||||
batslib_print_kv_single "$width" "${single[@]}"
|
||||
if batslib_is_single_line "${may_be_multi[1]}"; then
|
||||
batslib_print_kv_single "$width" "${may_be_multi[@]}"
|
||||
else
|
||||
may_be_multi[1]="$( printf '%s' "${may_be_multi[1]}" \
|
||||
| batslib_prefix \
|
||||
| batslib_mark '>' "$idx" )"
|
||||
batslib_print_kv_multi "${may_be_multi[@]}"
|
||||
fi
|
||||
} | batslib_decorate 'line should not be in output' \
|
||||
| fail
|
||||
return $?
|
||||
fi
|
||||
done
|
||||
fi
|
||||
elif (( is_match_line )); then
|
||||
# Specific line.
|
||||
if (( is_mode_regex )); then
|
||||
if [[ ${lines[$idx]} =~ $unexpected ]] || (( $? == 0 )); then
|
||||
batslib_print_kv_single 5 \
|
||||
'index' "$idx" \
|
||||
'regex' "$unexpected" \
|
||||
'line' "${lines[$idx]}" \
|
||||
| batslib_decorate 'regular expression should not match line' \
|
||||
| fail
|
||||
fi
|
||||
elif (( is_mode_partial )); then
|
||||
if [[ ${lines[$idx]} == *"$unexpected"* ]]; then
|
||||
batslib_print_kv_single 9 \
|
||||
'index' "$idx" \
|
||||
'substring' "$unexpected" \
|
||||
'line' "${lines[$idx]}" \
|
||||
| batslib_decorate 'line should not contain substring' \
|
||||
| fail
|
||||
fi
|
||||
else
|
||||
if [[ ${lines[$idx]} == "$unexpected" ]]; then
|
||||
batslib_print_kv_single 5 \
|
||||
'index' "$idx" \
|
||||
'line' "${lines[$idx]}" \
|
||||
| batslib_decorate 'line should differ' \
|
||||
| fail
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# Entire output.
|
||||
if (( is_mode_regex )); then
|
||||
if [[ $output =~ $unexpected ]] || (( $? == 0 )); then
|
||||
batslib_print_kv_single_or_multi 6 \
|
||||
'regex' "$unexpected" \
|
||||
'output' "$output" \
|
||||
| batslib_decorate 'regular expression should not match output' \
|
||||
| fail
|
||||
fi
|
||||
elif (( is_mode_partial )); then
|
||||
if [[ $output == *"$unexpected"* ]]; then
|
||||
batslib_print_kv_single_or_multi 9 \
|
||||
'substring' "$unexpected" \
|
||||
'output' "$output" \
|
||||
| batslib_decorate 'output should not contain substring' \
|
||||
| fail
|
||||
fi
|
||||
else
|
||||
if [[ $output == "$unexpected" ]]; then
|
||||
batslib_print_kv_single_or_multi 6 \
|
||||
'output' "$output" \
|
||||
| batslib_decorate 'output equals, but it was expected to differ' \
|
||||
| fail
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -1,264 +0,0 @@
|
||||
#
|
||||
# output.bash
|
||||
# -----------
|
||||
#
|
||||
# Private functions implementing output formatting. Used by public
|
||||
# helper functions.
|
||||
#
|
||||
|
||||
# Print a message to the standard error. When no parameters are
|
||||
# specified, the message is read from the standard input.
|
||||
#
|
||||
# Globals:
|
||||
# none
|
||||
# Arguments:
|
||||
# $@ - [=STDIN] message
|
||||
# Returns:
|
||||
# none
|
||||
# Inputs:
|
||||
# STDIN - [=$@] message
|
||||
# Outputs:
|
||||
# STDERR - message
|
||||
batslib_err() {
|
||||
{ if (( $# > 0 )); then
|
||||
echo "$@"
|
||||
else
|
||||
cat -
|
||||
fi
|
||||
} >&2
|
||||
}
|
||||
|
||||
# Count the number of lines in the given string.
|
||||
#
|
||||
# TODO(ztombol): Fix tests and remove this note after #93 is resolved!
|
||||
# NOTE: Due to a bug in Bats, `batslib_count_lines "$output"' does not
|
||||
# give the same result as `${#lines[@]}' when the output contains
|
||||
# empty lines.
|
||||
# See PR #93 (https://github.com/sstephenson/bats/pull/93).
|
||||
#
|
||||
# Globals:
|
||||
# none
|
||||
# Arguments:
|
||||
# $1 - string
|
||||
# Returns:
|
||||
# none
|
||||
# Outputs:
|
||||
# STDOUT - number of lines
|
||||
batslib_count_lines() {
|
||||
local -i n_lines=0
|
||||
local line
|
||||
while IFS='' read -r line || [[ -n $line ]]; do
|
||||
(( ++n_lines ))
|
||||
done < <(printf '%s' "$1")
|
||||
echo "$n_lines"
|
||||
}
|
||||
|
||||
# Determine whether all strings are single-line.
|
||||
#
|
||||
# Globals:
|
||||
# none
|
||||
# Arguments:
|
||||
# $@ - strings
|
||||
# Returns:
|
||||
# 0 - all strings are single-line
|
||||
# 1 - otherwise
|
||||
batslib_is_single_line() {
|
||||
for string in "$@"; do
|
||||
(( $(batslib_count_lines "$string") > 1 )) && return 1
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
# Determine the length of the longest key that has a single-line value.
|
||||
#
|
||||
# This function is useful in determining the correct width of the key
|
||||
# column in two-column format when some keys may have multi-line values
|
||||
# and thus should be excluded.
|
||||
#
|
||||
# Globals:
|
||||
# none
|
||||
# Arguments:
|
||||
# $odd - key
|
||||
# $even - value of the previous key
|
||||
# Returns:
|
||||
# none
|
||||
# Outputs:
|
||||
# STDOUT - length of longest key
|
||||
batslib_get_max_single_line_key_width() {
|
||||
local -i max_len=-1
|
||||
while (( $# != 0 )); do
|
||||
local -i key_len="${#1}"
|
||||
batslib_is_single_line "$2" && (( key_len > max_len )) && max_len="$key_len"
|
||||
shift 2
|
||||
done
|
||||
echo "$max_len"
|
||||
}
|
||||
|
||||
# Print key-value pairs in two-column format.
|
||||
#
|
||||
# Keys are displayed in the first column, and their corresponding values
|
||||
# in the second. To evenly line up values, the key column is fixed-width
|
||||
# and its width is specified with the first parameter (possibly computed
|
||||
# using `batslib_get_max_single_line_key_width').
|
||||
#
|
||||
# Globals:
|
||||
# none
|
||||
# Arguments:
|
||||
# $1 - width of key column
|
||||
# $even - key
|
||||
# $odd - value of the previous key
|
||||
# Returns:
|
||||
# none
|
||||
# Outputs:
|
||||
# STDOUT - formatted key-value pairs
|
||||
batslib_print_kv_single() {
|
||||
local -ir col_width="$1"; shift
|
||||
while (( $# != 0 )); do
|
||||
printf '%-*s : %s\n' "$col_width" "$1" "$2"
|
||||
shift 2
|
||||
done
|
||||
}
|
||||
|
||||
# Print key-value pairs in multi-line format.
|
||||
#
|
||||
# The key is displayed first with the number of lines of its
|
||||
# corresponding value in parenthesis. Next, starting on the next line,
|
||||
# the value is displayed. For better readability, it is recommended to
|
||||
# indent values using `batslib_prefix'.
|
||||
#
|
||||
# Globals:
|
||||
# none
|
||||
# Arguments:
|
||||
# $odd - key
|
||||
# $even - value of the previous key
|
||||
# Returns:
|
||||
# none
|
||||
# Outputs:
|
||||
# STDOUT - formatted key-value pairs
|
||||
batslib_print_kv_multi() {
|
||||
while (( $# != 0 )); do
|
||||
printf '%s (%d lines):\n' "$1" "$( batslib_count_lines "$2" )"
|
||||
printf '%s\n' "$2"
|
||||
shift 2
|
||||
done
|
||||
}
|
||||
|
||||
# Print all key-value pairs in either two-column or multi-line format
|
||||
# depending on whether all values are single-line.
|
||||
#
|
||||
# If all values are single-line, print all pairs in two-column format
|
||||
# with the specified key column width (identical to using
|
||||
# `batslib_print_kv_single').
|
||||
#
|
||||
# Otherwise, print all pairs in multi-line format after indenting values
|
||||
# with two spaces for readability (identical to using `batslib_prefix'
|
||||
# and `batslib_print_kv_multi')
|
||||
#
|
||||
# Globals:
|
||||
# none
|
||||
# Arguments:
|
||||
# $1 - width of key column (for two-column format)
|
||||
# $even - key
|
||||
# $odd - value of the previous key
|
||||
# Returns:
|
||||
# none
|
||||
# Outputs:
|
||||
# STDOUT - formatted key-value pairs
|
||||
batslib_print_kv_single_or_multi() {
|
||||
local -ir width="$1"; shift
|
||||
local -a pairs=( "$@" )
|
||||
|
||||
local -a values=()
|
||||
local -i i
|
||||
for (( i=1; i < ${#pairs[@]}; i+=2 )); do
|
||||
values+=( "${pairs[$i]}" )
|
||||
done
|
||||
|
||||
if batslib_is_single_line "${values[@]}"; then
|
||||
batslib_print_kv_single "$width" "${pairs[@]}"
|
||||
else
|
||||
local -i i
|
||||
for (( i=1; i < ${#pairs[@]}; i+=2 )); do
|
||||
pairs[$i]="$( batslib_prefix < <(printf '%s' "${pairs[$i]}") )"
|
||||
done
|
||||
batslib_print_kv_multi "${pairs[@]}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Prefix each line read from the standard input with the given string.
|
||||
#
|
||||
# Globals:
|
||||
# none
|
||||
# Arguments:
|
||||
# $1 - [= ] prefix string
|
||||
# Returns:
|
||||
# none
|
||||
# Inputs:
|
||||
# STDIN - lines
|
||||
# Outputs:
|
||||
# STDOUT - prefixed lines
|
||||
batslib_prefix() {
|
||||
local -r prefix="${1:- }"
|
||||
local line
|
||||
while IFS='' read -r line || [[ -n $line ]]; do
|
||||
printf '%s%s\n' "$prefix" "$line"
|
||||
done
|
||||
}
|
||||
|
||||
# Mark select lines of the text read from the standard input by
|
||||
# overwriting their beginning with the given string.
|
||||
#
|
||||
# Usually the input is indented by a few spaces using `batslib_prefix'
|
||||
# first.
|
||||
#
|
||||
# Globals:
|
||||
# none
|
||||
# Arguments:
|
||||
# $1 - marking string
|
||||
# $@ - indices (zero-based) of lines to mark
|
||||
# Returns:
|
||||
# none
|
||||
# Inputs:
|
||||
# STDIN - lines
|
||||
# Outputs:
|
||||
# STDOUT - lines after marking
|
||||
batslib_mark() {
|
||||
local -r symbol="$1"; shift
|
||||
# Sort line numbers.
|
||||
set -- $( sort -nu <<< "$( printf '%d\n' "$@" )" )
|
||||
|
||||
local line
|
||||
local -i idx=0
|
||||
while IFS='' read -r line || [[ -n $line ]]; do
|
||||
if (( ${1:--1} == idx )); then
|
||||
printf '%s\n' "${symbol}${line:${#symbol}}"
|
||||
shift
|
||||
else
|
||||
printf '%s\n' "$line"
|
||||
fi
|
||||
(( ++idx ))
|
||||
done
|
||||
}
|
||||
|
||||
# Enclose the input text in header and footer lines.
|
||||
#
|
||||
# The header contains the given string as title. The output is preceded
|
||||
# and followed by an additional newline to make it stand out more.
|
||||
#
|
||||
# Globals:
|
||||
# none
|
||||
# Arguments:
|
||||
# $1 - title
|
||||
# Returns:
|
||||
# none
|
||||
# Inputs:
|
||||
# STDIN - text
|
||||
# Outputs:
|
||||
# STDOUT - decorated text
|
||||
batslib_decorate() {
|
||||
echo
|
||||
echo "-- $1 --"
|
||||
cat -
|
||||
echo '--'
|
||||
echo
|
||||
}
|
||||
@ -1,66 +0,0 @@
|
||||
## functions to help deal with docker
|
||||
|
||||
# Removes container $1
|
||||
function docker_clean {
|
||||
docker kill $1 &>/dev/null ||:
|
||||
sleep .25s
|
||||
docker rm -vf $1 &>/dev/null ||:
|
||||
sleep .25s
|
||||
}
|
||||
|
||||
# get the ip of docker container $1
|
||||
function docker_ip {
|
||||
docker inspect --format '{{ .NetworkSettings.IPAddress }}' $1
|
||||
}
|
||||
|
||||
# get the ip of docker container $1
|
||||
function docker_id {
|
||||
docker inspect --format '{{ .ID }}' $1
|
||||
}
|
||||
|
||||
# get the running state of container $1
|
||||
# → true/false
|
||||
# fails if the container does not exist
|
||||
function docker_running_state {
|
||||
docker inspect -f {{.State.Running}} $1
|
||||
}
|
||||
|
||||
# get the docker container $1 PID
|
||||
function docker_pid {
|
||||
docker inspect --format {{.State.Pid}} $1
|
||||
}
|
||||
|
||||
# asserts logs from container $1 contains $2
|
||||
function docker_assert_log {
|
||||
local -r container=$1
|
||||
shift
|
||||
run docker logs $container
|
||||
assert_output -p "$*"
|
||||
}
|
||||
|
||||
# wait for a container to produce a given text in its log
|
||||
# $1 container
|
||||
# $2 timeout in second
|
||||
# $* text to wait for
|
||||
function docker_wait_for_log {
|
||||
local -r container=$1
|
||||
local -ir timeout_sec=$2
|
||||
shift 2
|
||||
retry $(( $timeout_sec * 2 )) .5s docker_assert_log $container "$*"
|
||||
}
|
||||
|
||||
# Create a docker container named $1 which exposes the docker host unix
|
||||
# socket over tcp on port 2375.
|
||||
#
|
||||
# $1 container name
|
||||
function docker_tcp {
|
||||
local container_name="$1"
|
||||
docker_clean $container_name
|
||||
docker run -d \
|
||||
--label bats-type="socat" \
|
||||
--name $container_name \
|
||||
--expose 2375 \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
rancher/socat-docker
|
||||
docker run --label bats-type="docker" --link "$container_name:docker" docker:1.10 version
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
## add the retry function to bats
|
||||
|
||||
# Retry a command $1 times until it succeeds. Wait $2 seconds between retries.
|
||||
function retry {
|
||||
local attempts=$1
|
||||
shift
|
||||
local delay=$1
|
||||
shift
|
||||
local i
|
||||
|
||||
for ((i=0; i < attempts; i++)); do
|
||||
run "$@"
|
||||
if [ "$status" -eq 0 ]; then
|
||||
echo "$output"
|
||||
return 0
|
||||
fi
|
||||
sleep $delay
|
||||
done
|
||||
|
||||
echo "Command \"$@\" failed $attempts times. Status: $status. Output: $output" >&2
|
||||
false
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIID7TCCAtWgAwIBAgIJAOGkf5EnexJVMA0GCSqGSIb3DQEBCwUAMIGMMQswCQYD
|
||||
VQQGEwJVUzERMA8GA1UECAwIVmlyZ2luaWExDzANBgNVBAcMBlJlc3RvbjERMA8G
|
||||
A1UECgwIRmFrZSBPcmcxGzAZBgNVBAMMEioubmdpbngtcHJveHkuYmF0czEpMCcG
|
||||
CSqGSIb3DQEJARYad2VibWFzdGVyQG5naW54LXByb3h5LmJhdHMwHhcNMTYwNDIw
|
||||
MTUzOTUxWhcNMjYwNDE4MTUzOTUxWjCBjDELMAkGA1UEBhMCVVMxETAPBgNVBAgM
|
||||
CFZpcmdpbmlhMQ8wDQYDVQQHDAZSZXN0b24xETAPBgNVBAoMCEZha2UgT3JnMRsw
|
||||
GQYDVQQDDBIqLm5naW54LXByb3h5LmJhdHMxKTAnBgkqhkiG9w0BCQEWGndlYm1h
|
||||
c3RlckBuZ2lueC1wcm94eS5iYXRzMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
|
||||
CgKCAQEA0Amkj3iaQn8Z2CW6n24zSuWu2OoLCkHZAk8eprkI4kKoPBvjusynkm8E
|
||||
phq65jebToHoldfuQ0wM61DzhD15bHwS3x9CrOVbShsmdnGALz+wdR0/4Likx50I
|
||||
YZdecTOAlkoZudnX5FZ4ngOxjqcym7p5T8TrSS97a0fx99gitZY0p+Nu2tip4o3t
|
||||
WBMs+SoPWTlQ1SrSmL8chC8O2knyBl/w1nHmDnMuR6FGcHdhLncApw9t5spgfv7p
|
||||
OrMF4tQxJQNk10TnflmEMkGmy+pfk2e0cQ1Kwp3Nmzm7ECkggxxyjU3ihKiFK+09
|
||||
8aSCi7gDAY925+mV6LZ5oLMpO3KJvQIDAQABo1AwTjAdBgNVHQ4EFgQU+NvFo37z
|
||||
9Dyq8Mu82SPtV7q1gYQwHwYDVR0jBBgwFoAU+NvFo37z9Dyq8Mu82SPtV7q1gYQw
|
||||
DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAI1ityDV0UsCVHSpB2LN+
|
||||
QXlk8XS0ACIJ8Q0hbOj3BmYrdAVglG4P6upDEueaaxwsaBTagkTP8nxZ9dhfZHyZ
|
||||
5YLNwYsiG5iqb8e0ecHx3uJT/0YiXn/8rBvxEZna4Fl8seGdp7BjOWUAS2Nv8tn4
|
||||
EJJvRdfX/O8XgPc95DM4lwQ/dvyWmavMI4lnl0n1IQV9WPGaIQhYPU9WEQK6iMUB
|
||||
o1kx8YbOJQD0ZBRfqpriNt1/8ylkkSYYav8QT9JFvQFCWEvaX71QF+cuOwC7ZYBH
|
||||
4ElXwEUrYBHKiPo0q0VsTtMvLh7h/T5czrIhG/NpfVJPtQOk8aVwNScL3/n+TGU8
|
||||
6g==
|
||||
-----END CERTIFICATE-----
|
||||
@ -1,28 +0,0 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDQCaSPeJpCfxnY
|
||||
JbqfbjNK5a7Y6gsKQdkCTx6muQjiQqg8G+O6zKeSbwSmGrrmN5tOgeiV1+5DTAzr
|
||||
UPOEPXlsfBLfH0Ks5VtKGyZ2cYAvP7B1HT/guKTHnQhhl15xM4CWShm52dfkVnie
|
||||
A7GOpzKbunlPxOtJL3trR/H32CK1ljSn427a2Knije1YEyz5Kg9ZOVDVKtKYvxyE
|
||||
Lw7aSfIGX/DWceYOcy5HoUZwd2EudwCnD23mymB+/uk6swXi1DElA2TXROd+WYQy
|
||||
QabL6l+TZ7RxDUrCnc2bObsQKSCDHHKNTeKEqIUr7T3xpIKLuAMBj3bn6ZXotnmg
|
||||
syk7com9AgMBAAECggEAa7wCp3XqVPNjW+c1/ShhkbDeWmDhtL8i9aopkmeSbTHd
|
||||
07sRtQQU56Vsf+Sp010KpZ5q52Z6cglpS1eRtHLtdbvPPhL/QXBJVVg4E/B1VIKk
|
||||
DBJIqUSVuPXeiEOOWgs01R+ssO1ae1o4foQlKF33vGPWPPQacL0RKh6I9TPNzcD7
|
||||
n4rujlHk72N/bNydyK2rnyKB4vAI5TbZPLps+Xe123CmgZnW3JClcWV9B4foRmiu
|
||||
a5Iq1WYAK2GYKbYwgqDRyYBC27m91a7U31pE4GQD+xQdlz6kcOlCU5hAcPK3h7j0
|
||||
fLQqn8g+YAtc0nBKKB4NZe3QEzTiVMorT0VitxI71QKBgQDnirardZaXOFzYGzB3
|
||||
j+FGB9BUW54hnHr5BxOYrfmEJ5umJjJWaGupfYrQsPArrJP1//WbqVZIPvdQParD
|
||||
mQhLmSp1r/VNzGB6pISmzU1ZGDHsmBxYseh366om5YBQUFU2vmbil9VkrkM4fsJG
|
||||
tcS9V/nVY/EM7Yp3PzjfLlhC1wKBgQDmA1YJmnZvIbLp3PoKqM69QiCLKztVm7nX
|
||||
xpu3b3qbXEzXkt2sP5PHmr+s13hOPQFKRJ2hk4UN9WqpnFoHw5E5eWWhSa/peUZm
|
||||
r10Y5XspiFtRHHiu6ABXB49eB4fen+vHEZHKyRJ4rFthKjjBHdNPC8bmwnT3jE85
|
||||
/8a26FLZiwKBgQDXEi8JZslBn9YF2oOTm28KCLoHka551AsaA+u892T8z3mxxGsf
|
||||
fhD7N6TYonIEb2Jkr6OpOortwqcgvpc+5oghCJ27AX2fDUdUxDp/YdYF+wZsmQJD
|
||||
lMW1lo7PYIBmmaf9mLCiq5xIz+GauYul+LNNmUl0YEgI1SC4EV63WCodswKBgDMX
|
||||
GJxHd/kVViVGFTAa8NjvAEWJU8OfNHduQRZMp8IsjVDw6VYiRRP4Fo0wyyMtv8Sc
|
||||
WxsRpmNEWO3VsdW5pd9LTLy3nmBQtMeIOjiWeHXwOMBaf5/yHmk2X6z2JULY6Mkt
|
||||
6OFPKlAtkJqTg0m58z7Ckeqd1NdLjimG27+y+PwjAoGAFt0cbC1Ust2BE6YEspSX
|
||||
ofpAnJsyKrbF9iVUyXDUP99sdqYQfPJ5uqPGkP59lJGkTLtebuitqi6FCyrsT6Fq
|
||||
AWLiExbqebAqcuAZw2S+iuK27S4rrkjVGF53J7vH3rOzCBUXaRx6GKfTjUqedHdg
|
||||
9Kw+LP6IFnMTb+EGLo+GqHs=
|
||||
-----END PRIVATE KEY-----
|
||||
@ -1,43 +0,0 @@
|
||||
#!/usr/bin/env bats
|
||||
load test_helpers
|
||||
SUT_CONTAINER=bats-nginx-proxy-${TEST_FILE}
|
||||
|
||||
function setup {
|
||||
# make sure to stop any web container before each test so we don't
|
||||
# have any unexpected contaiener running with VIRTUAL_HOST or VIRUTAL_PORT set
|
||||
stop_bats_containers web
|
||||
}
|
||||
|
||||
|
||||
@test "[$TEST_FILE] start a nginx-proxy container" {
|
||||
run nginxproxy $SUT_CONTAINER -v /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
assert_success
|
||||
docker_wait_for_log $SUT_CONTAINER 9 "Watching docker events"
|
||||
}
|
||||
|
||||
@test "[$TEST_FILE] nginx-proxy forwards requests for 2 hosts" {
|
||||
# WHEN a container runs a web server with VIRTUAL_HOST set for multiple hosts
|
||||
prepare_web_container bats-multiple-hosts-1 80 -e VIRTUAL_HOST=multiple-hosts-1-A.bats,multiple-hosts-1-B.bats
|
||||
dockergen_wait_for_event $SUT_CONTAINER start bats-multiple-hosts-1
|
||||
sleep 1
|
||||
|
||||
# THEN querying the proxy without Host header → 503
|
||||
run curl_container $SUT_CONTAINER / --head
|
||||
assert_output -l 0 $'HTTP/1.1 503 Service Temporarily Unavailable\r'
|
||||
|
||||
# THEN querying the proxy with unknown Host header → 503
|
||||
run curl_container $SUT_CONTAINER /data --header "Host: webFOO.bats" --head
|
||||
assert_output -l 0 $'HTTP/1.1 503 Service Temporarily Unavailable\r'
|
||||
|
||||
# THEN
|
||||
run curl_container $SUT_CONTAINER /data --header 'Host: multiple-hosts-1-A.bats'
|
||||
assert_output "answer from port 80"
|
||||
|
||||
# THEN
|
||||
run curl_container $SUT_CONTAINER /data --header 'Host: multiple-hosts-1-B.bats'
|
||||
assert_output "answer from port 80"
|
||||
}
|
||||
|
||||
@test "[$TEST_FILE] stop all bats containers" {
|
||||
stop_bats_containers
|
||||
}
|
||||
@ -1,64 +0,0 @@
|
||||
#!/usr/bin/env bats
|
||||
load test_helpers
|
||||
SUT_CONTAINER=bats-nginx-proxy-${TEST_FILE}
|
||||
|
||||
function setup {
|
||||
# make sure to stop any web container before each test so we don't
|
||||
# have any unexpected contaiener running with VIRTUAL_HOST or VIRUTAL_PORT set
|
||||
stop_bats_containers web
|
||||
}
|
||||
|
||||
|
||||
@test "[$TEST_FILE] start a nginx-proxy container" {
|
||||
# GIVEN nginx-proxy
|
||||
run nginxproxy $SUT_CONTAINER -v /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
assert_success
|
||||
docker_wait_for_log $SUT_CONTAINER 9 "Watching docker events"
|
||||
}
|
||||
|
||||
|
||||
@test "[$TEST_FILE] nginx-proxy defaults to the service running on port 80" {
|
||||
# WHEN
|
||||
prepare_web_container bats-web-${TEST_FILE}-1 "80 90" -e VIRTUAL_HOST=web.bats
|
||||
dockergen_wait_for_event $SUT_CONTAINER start bats-web-${TEST_FILE}-1
|
||||
sleep 1
|
||||
|
||||
# THEN
|
||||
assert_response_is_from_port 80
|
||||
}
|
||||
|
||||
|
||||
@test "[$TEST_FILE] VIRTUAL_PORT=90 while port 80 is also exposed" {
|
||||
# GIVEN
|
||||
prepare_web_container bats-web-${TEST_FILE}-2 "80 90" -e VIRTUAL_HOST=web.bats -e VIRTUAL_PORT=90
|
||||
dockergen_wait_for_event $SUT_CONTAINER start bats-web-${TEST_FILE}-2
|
||||
sleep 1
|
||||
|
||||
# THEN
|
||||
assert_response_is_from_port 90
|
||||
}
|
||||
|
||||
|
||||
@test "[$TEST_FILE] single exposed port != 80" {
|
||||
# GIVEN
|
||||
prepare_web_container bats-web-${TEST_FILE}-3 1234 -e VIRTUAL_HOST=web.bats
|
||||
dockergen_wait_for_event $SUT_CONTAINER start bats-web-${TEST_FILE}-3
|
||||
sleep 1
|
||||
|
||||
# THEN
|
||||
assert_response_is_from_port 1234
|
||||
}
|
||||
|
||||
@test "[$TEST_FILE] stop all bats containers" {
|
||||
stop_bats_containers
|
||||
}
|
||||
|
||||
|
||||
# assert querying nginx-proxy provides a response from the expected port of the web container
|
||||
# $1 port we are expecting an response from
|
||||
function assert_response_is_from_port {
|
||||
local -r port=$1
|
||||
run curl_container $SUT_CONTAINER /data --header "Host: web.bats"
|
||||
assert_output "answer from port $port"
|
||||
}
|
||||
|
||||
5
test/pytest.ini
Normal file
5
test/pytest.ini
Normal file
@ -0,0 +1,5 @@
|
||||
[pytest]
|
||||
# disable the creation of the `.cache` folders
|
||||
addopts = -p no:cacheprovider --ignore=requirements --ignore=certs -r s -v
|
||||
markers =
|
||||
incremental: mark a test as incremental.
|
||||
28
test/pytest.sh
Executable file
28
test/pytest.sh
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
###############################################################################
|
||||
# #
|
||||
# This script is meant to run the test suite from a Docker container. #
|
||||
# #
|
||||
# This is usefull when you want to run the test suite from Mac or #
|
||||
# Docker Toolbox. #
|
||||
# #
|
||||
###############################################################################
|
||||
|
||||
# Returns the absolute directory path to this script
|
||||
TESTDIR=$(cd "${0%/*}" && pwd) || exit 1
|
||||
DIR=$(cd "${TESTDIR}/.." && pwd) || exit 1
|
||||
|
||||
# check requirements
|
||||
echo "> Building nginx-proxy-tester image..."
|
||||
docker build --pull -t nginx-proxy-tester \
|
||||
-f "${TESTDIR}/requirements/Dockerfile-nginx-proxy-tester" \
|
||||
"${TESTDIR}/requirements" \
|
||||
|| exit 1
|
||||
|
||||
# run the nginx-proxy-tester container setting the correct value for the working dir in order for
|
||||
# docker-compose to work properly when run from within that container.
|
||||
exec docker run --rm -it --name "nginx-proxy-pytest" \
|
||||
--volume "/var/run/docker.sock:/var/run/docker.sock" \
|
||||
--volume "${DIR}:${DIR}" \
|
||||
--workdir "${TESTDIR}" \
|
||||
nginx-proxy-tester "$@"
|
||||
9
test/requirements/Dockerfile-nginx-proxy-tester
Normal file
9
test/requirements/Dockerfile-nginx-proxy-tester
Normal file
@ -0,0 +1,9 @@
|
||||
FROM python:3.9
|
||||
|
||||
ENV PYTEST_RUNNING_IN_CONTAINER=1
|
||||
|
||||
COPY python-requirements.txt /requirements.txt
|
||||
RUN pip install -r /requirements.txt
|
||||
|
||||
WORKDIR /test
|
||||
ENTRYPOINT ["pytest"]
|
||||
52
test/requirements/README.md
Normal file
52
test/requirements/README.md
Normal file
@ -0,0 +1,52 @@
|
||||
This directory contains resources to build Docker images tests depend on
|
||||
|
||||
# Build images
|
||||
|
||||
make build-webserver
|
||||
|
||||
|
||||
# python-requirements.txt
|
||||
|
||||
If you want to run the test suite from your computer, you need python and a few python modules.
|
||||
The _python-requirements.txt_ file describes the python modules required. To install them, use
|
||||
pip:
|
||||
|
||||
pip install -r python-requirements.txt
|
||||
|
||||
If you don't want to run the test from your computer, you can run the tests from a docker container, see the _pytest.sh_ script.
|
||||
|
||||
|
||||
# Images
|
||||
|
||||
## web
|
||||
|
||||
This container will run one or many webservers, each of them listening on a single port.
|
||||
|
||||
Ports are specified using the `WEB_PORTS` environment variable:
|
||||
|
||||
docker run -d -e WEB_PORTS=80 web # will create a container running one webserver listening on port 80
|
||||
docker run -d -e WEB_PORTS="80 81" web # will create a container running two webservers, one listening on port 80 and a second one listening on port 81
|
||||
|
||||
The webserver answers on two paths:
|
||||
|
||||
- `/headers`
|
||||
- `/port`
|
||||
|
||||
```
|
||||
$ docker run -d -e WEB_PORTS=80 -p 80:80 web
|
||||
$ curl http://127.0.0.1:80/headers
|
||||
Host: 127.0.0.1
|
||||
User-Agent: curl/7.47.0
|
||||
Accept: */*
|
||||
|
||||
$ curl http://127.0.0.1:80/port
|
||||
answer from port 80
|
||||
|
||||
```
|
||||
|
||||
|
||||
## nginx-proxy-tester
|
||||
|
||||
This is an optional requirement which is usefull if you cannot (or don't want to) install pytest and its requirements on your computer. In this case, you can use the `nginx-proxy-tester` docker image to run the test suite from a Docker container.
|
||||
|
||||
To use this image, it is mandatory to run the container using the `pytest.sh` shell script. The script will build the image and run a container from it with the appropriate volumes and settings.
|
||||
5
test/requirements/python-requirements.txt
Normal file
5
test/requirements/python-requirements.txt
Normal file
@ -0,0 +1,5 @@
|
||||
backoff==2.2.1
|
||||
docker-compose==1.29.2
|
||||
docker==6.0.1
|
||||
pytest==7.2.2
|
||||
requests==2.28.2
|
||||
8
test/requirements/web/Dockerfile
Normal file
8
test/requirements/web/Dockerfile
Normal file
@ -0,0 +1,8 @@
|
||||
# Docker Image running one (or multiple) webservers listening on all given ports from WEB_PORTS environment variable
|
||||
|
||||
FROM python:3
|
||||
COPY ./webserver.py /
|
||||
COPY ./entrypoint.sh /
|
||||
WORKDIR /opt
|
||||
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
|
||||
|
||||
15
test/requirements/web/entrypoint.sh
Normal file
15
test/requirements/web/entrypoint.sh
Normal file
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
set -u
|
||||
|
||||
trap '[ ${#PIDS[@]} -gt 0 ] && kill -TERM ${PIDS[@]}' TERM
|
||||
declare -a PIDS
|
||||
|
||||
for port in $WEB_PORTS; do
|
||||
echo starting a web server listening on port $port;
|
||||
/webserver.py $port &
|
||||
PIDS+=($!)
|
||||
done
|
||||
|
||||
wait ${PIDS[@]}
|
||||
trap - TERM
|
||||
wait ${PIDS[@]}
|
||||
38
test/requirements/web/webserver.py
Executable file
38
test/requirements/web/webserver.py
Executable file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os, sys, re
|
||||
import http.server
|
||||
import socketserver
|
||||
|
||||
class Handler(http.server.SimpleHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
|
||||
response_body = ""
|
||||
response_code = 200
|
||||
|
||||
if self.path == "/headers":
|
||||
response_body += self.headers.as_string()
|
||||
elif self.path == "/port":
|
||||
response_body += f"answer from port {PORT}\n"
|
||||
elif re.match("/status/(\d+)", self.path):
|
||||
result = re.match("/status/(\d+)", self.path)
|
||||
response_code = int(result.group(1))
|
||||
response_body += f"answer with response code {response_code}\n"
|
||||
elif self.path == "/":
|
||||
response_body += f"I'm {os.environ['HOSTNAME']}\n"
|
||||
else:
|
||||
response_body += "No route for this path!\n"
|
||||
response_code = 404
|
||||
|
||||
self.send_response(response_code)
|
||||
self.send_header("Content-Type", "text/plain")
|
||||
self.end_headers()
|
||||
|
||||
if (len(response_body)):
|
||||
self.wfile.write(response_body.encode())
|
||||
|
||||
if __name__ == '__main__':
|
||||
PORT = int(sys.argv[1])
|
||||
socketserver.TCPServer.allow_reuse_address = True
|
||||
httpd = socketserver.TCPServer(('0.0.0.0', PORT), Handler)
|
||||
httpd.serve_forever()
|
||||
146
test/ssl.bats
146
test/ssl.bats
@ -1,146 +0,0 @@
|
||||
#!/usr/bin/env bats
|
||||
load test_helpers
|
||||
SUT_CONTAINER=bats-nginx-proxy-${TEST_FILE}
|
||||
|
||||
function setup {
|
||||
# make sure to stop any web container before each test so we don't
|
||||
# have any unexpected contaiener running with VIRTUAL_HOST or VIRUTAL_PORT set
|
||||
stop_bats_containers web
|
||||
}
|
||||
|
||||
|
||||
@test "[$TEST_FILE] start a nginx-proxy container" {
|
||||
run nginxproxy $SUT_CONTAINER -v /var/run/docker.sock:/tmp/docker.sock:ro -v ${DIR}/lib/ssl:/etc/nginx/certs:ro
|
||||
assert_success
|
||||
docker_wait_for_log $SUT_CONTAINER 9 "Watching docker events"
|
||||
}
|
||||
|
||||
@test "[$TEST_FILE] test SSL for VIRTUAL_HOST=*.nginx-proxy.bats" {
|
||||
# WHEN
|
||||
prepare_web_container bats-ssl-hosts-1 "80 443" \
|
||||
-e VIRTUAL_HOST=*.nginx-proxy.bats \
|
||||
-e CERT_NAME=nginx-proxy.bats
|
||||
dockergen_wait_for_event $SUT_CONTAINER start bats-ssl-hosts-1
|
||||
sleep 1
|
||||
|
||||
# THEN
|
||||
assert_301 test.nginx-proxy.bats
|
||||
assert_200_https test.nginx-proxy.bats
|
||||
}
|
||||
|
||||
@test "[$TEST_FILE] test HTTPS_METHOD=nohttp" {
|
||||
# WHEN
|
||||
prepare_web_container bats-ssl-hosts-2 "80 443" \
|
||||
-e VIRTUAL_HOST=*.nginx-proxy.bats \
|
||||
-e CERT_NAME=nginx-proxy.bats \
|
||||
-e HTTPS_METHOD=nohttp
|
||||
dockergen_wait_for_event $SUT_CONTAINER start bats-ssl-hosts-2
|
||||
sleep 1
|
||||
|
||||
# THEN
|
||||
assert_503 test.nginx-proxy.bats
|
||||
assert_200_https test.nginx-proxy.bats
|
||||
}
|
||||
|
||||
@test "[$TEST_FILE] test HTTPS_METHOD=noredirect" {
|
||||
# WHEN
|
||||
prepare_web_container bats-ssl-hosts-3 "80 443" \
|
||||
-e VIRTUAL_HOST=*.nginx-proxy.bats \
|
||||
-e CERT_NAME=nginx-proxy.bats \
|
||||
-e HTTPS_METHOD=noredirect
|
||||
dockergen_wait_for_event $SUT_CONTAINER start bats-ssl-hosts-3
|
||||
sleep 1
|
||||
|
||||
# THEN
|
||||
assert_200 test.nginx-proxy.bats
|
||||
assert_200_https test.nginx-proxy.bats
|
||||
}
|
||||
|
||||
@test "[$TEST_FILE] test SSL Strict-Transport-Security" {
|
||||
# WHEN
|
||||
prepare_web_container bats-ssl-hosts-4 "80 443" \
|
||||
-e VIRTUAL_HOST=*.nginx-proxy.bats \
|
||||
-e CERT_NAME=nginx-proxy.bats
|
||||
dockergen_wait_for_event $SUT_CONTAINER start bats-ssl-hosts-1
|
||||
sleep 1
|
||||
|
||||
# THEN
|
||||
assert_301 test.nginx-proxy.bats
|
||||
assert_200_https test.nginx-proxy.bats
|
||||
assert_output -p "Strict-Transport-Security: max-age=31536000"
|
||||
}
|
||||
|
||||
@test "[$TEST_FILE] test HTTPS_METHOD=noredirect disables Strict-Transport-Security" {
|
||||
# WHEN
|
||||
prepare_web_container bats-ssl-hosts-5 "80 443" \
|
||||
-e VIRTUAL_HOST=*.nginx-proxy.bats \
|
||||
-e CERT_NAME=nginx-proxy.bats \
|
||||
-e HTTPS_METHOD=noredirect
|
||||
dockergen_wait_for_event $SUT_CONTAINER start bats-ssl-hosts-3
|
||||
sleep 1
|
||||
|
||||
# THEN
|
||||
assert_200 test.nginx-proxy.bats
|
||||
assert_200_https test.nginx-proxy.bats
|
||||
refute_output -p "Strict-Transport-Security: max-age=31536000"
|
||||
}
|
||||
|
||||
|
||||
@test "[$TEST_FILE] stop all bats containers" {
|
||||
stop_bats_containers
|
||||
}
|
||||
|
||||
|
||||
# assert that querying nginx-proxy with the given Host header produces a `HTTP 200` response
|
||||
# $1 Host HTTP header to use when querying nginx-proxy
|
||||
function assert_200 {
|
||||
local -r host=$1
|
||||
|
||||
run curl_container $SUT_CONTAINER / --head --header "Host: $host"
|
||||
assert_output -l 0 $'HTTP/1.1 200 OK\r'
|
||||
}
|
||||
|
||||
# assert that querying nginx-proxy with the given Host header produces a `HTTP 503` response
|
||||
# $1 Host HTTP header to use when querying nginx-proxy
|
||||
function assert_503 {
|
||||
local -r host=$1
|
||||
|
||||
run curl_container $SUT_CONTAINER / --head --header "Host: $host"
|
||||
assert_output -l 0 $'HTTP/1.1 503 Service Temporarily Unavailable\r'
|
||||
}
|
||||
|
||||
# assert that querying nginx-proxy with the given Host header produces a `HTTP 503` response
|
||||
# $1 Host HTTP header to use when querying nginx-proxy
|
||||
function assert_301 {
|
||||
local -r host=$1
|
||||
|
||||
run curl_container $SUT_CONTAINER / --head --header "Host: $host"
|
||||
assert_output -l 0 $'HTTP/1.1 301 Moved Permanently\r'
|
||||
}
|
||||
|
||||
# assert that querying nginx-proxy with the given Host header produces a `HTTP 200` response
|
||||
# $1 Host HTTP header to use when querying nginx-proxy
|
||||
function assert_200_https {
|
||||
local -r host=$1
|
||||
|
||||
run curl_container_https $SUT_CONTAINER / --head --header "Host: $host"
|
||||
assert_output -l 0 $'HTTP/1.1 200 OK\r'
|
||||
}
|
||||
|
||||
# assert that querying nginx-proxy with the given Host header produces a `HTTP 503` response
|
||||
# $1 Host HTTP header to use when querying nginx-proxy
|
||||
function assert_503_https {
|
||||
local -r host=$1
|
||||
|
||||
run curl_container_https $SUT_CONTAINER / --head --header "Host: $host"
|
||||
assert_output -l 0 $'HTTP/1.1 503 Service Temporarily Unavailable\r'
|
||||
}
|
||||
|
||||
# assert that querying nginx-proxy with the given Host header produces a `HTTP 503` response
|
||||
# $1 Host HTTP header to use when querying nginx-proxy
|
||||
function assert_301_https {
|
||||
local -r host=$1
|
||||
|
||||
run curl_container_https $SUT_CONTAINER / --head --header "Host: $host"
|
||||
assert_output -l 0 $'HTTP/1.1 301 Moved Permanently\r'
|
||||
}
|
||||
1
test/stress_tests/README.md
Normal file
1
test/stress_tests/README.md
Normal file
@ -0,0 +1 @@
|
||||
This directory contains tests that showcase scenarios known to break the expected behavior of nginx-proxy.
|
||||
5
test/stress_tests/test_deleted_cert/README.md
Normal file
5
test/stress_tests/test_deleted_cert/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
Test the behavior of nginx-proxy when restarted after deleting a certificate file is was using.
|
||||
|
||||
1. nginx-proxy is created with a virtual host having a certificate
|
||||
1. while nginx-proxy is running, the certificate file is deleted
|
||||
1. nginx-proxy is then restarted (without removing the container)
|
||||
@ -0,0 +1,70 @@
|
||||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number: 4096 (0x1000)
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
Issuer: O=nginx-proxy test suite, CN=www.nginx-proxy.tld
|
||||
Validity
|
||||
Not Before: Feb 17 23:20:54 2017 GMT
|
||||
Not After : Jul 5 23:20:54 2044 GMT
|
||||
Subject: CN=web.nginx-proxy
|
||||
Subject Public Key Info:
|
||||
Public Key Algorithm: rsaEncryption
|
||||
Public-Key: (2048 bit)
|
||||
Modulus:
|
||||
00:b6:27:63:a5:c6:e8:f4:7a:94:0e:cc:a2:62:76:
|
||||
6d:5d:33:6f:cf:19:fc:e7:e5:bb:0e:0e:d0:7c:4f:
|
||||
73:4c:48:2b:17:d1:4d:d5:9f:42:08:73:84:54:8c:
|
||||
86:d2:c5:da:59:01:3f:42:22:e0:36:f0:dc:ab:de:
|
||||
0a:bd:26:2b:22:13:87:a6:1f:23:ef:0e:99:27:8b:
|
||||
15:4a:1b:ef:93:c9:6b:91:de:a0:02:0c:62:bb:cc:
|
||||
56:37:e8:25:92:c3:1f:f1:69:d8:7c:a8:33:e0:89:
|
||||
ce:14:67:a0:39:77:88:91:e6:a3:07:97:90:22:88:
|
||||
d0:79:18:63:fb:6f:7e:ee:2b:42:7e:23:f5:e7:da:
|
||||
e9:ee:6a:fa:96:65:9f:e1:2b:15:49:c8:cd:2d:ce:
|
||||
86:4f:2c:2a:67:79:bf:41:30:14:cc:f6:0f:14:74:
|
||||
9e:b6:d3:d0:3b:f0:1b:b8:e8:19:2a:fd:d6:fd:dc:
|
||||
4b:4e:65:7d:9b:bf:37:7e:2d:35:22:2e:74:90:ce:
|
||||
41:35:3d:41:a0:99:db:97:1f:bf:3e:18:3c:48:fb:
|
||||
da:df:c6:4e:4e:b9:67:b8:10:d5:a5:13:03:c4:b7:
|
||||
65:e7:aa:f0:14:4b:d3:4d:ea:fe:8f:69:cf:50:21:
|
||||
63:27:cf:9e:4c:67:15:7b:3f:3b:da:cb:17:80:61:
|
||||
1e:25
|
||||
Exponent: 65537 (0x10001)
|
||||
X509v3 extensions:
|
||||
X509v3 Subject Alternative Name:
|
||||
DNS:web.nginx-proxy
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
09:31:be:db:4e:b0:b6:68:da:ae:5b:16:51:29:fc:9f:61:b6:
|
||||
5a:2f:3c:35:ef:67:76:97:b0:34:4e:3b:b4:d6:88:19:4f:84:
|
||||
2e:73:d3:c0:3a:4c:41:54:6c:bb:67:89:67:ad:25:55:d7:d4:
|
||||
80:fe:a7:3f:3d:9e:f1:34:96:d8:da:5a:78:51:c0:63:f1:52:
|
||||
29:35:55:f4:7d:70:1c:d3:96:62:7f:64:86:81:52:27:c4:c6:
|
||||
10:13:c6:73:56:4d:32:d0:b3:c3:c8:2c:25:83:e4:2b:1d:d4:
|
||||
74:30:e5:85:af:2d:b6:a5:6b:fe:5d:d3:3c:00:58:94:f4:6a:
|
||||
f5:a6:1d:cf:f9:ed:d5:27:ed:13:24:b2:4f:2b:f3:b8:e4:af:
|
||||
0c:1d:fe:e0:6a:01:5e:a2:44:ff:3e:96:fa:6c:39:a3:51:37:
|
||||
f3:72:55:d8:2d:29:6e:de:95:b9:d8:e3:1e:65:a5:9c:0d:79:
|
||||
2d:39:ab:c7:ac:16:b6:a5:71:4b:35:a4:6c:72:47:1b:72:9c:
|
||||
67:58:c1:fc:f6:7f:a7:73:50:7b:d6:27:57:74:a1:31:38:a7:
|
||||
31:e3:b9:d4:c9:45:33:ec:ed:16:cf:c5:bd:d0:03:b1:45:3f:
|
||||
68:0d:91:5c:26:4e:37:05:74:ed:3e:75:5e:ca:5e:ee:e2:51:
|
||||
4b:da:08:99
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIC8zCCAdugAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPzEfMB0GA1UECgwWbmdp
|
||||
bngtcHJveHkgdGVzdCBzdWl0ZTEcMBoGA1UEAwwTd3d3Lm5naW54LXByb3h5LnRs
|
||||
ZDAeFw0xNzAyMTcyMzIwNTRaFw00NDA3MDUyMzIwNTRaMBoxGDAWBgNVBAMMD3dl
|
||||
Yi5uZ2lueC1wcm94eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALYn
|
||||
Y6XG6PR6lA7MomJ2bV0zb88Z/Ofluw4O0HxPc0xIKxfRTdWfQghzhFSMhtLF2lkB
|
||||
P0Ii4Dbw3KveCr0mKyITh6YfI+8OmSeLFUob75PJa5HeoAIMYrvMVjfoJZLDH/Fp
|
||||
2HyoM+CJzhRnoDl3iJHmoweXkCKI0HkYY/tvfu4rQn4j9efa6e5q+pZln+ErFUnI
|
||||
zS3Ohk8sKmd5v0EwFMz2DxR0nrbT0DvwG7joGSr91v3cS05lfZu/N34tNSIudJDO
|
||||
QTU9QaCZ25cfvz4YPEj72t/GTk65Z7gQ1aUTA8S3Zeeq8BRL003q/o9pz1AhYyfP
|
||||
nkxnFXs/O9rLF4BhHiUCAwEAAaMeMBwwGgYDVR0RBBMwEYIPd2ViLm5naW54LXBy
|
||||
b3h5MA0GCSqGSIb3DQEBCwUAA4IBAQAJMb7bTrC2aNquWxZRKfyfYbZaLzw172d2
|
||||
l7A0Tju01ogZT4Quc9PAOkxBVGy7Z4lnrSVV19SA/qc/PZ7xNJbY2lp4UcBj8VIp
|
||||
NVX0fXAc05Zif2SGgVInxMYQE8ZzVk0y0LPDyCwlg+QrHdR0MOWFry22pWv+XdM8
|
||||
AFiU9Gr1ph3P+e3VJ+0TJLJPK/O45K8MHf7gagFeokT/Ppb6bDmjUTfzclXYLSlu
|
||||
3pW52OMeZaWcDXktOavHrBa2pXFLNaRsckcbcpxnWMH89n+nc1B71idXdKExOKcx
|
||||
47nUyUUz7O0Wz8W90AOxRT9oDZFcJk43BXTtPnVeyl7u4lFL2giZ
|
||||
-----END CERTIFICATE-----
|
||||
@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEowIBAAKCAQEAtidjpcbo9HqUDsyiYnZtXTNvzxn85+W7Dg7QfE9zTEgrF9FN
|
||||
1Z9CCHOEVIyG0sXaWQE/QiLgNvDcq94KvSYrIhOHph8j7w6ZJ4sVShvvk8lrkd6g
|
||||
Agxiu8xWN+glksMf8WnYfKgz4InOFGegOXeIkeajB5eQIojQeRhj+29+7itCfiP1
|
||||
59rp7mr6lmWf4SsVScjNLc6GTywqZ3m/QTAUzPYPFHSettPQO/AbuOgZKv3W/dxL
|
||||
TmV9m783fi01Ii50kM5BNT1BoJnblx+/Phg8SPva38ZOTrlnuBDVpRMDxLdl56rw
|
||||
FEvTTer+j2nPUCFjJ8+eTGcVez872ssXgGEeJQIDAQABAoIBAGQCMFW+ZfyEqHGP
|
||||
rMA+oUEAkqy0agSwPwky3QjDXlxNa0uCYSeebtTRB6CcHxHuCzm+04puN4gyqhW6
|
||||
rU64fAoTivCMPGBuNWxekmvD9r+/YM4P2u4E+th9EgFT9f0kII+dO30FpKXtQzY0
|
||||
xuWGWXcxl+T9M+eiEkPKPmq4BoqgTDo5ty7qDv0ZqksGotKFmdYbtSvgBAueJdwu
|
||||
VWJvenI9F42ExBRKOW1aldiRiaYBCLiCVPKJtOg9iuOP9RHUL1SE8xy5I5mm78g3
|
||||
a13ji3BNq3yS+VhGjQ7zDy1V1jGupLoJw4I7OThu8hy+B8Vt8EN/iqakufOkjlTN
|
||||
xTJ33CkCgYEA5Iymg0NTjWk6aEkFa9pERjfUWqdVp9sWSpFFZZgi55n7LOx6ohi3
|
||||
vuLim3is/gYfK2kU/kHGZZLPnT0Rdx0MbOB4XK0CAUlqtUd0IyO4jMZ06g4/kn3N
|
||||
e2jLdCCIBoEQuLk4ELxj2mHsLQhEvDrg7nzU2WpTHHhvJbIbDWOAxhsCgYEAzAgv
|
||||
rKpanF+QDf4yeKHxAj2rrwRksTw4Pe7ZK/bog/i+HIVDA70vMapqftHbual/IRrB
|
||||
JL7hxskoJ/h9c1w4xkWDjqkSKz8/Ihr4dyPfWyGINWbx/rarT/m5MU5SarScoK7o
|
||||
Xgb25x+W+61rtI+2JhVRGO86+JiAeT4LkAX88L8CgYAwHHug/jdEeXZWJakCfzwI
|
||||
HBCT1M3vO+uBXvtg25ndb0i0uENIhDOJ93EEkW65Osis9r34mBgPocwaqZRXosHO
|
||||
2aH8wF6/rpjL+HK2QvrCh7Rs4Pr494qeA/1wQLjhxaGjgToQK9hJTHvPLwJpLWvU
|
||||
SGr2Ka+9Oo0LPmb7dorRKQKBgQCLsNcjOodLJMp2KiHYIdfmlt6itzlRd09yZ8Nc
|
||||
rHHJWVagJEUbnD1hnbHIHlp3pSqbObwfMmlWNoc9xo3tm6hrZ1CJLgx4e5b3/Ms8
|
||||
ltznge/F0DPDFsH3wZwfu+YFlJ7gDKCfL9l/qEsxCS0CtJobPOEHV1NivNbJK8ey
|
||||
1ca19QKBgDTdMOUsobAmDEkPQIpxfK1iqYAB7hpRLi79OOhLp23NKeyRNu8FH9fo
|
||||
G3DZ4xUi6hP2bwiYugMXDyLKfvxbsXwQC84kGF8j+bGazKNhHqEC1OpYwmaTB3kg
|
||||
qL9cHbjWySeRdIsRY/eWmiKjUwmiO54eAe1HWUdcsuz8yM3xf636
|
||||
-----END RSA PRIVATE KEY-----
|
||||
15
test/stress_tests/test_deleted_cert/docker-compose.yml
Normal file
15
test/stress_tests/test_deleted_cert/docker-compose.yml
Normal file
@ -0,0 +1,15 @@
|
||||
web:
|
||||
image: web
|
||||
expose:
|
||||
- "81"
|
||||
environment:
|
||||
WEB_PORTS: 81
|
||||
VIRTUAL_HOST: web.nginx-proxy
|
||||
|
||||
|
||||
reverseproxy:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
container_name: reverseproxy
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
- ./tmp_certs:/etc/nginx/certs:ro
|
||||
@ -0,0 +1,72 @@
|
||||
import logging
|
||||
import os
|
||||
from os.path import join, isfile
|
||||
from shutil import copy
|
||||
from time import sleep
|
||||
|
||||
import pytest
|
||||
from requests import ConnectionError
|
||||
|
||||
script_dir = os.path.dirname(__file__)
|
||||
|
||||
pytestmark = pytest.mark.xfail() # TODO delete this marker once those issues are fixed
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def certs():
|
||||
"""
|
||||
pytest fixture that provides cert and key files into the tmp_certs directory
|
||||
"""
|
||||
file_names = ("web.nginx-proxy.crt", "web.nginx-proxy.key")
|
||||
logging.info("copying server cert and key files into tmp_certs")
|
||||
for f_name in file_names:
|
||||
copy(join(script_dir, "certs", f_name), join(script_dir, "tmp_certs"))
|
||||
yield
|
||||
logging.info("cleaning up the tmp_cert directory")
|
||||
for f_name in file_names:
|
||||
if isfile(join(script_dir, "tmp_certs", f_name)):
|
||||
os.remove(join(script_dir, "tmp_certs", f_name))
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
||||
def test_unknown_virtual_host_is_503(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://foo.nginx-proxy/")
|
||||
assert r.status_code == 503
|
||||
|
||||
|
||||
def test_http_web_is_301(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://web.nginx-proxy/port", allow_redirects=False)
|
||||
assert r.status_code == 301
|
||||
|
||||
|
||||
def test_https_web_is_200(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("https://web.nginx-proxy/port")
|
||||
assert r.status_code == 200
|
||||
assert "answer from port 81\n" in r.text
|
||||
|
||||
|
||||
@pytest.mark.incremental
|
||||
def test_delete_cert_and_restart_reverseproxy(docker_compose):
|
||||
os.remove(join(script_dir, "tmp_certs", "web.nginx-proxy.crt"))
|
||||
docker_compose.containers.get("reverseproxy").restart()
|
||||
sleep(3) # give time for the container to initialize
|
||||
assert "running" == docker_compose.containers.get("reverseproxy").status
|
||||
|
||||
|
||||
@pytest.mark.incremental
|
||||
def test_unknown_virtual_host_is_still_503(nginxproxy):
|
||||
r = nginxproxy.get("http://foo.nginx-proxy/")
|
||||
assert r.status_code == 503
|
||||
|
||||
|
||||
@pytest.mark.incremental
|
||||
def test_http_web_is_now_200(nginxproxy):
|
||||
r = nginxproxy.get("http://web.nginx-proxy/port", allow_redirects=False)
|
||||
assert r.status_code == 200
|
||||
assert "answer from port 81\n" == r.text
|
||||
|
||||
|
||||
@pytest.mark.incremental
|
||||
def test_https_web_is_now_broken_since_there_is_no_cert(nginxproxy):
|
||||
with pytest.raises(ConnectionError):
|
||||
nginxproxy.get("https://web.nginx-proxy/port")
|
||||
2
test/stress_tests/test_deleted_cert/tmp_certs/.gitignore
vendored
Normal file
2
test/stress_tests/test_deleted_cert/tmp_certs/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
59
test/stress_tests/test_unreachable_network/README.md
Normal file
59
test/stress_tests/test_unreachable_network/README.md
Normal file
@ -0,0 +1,59 @@
|
||||
# nginx-proxy template is not considered when a container is not reachable
|
||||
|
||||
Having a container with the `VIRTUAL_HOST` environment variable set but on a network not reachable from the nginx-proxy container will result in nginx-proxy serving the default nginx welcome page for all requests.
|
||||
|
||||
Furthermore, if the nginx-proxy in such state is restarted, the nginx process will crash and the container stops.
|
||||
|
||||
In the generated nginx config file, we can notice the presence of an empty `upstream {}` block.
|
||||
|
||||
This can be fixed by merging [PR-585](https://github.com/nginx-proxy/nginx-proxy/pull/585).
|
||||
|
||||
## How to reproduce
|
||||
|
||||
1. a first web container is created on network `netA`
|
||||
1. a second web container is created on network `netB`
|
||||
1. nginx-proxy is created with access to `netA` only
|
||||
|
||||
|
||||
## Erratic behavior
|
||||
|
||||
- nginx serves the default welcome page for all requests to `/` and error 404 for any other path
|
||||
- nginx-container crash on restart
|
||||
|
||||
Log shows:
|
||||
|
||||
```
|
||||
webB_1 | starting a web server listening on port 82
|
||||
webA_1 | starting a web server listening on port 81
|
||||
reverseproxy | forego | starting dockergen.1 on port 5000
|
||||
reverseproxy | forego | starting nginx.1 on port 5100
|
||||
reverseproxy | dockergen.1 | 2017/02/20 01:10:24 Generated '/etc/nginx/conf.d/default.conf' from 3 containers
|
||||
reverseproxy | dockergen.1 | 2017/02/20 01:10:24 Running 'nginx -s reload'
|
||||
reverseproxy | dockergen.1 | 2017/02/20 01:10:24 Error running notify command: nginx -s reload, exit status 1
|
||||
reverseproxy | dockergen.1 | 2017/02/20 01:10:24 Watching docker events
|
||||
reverseproxy | dockergen.1 | 2017/02/20 01:10:24 Contents of /etc/nginx/conf.d/default.conf did not change. Skipping notification 'nginx -s reload'
|
||||
reverseproxy | reverseproxy | forego | starting dockergen.1 on port 5000 <---- nginx-proxy container restarted
|
||||
reverseproxy | forego | starting nginx.1 on port 5100
|
||||
reverseproxy | dockergen.1 | 2017/02/20 01:10:24 Generated '/etc/nginx/conf.d/default.conf' from 3 containers
|
||||
reverseproxy | dockergen.1 | 2017/02/20 01:10:24 Running 'nginx -s reload'
|
||||
reverseproxy | dockergen.1 | 2017/02/20 01:10:24 Error running notify command: nginx -s reload, exit status 1
|
||||
reverseproxy | dockergen.1 | 2017/02/20 01:10:24 Watching docker events
|
||||
reverseproxy | dockergen.1 | 2017/02/20 01:10:24 Contents of /etc/nginx/conf.d/default.conf did not change. Skipping notification 'nginx -s reload'
|
||||
reverseproxy | forego | starting dockergen.1 on port 5000
|
||||
reverseproxy | forego | starting nginx.1 on port 5100
|
||||
reverseproxy | nginx.1 | 2017/02/20 01:11:02 [emerg] 17#17: no servers are inside upstream in /etc/nginx/conf.d/default.conf:64
|
||||
reverseproxy | forego | starting nginx.1 on port 5200
|
||||
reverseproxy | forego | sending SIGTERM to nginx.1
|
||||
reverseproxy | forego | sending SIGTERM to dockergen.1
|
||||
reverseproxy exited with code 0
|
||||
reverseproxy exited with code 0
|
||||
|
||||
```
|
||||
|
||||
## Expected behavior
|
||||
|
||||
- no default nginx welcome page should be served
|
||||
- nginx is able to forward requests to containers of `netA`
|
||||
- nginx respond with error 503 for unknown virtual hosts
|
||||
- nginx is not able to forward requests to containers of `netB` and responds with an error
|
||||
- nginx should survive restarts
|
||||
@ -0,0 +1,35 @@
|
||||
version: "2"
|
||||
|
||||
networks:
|
||||
netA:
|
||||
netB:
|
||||
|
||||
services:
|
||||
reverseproxy:
|
||||
container_name: reverseproxy
|
||||
networks:
|
||||
- netA
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
|
||||
webA:
|
||||
networks:
|
||||
- netA
|
||||
image: web
|
||||
expose:
|
||||
- 81
|
||||
environment:
|
||||
WEB_PORTS: 81
|
||||
VIRTUAL_HOST: webA.nginx-proxy
|
||||
|
||||
webB:
|
||||
networks:
|
||||
- netB
|
||||
image: web
|
||||
expose:
|
||||
- 82
|
||||
environment:
|
||||
WEB_PORTS: 82
|
||||
VIRTUAL_HOST: webB.nginx-proxy
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
from time import sleep
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
|
||||
|
||||
def test_default_nginx_welcome_page_should_not_be_served(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://whatever.nginx-proxy/", allow_redirects=False)
|
||||
assert "<title>Welcome to nginx!</title>" not in r.text
|
||||
|
||||
|
||||
def test_unknown_virtual_host_is_503(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://unknown.nginx-proxy/", allow_redirects=False)
|
||||
assert r.status_code == 503
|
||||
|
||||
|
||||
def test_http_web_a_is_forwarded(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://webA.nginx-proxy/port", allow_redirects=False)
|
||||
assert r.status_code == 200
|
||||
assert "answer from port 81\n" == r.text
|
||||
|
||||
|
||||
def test_http_web_b_gets_an_error(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://webB.nginx-proxy/", allow_redirects=False)
|
||||
assert "<title>Welcome to nginx!</title>" not in r.text
|
||||
with pytest.raises(requests.exceptions.HTTPError):
|
||||
r.raise_for_status()
|
||||
|
||||
|
||||
def test_reverseproxy_survive_restart(docker_compose):
|
||||
docker_compose.containers.get("reverseproxy").restart()
|
||||
sleep(2) # give time for the container to initialize
|
||||
assert docker_compose.containers.get("reverseproxy").status == "running"
|
||||
15
test/test_DOCKER_HOST_unix_socket.py
Normal file
15
test/test_DOCKER_HOST_unix_socket.py
Normal file
@ -0,0 +1,15 @@
|
||||
import pytest
|
||||
|
||||
def test_unknown_virtual_host(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://nginx-proxy/port")
|
||||
assert r.status_code == 503
|
||||
|
||||
def test_forwards_to_web1(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://web1.nginx-proxy.tld/port")
|
||||
assert r.status_code == 200
|
||||
assert r.text == "answer from port 81\n"
|
||||
|
||||
def test_forwards_to_web2(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://web2.nginx-proxy.tld/port")
|
||||
assert r.status_code == 200
|
||||
assert r.text == "answer from port 82\n"
|
||||
23
test/test_DOCKER_HOST_unix_socket.yml
Normal file
23
test/test_DOCKER_HOST_unix_socket.yml
Normal file
@ -0,0 +1,23 @@
|
||||
web1:
|
||||
image: web
|
||||
expose:
|
||||
- "81"
|
||||
environment:
|
||||
WEB_PORTS: 81
|
||||
VIRTUAL_HOST: web1.nginx-proxy.tld
|
||||
|
||||
web2:
|
||||
image: web
|
||||
expose:
|
||||
- "82"
|
||||
environment:
|
||||
WEB_PORTS: 82
|
||||
VIRTUAL_HOST: web2.nginx-proxy.tld
|
||||
|
||||
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/f00.sock:ro
|
||||
environment:
|
||||
DOCKER_HOST: unix:///f00.sock
|
||||
10
test/test_composev2.py
Normal file
10
test/test_composev2.py
Normal file
@ -0,0 +1,10 @@
|
||||
import pytest
|
||||
|
||||
def test_unknown_virtual_host(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://nginx-proxy/")
|
||||
assert r.status_code == 503
|
||||
|
||||
def test_forwards_to_whoami(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://web.nginx-proxy.local/port")
|
||||
assert r.status_code == 200
|
||||
assert r.text == "answer from port 81\n"
|
||||
14
test/test_composev2.yml
Normal file
14
test/test_composev2.yml
Normal file
@ -0,0 +1,14 @@
|
||||
version: '2'
|
||||
services:
|
||||
nginx-proxy:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
|
||||
web:
|
||||
image: web
|
||||
expose:
|
||||
- "81"
|
||||
environment:
|
||||
WEB_PORTS: 81
|
||||
VIRTUAL_HOST: web.nginx-proxy.local
|
||||
1
test/test_custom/my_custom_proxy_settings.conf
Normal file
1
test/test_custom/my_custom_proxy_settings.conf
Normal file
@ -0,0 +1 @@
|
||||
add_header X-test f00;
|
||||
1
test/test_custom/my_custom_proxy_settings_bar.conf
Normal file
1
test/test_custom/my_custom_proxy_settings_bar.conf
Normal file
@ -0,0 +1 @@
|
||||
add_header X-test bar;
|
||||
28
test/test_custom/test_defaults-location.py
Normal file
28
test/test_custom/test_defaults-location.py
Normal file
@ -0,0 +1,28 @@
|
||||
import pytest
|
||||
|
||||
def test_custom_default_conf_does_not_apply_to_unknown_vhost(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://nginx-proxy/")
|
||||
assert r.status_code == 503
|
||||
assert "X-test" not in r.headers
|
||||
|
||||
def test_custom_default_conf_applies_to_web1(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://web1.nginx-proxy.local/port")
|
||||
assert r.status_code == 200
|
||||
assert r.text == "answer from port 81\n"
|
||||
assert "X-test" in r.headers
|
||||
assert "f00" == r.headers["X-test"]
|
||||
|
||||
def test_custom_default_conf_applies_to_web2(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://web2.nginx-proxy.local/port")
|
||||
assert r.status_code == 200
|
||||
assert r.text == "answer from port 82\n"
|
||||
assert "X-test" in r.headers
|
||||
assert "f00" == r.headers["X-test"]
|
||||
|
||||
|
||||
def test_custom_default_conf_is_overriden_for_web3(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://web3.nginx-proxy.local/port")
|
||||
assert r.status_code == 200
|
||||
assert r.text == "answer from port 83\n"
|
||||
assert "X-test" in r.headers
|
||||
assert "bar" == r.headers["X-test"]
|
||||
30
test/test_custom/test_defaults-location.yml
Normal file
30
test/test_custom/test_defaults-location.yml
Normal file
@ -0,0 +1,30 @@
|
||||
nginx-proxy:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
- ./my_custom_proxy_settings.conf:/etc/nginx/vhost.d/default_location:ro
|
||||
- ./my_custom_proxy_settings_bar.conf:/etc/nginx/vhost.d/web3.nginx-proxy.local_location:ro
|
||||
|
||||
web1:
|
||||
image: web
|
||||
expose:
|
||||
- "81"
|
||||
environment:
|
||||
WEB_PORTS: 81
|
||||
VIRTUAL_HOST: web1.nginx-proxy.local
|
||||
|
||||
web2:
|
||||
image: web
|
||||
expose:
|
||||
- "82"
|
||||
environment:
|
||||
WEB_PORTS: 82
|
||||
VIRTUAL_HOST: web2.nginx-proxy.local
|
||||
|
||||
web3:
|
||||
image: web
|
||||
expose:
|
||||
- "83"
|
||||
environment:
|
||||
WEB_PORTS: 83
|
||||
VIRTUAL_HOST: web3.nginx-proxy.local
|
||||
20
test/test_custom/test_defaults.py
Normal file
20
test/test_custom/test_defaults.py
Normal file
@ -0,0 +1,20 @@
|
||||
import pytest
|
||||
|
||||
def test_custom_conf_does_not_apply_to_unknown_vhost(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://nginx-proxy/")
|
||||
assert r.status_code == 503
|
||||
assert "X-test" not in r.headers
|
||||
|
||||
def test_custom_conf_applies_to_web1(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://web1.nginx-proxy.local/port")
|
||||
assert r.status_code == 200
|
||||
assert r.text == "answer from port 81\n"
|
||||
assert "X-test" in r.headers
|
||||
assert "f00" == r.headers["X-test"]
|
||||
|
||||
def test_custom_conf_applies_to_web2(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://web2.nginx-proxy.local/port")
|
||||
assert r.status_code == 200
|
||||
assert r.text == "answer from port 82\n"
|
||||
assert "X-test" in r.headers
|
||||
assert "f00" == r.headers["X-test"]
|
||||
23
test/test_custom/test_defaults.yml
Normal file
23
test/test_custom/test_defaults.yml
Normal file
@ -0,0 +1,23 @@
|
||||
version: '2'
|
||||
services:
|
||||
nginx-proxy:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
- ./my_custom_proxy_settings.conf:/etc/nginx/proxy.conf:ro
|
||||
|
||||
web1:
|
||||
image: web
|
||||
expose:
|
||||
- "81"
|
||||
environment:
|
||||
WEB_PORTS: 81
|
||||
VIRTUAL_HOST: web1.nginx-proxy.local
|
||||
|
||||
web2:
|
||||
image: web
|
||||
expose:
|
||||
- "82"
|
||||
environment:
|
||||
WEB_PORTS: 82
|
||||
VIRTUAL_HOST: web2.nginx-proxy.local
|
||||
22
test/test_custom/test_location-per-vhost.py
Normal file
22
test/test_custom/test_location-per-vhost.py
Normal file
@ -0,0 +1,22 @@
|
||||
import pytest
|
||||
|
||||
def test_custom_conf_does_not_apply_to_unknown_vhost(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://nginx-proxy/")
|
||||
assert r.status_code == 503
|
||||
assert "X-test" not in r.headers
|
||||
|
||||
def test_custom_conf_applies_to_web1(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://web1.nginx-proxy.local/port")
|
||||
assert r.status_code == 200
|
||||
assert r.text == "answer from port 81\n"
|
||||
assert "X-test" in r.headers
|
||||
assert "f00" == r.headers["X-test"]
|
||||
|
||||
def test_custom_conf_does_not_apply_to_web2(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://web2.nginx-proxy.local/port")
|
||||
assert r.status_code == 200
|
||||
assert r.text == "answer from port 82\n"
|
||||
assert "X-test" not in r.headers
|
||||
|
||||
def test_custom_block_is_present_in_nginx_generated_conf(docker_compose, nginxproxy):
|
||||
assert b"include /etc/nginx/vhost.d/web1.nginx-proxy.local_location;" in nginxproxy.get_conf()
|
||||
23
test/test_custom/test_location-per-vhost.yml
Normal file
23
test/test_custom/test_location-per-vhost.yml
Normal file
@ -0,0 +1,23 @@
|
||||
version: '2'
|
||||
services:
|
||||
nginx-proxy:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
- ./my_custom_proxy_settings.conf:/etc/nginx/vhost.d/web1.nginx-proxy.local_location:ro
|
||||
|
||||
web1:
|
||||
image: web
|
||||
expose:
|
||||
- "81"
|
||||
environment:
|
||||
WEB_PORTS: 81
|
||||
VIRTUAL_HOST: web1.nginx-proxy.local
|
||||
|
||||
web2:
|
||||
image: web
|
||||
expose:
|
||||
- "82"
|
||||
environment:
|
||||
WEB_PORTS: 82
|
||||
VIRTUAL_HOST: web2.nginx-proxy.local
|
||||
19
test/test_custom/test_per-vhost.py
Normal file
19
test/test_custom/test_per-vhost.py
Normal file
@ -0,0 +1,19 @@
|
||||
import pytest
|
||||
|
||||
def test_custom_conf_does_not_apply_to_unknown_vhost(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://nginx-proxy/")
|
||||
assert r.status_code == 503
|
||||
assert "X-test" not in r.headers
|
||||
|
||||
def test_custom_conf_applies_to_web1(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://web1.nginx-proxy.local/port")
|
||||
assert r.status_code == 200
|
||||
assert r.text == "answer from port 81\n"
|
||||
assert "X-test" in r.headers
|
||||
assert "f00" == r.headers["X-test"]
|
||||
|
||||
def test_custom_conf_does_not_apply_to_web2(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://web2.nginx-proxy.local/port")
|
||||
assert r.status_code == 200
|
||||
assert r.text == "answer from port 82\n"
|
||||
assert "X-test" not in r.headers
|
||||
23
test/test_custom/test_per-vhost.yml
Normal file
23
test/test_custom/test_per-vhost.yml
Normal file
@ -0,0 +1,23 @@
|
||||
version: '2'
|
||||
services:
|
||||
nginx-proxy:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
- ./my_custom_proxy_settings.conf:/etc/nginx/vhost.d/web1.nginx-proxy.local:ro
|
||||
|
||||
web1:
|
||||
image: web
|
||||
expose:
|
||||
- "81"
|
||||
environment:
|
||||
WEB_PORTS: 81
|
||||
VIRTUAL_HOST: web1.nginx-proxy.local
|
||||
|
||||
web2:
|
||||
image: web
|
||||
expose:
|
||||
- "82"
|
||||
environment:
|
||||
WEB_PORTS: 82
|
||||
VIRTUAL_HOST: web2.nginx-proxy.local
|
||||
20
test/test_custom/test_proxy-wide.py
Normal file
20
test/test_custom/test_proxy-wide.py
Normal file
@ -0,0 +1,20 @@
|
||||
import pytest
|
||||
|
||||
def test_custom_conf_does_not_apply_to_unknown_vhost(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://nginx-proxy/")
|
||||
assert r.status_code == 503
|
||||
assert "X-test" not in r.headers
|
||||
|
||||
def test_custom_conf_applies_to_web1(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://web1.nginx-proxy.local/port")
|
||||
assert r.status_code == 200
|
||||
assert r.text == "answer from port 81\n"
|
||||
assert "X-test" in r.headers
|
||||
assert "f00" == r.headers["X-test"]
|
||||
|
||||
def test_custom_conf_applies_to_web2(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://web2.nginx-proxy.local/port")
|
||||
assert r.status_code == 200
|
||||
assert r.text == "answer from port 82\n"
|
||||
assert "X-test" in r.headers
|
||||
assert "f00" == r.headers["X-test"]
|
||||
23
test/test_custom/test_proxy-wide.yml
Normal file
23
test/test_custom/test_proxy-wide.yml
Normal file
@ -0,0 +1,23 @@
|
||||
version: '2'
|
||||
services:
|
||||
nginx-proxy:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
- ./my_custom_proxy_settings.conf:/etc/nginx/conf.d/my_custom_proxy_settings.conf:ro
|
||||
|
||||
web1:
|
||||
image: web
|
||||
expose:
|
||||
- "81"
|
||||
environment:
|
||||
WEB_PORTS: 81
|
||||
VIRTUAL_HOST: web1.nginx-proxy.local
|
||||
|
||||
web2:
|
||||
image: web
|
||||
expose:
|
||||
- "82"
|
||||
environment:
|
||||
WEB_PORTS: 82
|
||||
VIRTUAL_HOST: web2.nginx-proxy.local
|
||||
7
test/test_default-host.py
Normal file
7
test/test_default-host.py
Normal file
@ -0,0 +1,7 @@
|
||||
import pytest
|
||||
|
||||
|
||||
def test_fallback_on_default(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://unknown.nginx-proxy.tld/port")
|
||||
assert r.status_code == 200
|
||||
assert r.text == "answer from port 81\n"
|
||||
17
test/test_default-host.yml
Normal file
17
test/test_default-host.yml
Normal file
@ -0,0 +1,17 @@
|
||||
# GIVEN a webserver with VIRTUAL_HOST set to web1.tld
|
||||
web1:
|
||||
image: web
|
||||
expose:
|
||||
- "81"
|
||||
environment:
|
||||
WEB_PORTS: 81
|
||||
VIRTUAL_HOST: web1.tld
|
||||
|
||||
|
||||
# WHEN nginx-proxy runs with DEFAULT_HOST set to web1.tld
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
environment:
|
||||
DEFAULT_HOST: web1.tld
|
||||
8
test/test_default-root-none.py
Normal file
8
test/test_default-root-none.py
Normal file
@ -0,0 +1,8 @@
|
||||
import re
|
||||
|
||||
|
||||
def test_default_root_none(docker_compose, nginxproxy):
|
||||
conf = nginxproxy.get_conf().decode()
|
||||
assert re.search(r"(?m)^\s*location\s+/path\s+\{", conf)
|
||||
assert not re.search(r"(?m)^\s*location\s+/\s+\{", conf)
|
||||
|
||||
15
test/test_default-root-none.yml
Normal file
15
test/test_default-root-none.yml
Normal file
@ -0,0 +1,15 @@
|
||||
services:
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
environment:
|
||||
DEFAULT_ROOT: none
|
||||
web:
|
||||
image: web
|
||||
expose:
|
||||
- "80"
|
||||
environment:
|
||||
WEB_PORTS: "80"
|
||||
VIRTUAL_HOST: web.nginx-proxy.test
|
||||
VIRTUAL_PATH: /path
|
||||
1
test/test_dockergen/.gitignore
vendored
Normal file
1
test/test_dockergen/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
nginx.tmpl
|
||||
10
test/test_dockergen/test_dockergen_v2.py
Normal file
10
test/test_dockergen/test_dockergen_v2.py
Normal file
@ -0,0 +1,10 @@
|
||||
def test_unknown_virtual_host_is_503(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://unknown.nginx.container.docker/")
|
||||
assert r.status_code == 503
|
||||
|
||||
|
||||
def test_forwards_to_whoami(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://whoami.nginx.container.docker/")
|
||||
assert r.status_code == 200
|
||||
whoami_container = docker_compose.containers.get("whoami")
|
||||
assert r.text == f"I'm {whoami_container.id[:12]}\n"
|
||||
26
test/test_dockergen/test_dockergen_v2.yml
Normal file
26
test/test_dockergen/test_dockergen_v2.yml
Normal file
@ -0,0 +1,26 @@
|
||||
version: '2'
|
||||
|
||||
services:
|
||||
nginx:
|
||||
image: nginx
|
||||
container_name: nginx
|
||||
volumes:
|
||||
- /etc/nginx/conf.d
|
||||
|
||||
dockergen:
|
||||
image: nginxproxy/docker-gen
|
||||
command: -notify-sighup nginx -watch /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
|
||||
volumes_from:
|
||||
- nginx
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
- ../../nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl
|
||||
|
||||
web:
|
||||
image: web
|
||||
container_name: whoami
|
||||
expose:
|
||||
- "80"
|
||||
environment:
|
||||
WEB_PORTS: 80
|
||||
VIRTUAL_HOST: whoami.nginx.container.docker
|
||||
27
test/test_dockergen/test_dockergen_v3.py
Normal file
27
test/test_dockergen/test_dockergen_v3.py
Normal file
@ -0,0 +1,27 @@
|
||||
import docker
|
||||
import pytest
|
||||
from distutils.version import LooseVersion
|
||||
|
||||
|
||||
raw_version = docker.from_env().version()["Version"]
|
||||
pytestmark = pytest.mark.skipif(
|
||||
LooseVersion(raw_version) < LooseVersion("1.13"),
|
||||
reason="Docker compose syntax v3 requires docker engine v1.13 or later (got {raw_version})"
|
||||
)
|
||||
|
||||
|
||||
def test_unknown_virtual_host_is_503(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://unknown.nginx.container.docker/")
|
||||
assert r.status_code == 503
|
||||
|
||||
|
||||
def test_forwards_to_whoami(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://whoami.nginx.container.docker/")
|
||||
assert r.status_code == 200
|
||||
whoami_container = docker_compose.containers.get("whoami")
|
||||
assert r.text == f"I'm {whoami_container.id[:12]}\n"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import doctest
|
||||
doctest.testmod()
|
||||
27
test/test_dockergen/test_dockergen_v3.yml
Normal file
27
test/test_dockergen/test_dockergen_v3.yml
Normal file
@ -0,0 +1,27 @@
|
||||
version: '3'
|
||||
services:
|
||||
nginx:
|
||||
image: nginx
|
||||
container_name: nginx
|
||||
volumes:
|
||||
- nginx_conf:/etc/nginx/conf.d
|
||||
|
||||
dockergen:
|
||||
image: nginxproxy/docker-gen
|
||||
command: -notify-sighup nginx -watch /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
- ../../nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl
|
||||
- nginx_conf:/etc/nginx/conf.d
|
||||
|
||||
web:
|
||||
image: web
|
||||
container_name: whoami
|
||||
expose:
|
||||
- "80"
|
||||
environment:
|
||||
WEB_PORTS: 80
|
||||
VIRTUAL_HOST: whoami.nginx.container.docker
|
||||
|
||||
volumes:
|
||||
nginx_conf: {}
|
||||
82
test/test_events.py
Normal file
82
test/test_events.py
Normal file
@ -0,0 +1,82 @@
|
||||
"""
|
||||
Test that nginx-proxy detects new containers
|
||||
"""
|
||||
from time import sleep
|
||||
|
||||
import pytest
|
||||
from docker.errors import NotFound
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def web1(docker_compose):
|
||||
"""
|
||||
pytest fixture creating a web container with `VIRTUAL_HOST=web1.nginx-proxy` listening on port 81.
|
||||
"""
|
||||
container = docker_compose.containers.run(
|
||||
name="web1",
|
||||
image="web",
|
||||
detach=True,
|
||||
environment={
|
||||
"WEB_PORTS": "81",
|
||||
"VIRTUAL_HOST": "web1.nginx-proxy"
|
||||
},
|
||||
ports={"81/tcp": None}
|
||||
)
|
||||
sleep(2) # give it some time to initialize and for docker-gen to detect it
|
||||
yield container
|
||||
try:
|
||||
docker_compose.containers.get("web1").remove(force=True)
|
||||
except NotFound:
|
||||
pass
|
||||
|
||||
@pytest.fixture()
|
||||
def web2(docker_compose):
|
||||
"""
|
||||
pytest fixture creating a web container with `VIRTUAL_HOST=nginx-proxy`, `VIRTUAL_PATH=/web2/` and `VIRTUAL_DEST=/` listening on port 82.
|
||||
"""
|
||||
container = docker_compose.containers.run(
|
||||
name="web2",
|
||||
image="web",
|
||||
detach=True,
|
||||
environment={
|
||||
"WEB_PORTS": "82",
|
||||
"VIRTUAL_HOST": "nginx-proxy",
|
||||
"VIRTUAL_PATH": "/web2/",
|
||||
"VIRTUAL_DEST": "/",
|
||||
},
|
||||
ports={"82/tcp": None}
|
||||
)
|
||||
sleep(2) # give it some time to initialize and for docker-gen to detect it
|
||||
yield container
|
||||
try:
|
||||
docker_compose.containers.get("web2").remove(force=True)
|
||||
except NotFound:
|
||||
pass
|
||||
|
||||
def test_nginx_proxy_behavior_when_alone(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://nginx-proxy/")
|
||||
assert r.status_code == 503
|
||||
|
||||
|
||||
def test_new_container_is_detected_vhost(web1, nginxproxy):
|
||||
r = nginxproxy.get("http://web1.nginx-proxy/port")
|
||||
assert r.status_code == 200
|
||||
assert "answer from port 81\n" == r.text
|
||||
|
||||
web1.remove(force=True)
|
||||
sleep(2)
|
||||
r = nginxproxy.get("http://web1.nginx-proxy/port")
|
||||
assert r.status_code == 503
|
||||
|
||||
def test_new_container_is_detected_vpath(web2, nginxproxy):
|
||||
r = nginxproxy.get("http://nginx-proxy/web2/port")
|
||||
assert r.status_code == 200
|
||||
assert "answer from port 82\n" == r.text
|
||||
r = nginxproxy.get("http://nginx-proxy/port")
|
||||
assert r.status_code in [404, 503]
|
||||
|
||||
web2.remove(force=True)
|
||||
sleep(2)
|
||||
r = nginxproxy.get("http://nginx-proxy/web2/port")
|
||||
assert r.status_code == 503
|
||||
|
||||
4
test/test_events.yml
Normal file
4
test/test_events.yml
Normal file
@ -0,0 +1,4 @@
|
||||
nginxproxy:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
@ -0,0 +1,71 @@
|
||||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number: 4096 (0x1000)
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
Issuer: O=nginx-proxy test suite, CN=www.nginx-proxy.tld
|
||||
Validity
|
||||
Not Before: Feb 7 21:54:16 2023 GMT
|
||||
Not After : Jun 25 21:54:16 2050 GMT
|
||||
Subject: CN=http-only.nginx-proxy.test
|
||||
Subject Public Key Info:
|
||||
Public Key Algorithm: rsaEncryption
|
||||
RSA Public-Key: (2048 bit)
|
||||
Modulus:
|
||||
00:b4:62:61:07:54:2e:6d:55:83:2d:24:b7:e2:15:
|
||||
34:13:bd:79:21:e9:10:75:3f:4c:f8:ba:60:29:87:
|
||||
e5:8e:2a:1e:fd:33:51:5a:8a:3a:6f:60:ff:24:f1:
|
||||
1b:27:30:8c:ac:43:04:b7:79:cb:7a:ec:c6:08:a4:
|
||||
a0:15:b0:0f:ee:6b:15:84:24:11:bc:85:2b:48:06:
|
||||
04:0a:58:bb:8c:e8:4d:48:f5:06:c5:91:fe:5d:99:
|
||||
0a:29:31:8a:f1:9b:0c:e0:39:75:a1:06:9b:d4:f5:
|
||||
06:74:8f:46:5e:64:ba:2f:d0:3d:7c:3d:30:03:e9:
|
||||
7c:35:17:69:04:f6:2e:29:d4:93:d6:d6:d2:6c:04:
|
||||
38:06:21:06:05:30:8a:b9:9d:05:8d:12:6e:48:39:
|
||||
bb:f6:93:4f:ba:a5:84:c7:96:2f:be:92:25:e9:d0:
|
||||
95:2a:d9:23:8a:b3:28:0b:b6:19:1c:3b:be:a2:91:
|
||||
70:44:a8:77:18:94:4b:df:61:f4:5c:c9:78:76:34:
|
||||
b5:87:0f:c0:92:04:26:b6:ca:62:cd:9b:5d:eb:bf:
|
||||
10:ac:df:af:72:5f:af:09:38:b1:dc:e1:3d:13:db:
|
||||
a0:ac:b7:2e:ca:39:5c:4c:f1:1e:81:a8:b4:44:a2:
|
||||
72:d5:3b:c0:71:cc:dc:16:0d:fa:38:96:44:b3:00:
|
||||
d6:65
|
||||
Exponent: 65537 (0x10001)
|
||||
X509v3 extensions:
|
||||
X509v3 Subject Alternative Name:
|
||||
DNS:http-only.nginx-proxy.test
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
3b:54:95:48:4d:f6:93:38:42:40:02:ab:b7:17:3b:50:3b:ca:
|
||||
c7:12:69:b0:da:cb:d7:3e:0e:1f:bf:a2:59:c7:fe:c2:5c:43:
|
||||
84:92:b9:3a:be:8f:7e:2e:81:3c:ed:f3:a9:77:21:c2:35:f1:
|
||||
da:cf:3a:1e:e2:ee:a2:ce:72:55:97:87:0e:ad:59:61:f7:75:
|
||||
46:c0:2b:d4:88:b7:36:97:11:fb:5e:28:89:e9:2a:92:f1:15:
|
||||
f1:43:8e:c1:38:85:8d:3a:26:7d:25:72:93:17:96:8d:5a:ed:
|
||||
e8:73:3a:d5:8d:80:f2:af:38:84:ff:85:2e:d1:36:7d:2e:e1:
|
||||
f0:2c:d8:15:5f:fc:c5:70:5d:25:6a:22:f3:2a:cd:0f:25:ad:
|
||||
d4:93:d3:9a:3e:50:bc:da:a5:6c:86:ea:1d:d9:b9:c5:90:db:
|
||||
f5:02:c8:c9:77:5c:ef:77:fe:74:60:41:33:d9:3c:a2:e1:73:
|
||||
aa:14:18:5d:36:58:c8:41:63:4c:59:0e:4b:3d:c5:65:5a:01:
|
||||
b0:16:50:0f:d0:4f:0d:ca:97:f6:11:47:06:6b:b1:ae:bb:26:
|
||||
30:34:8b:7a:91:5d:8a:22:c7:f9:05:0d:bb:a5:b7:60:c0:20:
|
||||
ce:d0:0e:c0:66:b3:e7:c4:61:ec:c5:40:e6:52:11:41:c3:11:
|
||||
18:04:c7:1e
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDCzCCAfOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPzEfMB0GA1UECgwWbmdp
|
||||
bngtcHJveHkgdGVzdCBzdWl0ZTEcMBoGA1UEAwwTd3d3Lm5naW54LXByb3h5LnRs
|
||||
ZDAgFw0yMzAyMDcyMTU0MTZaGA8yMDUwMDYyNTIxNTQxNlowJTEjMCEGA1UEAwwa
|
||||
aHR0cC1vbmx5Lm5naW54LXByb3h5LnRlc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IB
|
||||
DwAwggEKAoIBAQC0YmEHVC5tVYMtJLfiFTQTvXkh6RB1P0z4umAph+WOKh79M1Fa
|
||||
ijpvYP8k8RsnMIysQwS3ect67MYIpKAVsA/uaxWEJBG8hStIBgQKWLuM6E1I9QbF
|
||||
kf5dmQopMYrxmwzgOXWhBpvU9QZ0j0ZeZLov0D18PTAD6Xw1F2kE9i4p1JPW1tJs
|
||||
BDgGIQYFMIq5nQWNEm5IObv2k0+6pYTHli++kiXp0JUq2SOKsygLthkcO76ikXBE
|
||||
qHcYlEvfYfRcyXh2NLWHD8CSBCa2ymLNm13rvxCs369yX68JOLHc4T0T26Csty7K
|
||||
OVxM8R6BqLREonLVO8BxzNwWDfo4lkSzANZlAgMBAAGjKTAnMCUGA1UdEQQeMByC
|
||||
Gmh0dHAtb25seS5uZ2lueC1wcm94eS50ZXN0MA0GCSqGSIb3DQEBCwUAA4IBAQA7
|
||||
VJVITfaTOEJAAqu3FztQO8rHEmmw2svXPg4fv6JZx/7CXEOEkrk6vo9+LoE87fOp
|
||||
dyHCNfHazzoe4u6iznJVl4cOrVlh93VGwCvUiLc2lxH7XiiJ6SqS8RXxQ47BOIWN
|
||||
OiZ9JXKTF5aNWu3oczrVjYDyrziE/4Uu0TZ9LuHwLNgVX/zFcF0laiLzKs0PJa3U
|
||||
k9OaPlC82qVshuod2bnFkNv1AsjJd1zvd/50YEEz2Tyi4XOqFBhdNljIQWNMWQ5L
|
||||
PcVlWgGwFlAP0E8Nypf2EUcGa7GuuyYwNIt6kV2KIsf5BQ27pbdgwCDO0A7AZrPn
|
||||
xGHsxUDmUhFBwxEYBMce
|
||||
-----END CERTIFICATE-----
|
||||
@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEpAIBAAKCAQEAtGJhB1QubVWDLSS34hU0E715IekQdT9M+LpgKYfljioe/TNR
|
||||
Woo6b2D/JPEbJzCMrEMEt3nLeuzGCKSgFbAP7msVhCQRvIUrSAYECli7jOhNSPUG
|
||||
xZH+XZkKKTGK8ZsM4Dl1oQab1PUGdI9GXmS6L9A9fD0wA+l8NRdpBPYuKdST1tbS
|
||||
bAQ4BiEGBTCKuZ0FjRJuSDm79pNPuqWEx5YvvpIl6dCVKtkjirMoC7YZHDu+opFw
|
||||
RKh3GJRL32H0XMl4djS1hw/AkgQmtspizZtd678QrN+vcl+vCTix3OE9E9ugrLcu
|
||||
yjlcTPEegai0RKJy1TvAcczcFg36OJZEswDWZQIDAQABAoIBAAfDA/HQyX6i41YZ
|
||||
8l+kEe2XhZLT+IVTB/jb7C9dTZ9kaJj0kFeZAxKv1cq9JTH2gNcYuyc58muDrLHK
|
||||
g6jrPoQ/z1k0RB8ci9Q5jgrz7n4NsOWmxXfS5GMaprlHDHeA+HjdgBZBtorfUDvL
|
||||
vndpVimgiETETUCd115hd39jKHFcRcdV6yCix7ObywK3dMgLVpagCcnlyCWffS/r
|
||||
nhhMfJ+VstW0nUtfZ7JEYwT6Cg7lLAVtDkqPX8zGjJiRwUKH808bUyqEw1y5Cc8U
|
||||
U5hbmMgPWfXsKxsEC6FSVHBG9ZX2jymOMQXijLFcBSuWvADHmyU+ZxXcbtd1rv4E
|
||||
cGFj3wECgYEA5cNrr5WjrpEin6MYYVWxiQ+xEWPU2R17eApagrDRLM41JJpv7a5m
|
||||
TYuZRfIxb59CBPi718Gi168P3T2KMvo2/BTh9Lq5ZBYHx3aDqW2QvMFn7/tgamj8
|
||||
0DBxccd2QWfGIBrT1rAF7lD8TC86wtDDVKrvhucRSEXVKF/jWFFRGfUCgYEAyPt6
|
||||
48khr7sfNMVdkDLjQjZVV6H7ZUMoSn0FGybgKWxW+b0XCBPObUQWIpyCNTRr1+4A
|
||||
1TAUS+F/OVVfwnLNgemeE2wd6CaduxwiK1U4pHbyXCElH1ifonHWV3MoXOefYsiY
|
||||
q5z2jfJzUi0JZVUKsveu9rQsFLsc//1s/I5T1LECgYEAldY6fNg2VVp63OZsuNU8
|
||||
oSiljbSwEyMh6Oe/nOkYkIKtr4AzrCoGt11piG7ohGW0lS9suMijnMqiquI+JP5+
|
||||
KyinLoUy761aR17nf+9e62mpkZw6hUqQTGi7Irs0SHUXhMpaCfDi/Ua9MiW+yVuB
|
||||
ds6+xBgeciZwWxMlXOwy2p0CgYEAm+YWiSK3Mq0fo7uEvBn9Fps2z+ciLoZNdppL
|
||||
n6gkMX2MaeQ3PVi/wxoRYX+tsL+c973yf2vwEnw0R7Dlutt6dc9VgxNWj4GE0GMe
|
||||
Tiao7Uom7Tf4p7wC9+r9rI/zOz2f8OxRIK18wtbShWfR5fx1dCWUXmGb3+jUse1O
|
||||
4Qk2FcECgYAvSvGFoJb8tuHFEYYHBbjficmvTUsrTE+EhxPqWKFhKfF19fFFIupy
|
||||
XBCrN6nwrh+/YMxZXeIRbbTTf814cOO7PjLeNhnfhJZkaJq1HzbYe3bOurna3qrm
|
||||
Ra3xiM8Ld2PyGnZPXf8+AWhMhuPkLX1KFVTCAxwCpmTZCHtiGCmXMA==
|
||||
-----END RSA PRIVATE KEY-----
|
||||
@ -0,0 +1,71 @@
|
||||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number: 4096 (0x1000)
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
Issuer: O=nginx-proxy test suite, CN=www.nginx-proxy.tld
|
||||
Validity
|
||||
Not Before: Feb 7 21:53:19 2023 GMT
|
||||
Not After : Jun 25 21:53:19 2050 GMT
|
||||
Subject: CN=https-and-http.nginx-proxy.test
|
||||
Subject Public Key Info:
|
||||
Public Key Algorithm: rsaEncryption
|
||||
RSA Public-Key: (2048 bit)
|
||||
Modulus:
|
||||
00:b7:97:85:d1:7f:6b:50:29:f3:87:b7:4e:f5:25:
|
||||
40:6a:d8:fa:a1:63:3c:4a:2e:68:4a:c6:8b:38:df:
|
||||
07:81:d0:08:9d:fc:17:f5:37:28:7f:31:e6:f3:81:
|
||||
28:4e:22:b6:bd:a2:4e:f2:2f:e5:0f:dd:55:3c:e1:
|
||||
04:84:4c:45:1b:1a:ae:b7:f0:2a:da:43:05:71:91:
|
||||
92:b8:d1:49:fe:80:0a:53:b9:66:da:54:60:9a:fc:
|
||||
e1:b2:e8:28:48:7f:96:94:3c:92:a3:b2:37:f6:7a:
|
||||
c2:de:0b:12:f0:ae:4e:92:fe:2d:c1:b2:95:28:1f:
|
||||
88:8d:79:99:81:19:ae:22:a4:95:f5:9f:db:25:8e:
|
||||
1d:cf:43:cd:6f:85:93:5f:79:ee:f8:f3:d4:82:e1:
|
||||
e9:4d:c9:ad:ae:5b:92:43:3a:3c:71:51:70:f7:3e:
|
||||
bd:1b:24:52:6a:a3:cf:54:72:57:ed:fe:72:ea:96:
|
||||
9b:5a:02:02:a7:df:85:b7:68:ae:1e:07:77:9f:59:
|
||||
a5:a0:8b:28:c2:c8:b7:bb:8a:42:50:df:05:73:bf:
|
||||
9c:55:13:b5:82:79:77:40:57:a4:8f:88:a5:71:50:
|
||||
d7:70:b0:4d:0c:d9:86:b3:9b:db:8a:20:bd:19:68:
|
||||
10:52:2d:53:ba:0e:2e:1c:ad:80:54:bb:b6:c9:ab:
|
||||
11:39
|
||||
Exponent: 65537 (0x10001)
|
||||
X509v3 extensions:
|
||||
X509v3 Subject Alternative Name:
|
||||
DNS:https-and-http.nginx-proxy.test
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
2c:f3:e5:47:3f:8e:5a:28:b1:df:e5:95:50:85:6f:27:2f:a6:
|
||||
8d:f1:5e:cf:df:e2:52:66:97:61:36:59:81:26:25:19:99:c9:
|
||||
93:e5:85:cb:ca:69:af:4b:21:a3:d2:7a:bf:b5:5e:2d:42:fb:
|
||||
99:f8:22:58:e5:bf:79:b8:8a:74:7e:c6:94:14:d9:f2:27:63:
|
||||
b6:e5:74:21:5b:59:fb:f6:c8:a9:28:fb:60:f7:5e:bd:c2:e6:
|
||||
74:24:14:96:61:95:6c:c2:66:b4:52:25:a1:85:5a:97:e5:68:
|
||||
5c:62:cf:69:3b:b0:a9:56:d8:e3:5f:74:dc:84:18:d5:3e:4f:
|
||||
c9:35:39:26:88:dc:9b:80:d9:40:e1:4f:09:27:8d:d2:89:55:
|
||||
30:91:02:86:35:04:95:1e:1d:58:14:5b:c6:e0:2e:a7:bf:a8:
|
||||
f6:2b:76:8a:4e:71:79:bc:c0:04:cd:db:81:73:46:ce:68:ed:
|
||||
25:b0:0e:42:8d:96:64:77:3b:f4:9d:1a:c9:f6:78:4c:56:4f:
|
||||
92:17:29:3d:80:50:71:77:4b:a8:29:c2:12:fc:ad:0a:37:81:
|
||||
38:4c:fb:54:99:4d:12:5f:98:dc:d1:a9:7b:08:45:c4:6f:7e:
|
||||
fe:00:e0:db:79:fe:d1:28:e3:8e:82:d1:fb:bc:0a:c4:42:93:
|
||||
c9:5e:eb:ba
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDFTCCAf2gAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPzEfMB0GA1UECgwWbmdp
|
||||
bngtcHJveHkgdGVzdCBzdWl0ZTEcMBoGA1UEAwwTd3d3Lm5naW54LXByb3h5LnRs
|
||||
ZDAgFw0yMzAyMDcyMTUzMTlaGA8yMDUwMDYyNTIxNTMxOVowKjEoMCYGA1UEAwwf
|
||||
aHR0cHMtYW5kLWh0dHAubmdpbngtcHJveHkudGVzdDCCASIwDQYJKoZIhvcNAQEB
|
||||
BQADggEPADCCAQoCggEBALeXhdF/a1Ap84e3TvUlQGrY+qFjPEouaErGizjfB4HQ
|
||||
CJ38F/U3KH8x5vOBKE4itr2iTvIv5Q/dVTzhBIRMRRsarrfwKtpDBXGRkrjRSf6A
|
||||
ClO5ZtpUYJr84bLoKEh/lpQ8kqOyN/Z6wt4LEvCuTpL+LcGylSgfiI15mYEZriKk
|
||||
lfWf2yWOHc9DzW+Fk1957vjz1ILh6U3Jra5bkkM6PHFRcPc+vRskUmqjz1RyV+3+
|
||||
cuqWm1oCAqffhbdorh4Hd59ZpaCLKMLIt7uKQlDfBXO/nFUTtYJ5d0BXpI+IpXFQ
|
||||
13CwTQzZhrOb24ogvRloEFItU7oOLhytgFS7tsmrETkCAwEAAaMuMCwwKgYDVR0R
|
||||
BCMwIYIfaHR0cHMtYW5kLWh0dHAubmdpbngtcHJveHkudGVzdDANBgkqhkiG9w0B
|
||||
AQsFAAOCAQEALPPlRz+OWiix3+WVUIVvJy+mjfFez9/iUmaXYTZZgSYlGZnJk+WF
|
||||
y8ppr0sho9J6v7VeLUL7mfgiWOW/ebiKdH7GlBTZ8idjtuV0IVtZ+/bIqSj7YPde
|
||||
vcLmdCQUlmGVbMJmtFIloYVal+VoXGLPaTuwqVbY41903IQY1T5PyTU5Jojcm4DZ
|
||||
QOFPCSeN0olVMJEChjUElR4dWBRbxuAup7+o9it2ik5xebzABM3bgXNGzmjtJbAO
|
||||
Qo2WZHc79J0ayfZ4TFZPkhcpPYBQcXdLqCnCEvytCjeBOEz7VJlNEl+Y3NGpewhF
|
||||
xG9+/gDg23n+0SjjjoLR+7wKxEKTyV7rug==
|
||||
-----END CERTIFICATE-----
|
||||
@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEpAIBAAKCAQEAt5eF0X9rUCnzh7dO9SVAatj6oWM8Si5oSsaLON8HgdAInfwX
|
||||
9TcofzHm84EoTiK2vaJO8i/lD91VPOEEhExFGxqut/Aq2kMFcZGSuNFJ/oAKU7lm
|
||||
2lRgmvzhsugoSH+WlDySo7I39nrC3gsS8K5Okv4twbKVKB+IjXmZgRmuIqSV9Z/b
|
||||
JY4dz0PNb4WTX3nu+PPUguHpTcmtrluSQzo8cVFw9z69GyRSaqPPVHJX7f5y6pab
|
||||
WgICp9+Ft2iuHgd3n1mloIsowsi3u4pCUN8Fc7+cVRO1gnl3QFekj4ilcVDXcLBN
|
||||
DNmGs5vbiiC9GWgQUi1Tug4uHK2AVLu2yasROQIDAQABAoIBACT4KSVHoEdzOyvw
|
||||
GME6sB8T9Fw9TG2vrKaqFmzsVGmqh6Gwmu5xHgGG/fe44XHigaPsJDOWu2yXaEur
|
||||
ECrH5P6RP++gODDdYCI/ayk2U80g4XN8mR6L8Swkkhphr4Lx1lOhYvH9uFE05Tqr
|
||||
RjQbFY16C6K+oFSFDQ1YGDYsAqnM3RD7PH+lHpo8UN1TO/vogdSQEpMYZDwLAYnW
|
||||
uD5G3c0u2PsGu9YLuz2p8hcs3chh+cqKJWXOeW0JLrNGx1bqeQWkn6nXRDdRYi9V
|
||||
cJlTgDqGuF54bieSyq9ABDZQP4Ol+moYKDoIz5PwurNjcYSklrT1tw0gqHZoQK1L
|
||||
fDjw3QECgYEA7QMRU1AFKTvO7/8WLHLN5BT63n31wm0e9PYpz/XVLWEfxBcp9Xmf
|
||||
xAIhXZ/U9P4dfNqxTjN9mVGzCHh5KfDJnUFqOXFy/zvfMeRzJf6dJo6/4OX9Bijr
|
||||
Tgd454vyGXYQP2t+F14UAwl6vlGOAjttiP5qY5Ef1gllBEeIPe9Ts9kCgYEAxkzZ
|
||||
pq4HJ/5/iDquMEHXNXzpNPavSvgxQdl1ILvJ49LJImmQFBCP9PqiOTIfePz1OqUI
|
||||
C4baFuc0FEDJ3x9CUNmMY1lEi2ZUq2agPSXaQNsMcKtEJH8SoJlJIRpkQA7unX09
|
||||
zb4dam6g79OaGmb8scePuezXMLv1Ee6WWtXbzGECgYEA6PYn9Gzl9cacu9dOUzgw
|
||||
2ewpPcIvawDY+cxwAsHO3MDneVWPX4JBoGa7pwvwRTL1hwBqYMRJwwbD5CKObcQI
|
||||
V/KxV28Eqo2N77tt1z2x9/E99u/4yTI1P0gm9ejfeVlL1RpyIMPPBcEujZ0Z6WXC
|
||||
X3I63k0KLtajHRa2erIf4tkCgYAfunAgwTuX5JqXO3xfcEl033WY6deGUUvgU2Dw
|
||||
Sdu1viY8gVNyQmwmMGwAZsquWxsJtRoibgM7IucsTml+b8v2j7hstP3IqCjn+9Wr
|
||||
swDG28WTyXNvu31JgP04dLaRoVIAlOdsofym6OiLNvozO0M3VsziXMjZnVlK8zfP
|
||||
dORkQQKBgQDXAJEJPygxVA+bF104dzCMWGmU7K8ShEWC5eOdKK4KWf9bNDpY6M6c
|
||||
i6zga/xBbj7e3Bxqprpp8Wy2gIsnYiVo4V9EQethbLdomPxOpBMNMARw81rL1CpO
|
||||
jbHB7bIDcKs2tQoZEXUW86ZxC8sdaDaWTJTfUO0RpJow6ZO3yvxVIQ==
|
||||
-----END RSA PRIVATE KEY-----
|
||||
@ -0,0 +1,71 @@
|
||||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number: 4096 (0x1000)
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
Issuer: O=nginx-proxy test suite, CN=www.nginx-proxy.tld
|
||||
Validity
|
||||
Not Before: Feb 7 21:53:49 2023 GMT
|
||||
Not After : Jun 25 21:53:49 2050 GMT
|
||||
Subject: CN=https-only.nginx-proxy.test
|
||||
Subject Public Key Info:
|
||||
Public Key Algorithm: rsaEncryption
|
||||
RSA Public-Key: (2048 bit)
|
||||
Modulus:
|
||||
00:d9:87:48:02:85:f4:5f:0d:90:7e:4c:4f:13:89:
|
||||
41:ca:41:15:c2:6f:fd:a8:c7:17:83:c6:dd:8c:fe:
|
||||
19:a4:b2:6b:0b:35:4f:b4:3d:7c:40:0a:04:33:2a:
|
||||
fd:10:72:f7:63:63:99:5b:3d:ec:78:ee:c6:4d:c8:
|
||||
0e:4c:be:f2:3f:e3:02:74:57:9a:c1:fe:15:95:63:
|
||||
4e:e7:2c:eb:70:f2:6b:c8:ba:01:a2:ca:a1:c7:76:
|
||||
ff:38:e4:c2:b0:66:fc:85:d2:af:0f:22:81:d4:82:
|
||||
eb:d5:b0:e6:69:14:37:dd:8d:ad:29:ce:93:68:5a:
|
||||
ce:f4:77:76:6f:78:13:b6:c8:2f:fe:e0:b6:7e:fb:
|
||||
29:16:be:e2:f5:45:3b:39:5b:52:dc:26:b7:ca:0c:
|
||||
b6:1c:fc:a8:38:0b:dd:c1:f4:04:9b:2d:38:c9:a5:
|
||||
2d:3e:f1:42:88:53:a2:3b:17:cf:d5:3c:2b:d6:6a:
|
||||
7f:6f:05:8d:c5:b7:5d:64:1e:83:1b:e7:ec:80:3d:
|
||||
6d:34:c1:66:b2:e6:5d:d9:a7:6e:46:75:14:bf:10:
|
||||
16:c5:fc:47:8e:63:fa:e5:b4:bd:f2:b9:e0:cb:ea:
|
||||
75:f9:68:ee:7d:8f:ea:8f:1a:9f:34:27:7a:4a:9f:
|
||||
85:fd:3e:17:a7:96:c3:d0:4e:50:a2:a2:e0:45:92:
|
||||
d0:b5
|
||||
Exponent: 65537 (0x10001)
|
||||
X509v3 extensions:
|
||||
X509v3 Subject Alternative Name:
|
||||
DNS:https-only.nginx-proxy.test
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
8a:52:46:42:a9:74:18:6a:52:90:ef:a4:e9:c5:54:d5:97:3a:
|
||||
ff:8b:c2:76:4f:9e:47:aa:e1:ea:e5:b9:af:9d:33:e3:85:17:
|
||||
54:7d:32:bd:ac:90:3f:5c:d2:a1:42:17:52:2b:b1:83:e5:c3:
|
||||
bf:81:f0:e7:38:e2:88:67:7b:d8:59:fe:f9:94:99:ba:be:f4:
|
||||
3c:24:b2:c7:9e:f0:98:21:c6:2d:c2:e8:f3:67:bd:62:00:aa:
|
||||
ce:34:fa:b4:53:6d:c1:09:5e:55:bd:43:aa:86:c6:f8:c5:83:
|
||||
46:3a:49:12:a2:ec:30:36:0c:99:44:74:09:9d:cc:4b:98:1f:
|
||||
7e:c9:9b:68:a0:f8:1e:00:14:d0:da:2a:bf:c8:ca:a8:1c:10:
|
||||
b5:68:a2:f1:41:93:0c:f3:3f:c0:c6:53:3c:8d:a7:dd:a5:7b:
|
||||
35:cc:44:e0:5b:6d:c5:cb:33:6f:c1:43:7e:06:df:21:99:11:
|
||||
b3:91:41:b4:5e:f0:37:1e:8e:e5:73:85:dc:4a:21:d5:41:f9:
|
||||
4e:b8:f5:ed:21:93:09:91:c2:8c:6b:04:a4:84:ab:3a:fe:35:
|
||||
64:fa:6b:a7:8d:40:a6:64:89:30:84:ac:28:99:5a:01:79:77:
|
||||
c0:df:88:da:a9:75:5f:c4:51:ae:a8:45:7b:d2:e1:a2:81:29:
|
||||
60:cd:7b:cd
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDDTCCAfWgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPzEfMB0GA1UECgwWbmdp
|
||||
bngtcHJveHkgdGVzdCBzdWl0ZTEcMBoGA1UEAwwTd3d3Lm5naW54LXByb3h5LnRs
|
||||
ZDAgFw0yMzAyMDcyMTUzNDlaGA8yMDUwMDYyNTIxNTM0OVowJjEkMCIGA1UEAwwb
|
||||
aHR0cHMtb25seS5uZ2lueC1wcm94eS50ZXN0MIIBIjANBgkqhkiG9w0BAQEFAAOC
|
||||
AQ8AMIIBCgKCAQEA2YdIAoX0Xw2QfkxPE4lBykEVwm/9qMcXg8bdjP4ZpLJrCzVP
|
||||
tD18QAoEMyr9EHL3Y2OZWz3seO7GTcgOTL7yP+MCdFeawf4VlWNO5yzrcPJryLoB
|
||||
osqhx3b/OOTCsGb8hdKvDyKB1ILr1bDmaRQ33Y2tKc6TaFrO9Hd2b3gTtsgv/uC2
|
||||
fvspFr7i9UU7OVtS3Ca3ygy2HPyoOAvdwfQEmy04yaUtPvFCiFOiOxfP1Twr1mp/
|
||||
bwWNxbddZB6DG+fsgD1tNMFmsuZd2aduRnUUvxAWxfxHjmP65bS98rngy+p1+Wju
|
||||
fY/qjxqfNCd6Sp+F/T4Xp5bD0E5QoqLgRZLQtQIDAQABoyowKDAmBgNVHREEHzAd
|
||||
ghtodHRwcy1vbmx5Lm5naW54LXByb3h5LnRlc3QwDQYJKoZIhvcNAQELBQADggEB
|
||||
AIpSRkKpdBhqUpDvpOnFVNWXOv+LwnZPnkeq4erlua+dM+OFF1R9Mr2skD9c0qFC
|
||||
F1IrsYPlw7+B8Oc44ohne9hZ/vmUmbq+9Dwkssee8Jghxi3C6PNnvWIAqs40+rRT
|
||||
bcEJXlW9Q6qGxvjFg0Y6SRKi7DA2DJlEdAmdzEuYH37Jm2ig+B4AFNDaKr/Iyqgc
|
||||
ELVoovFBkwzzP8DGUzyNp92lezXMROBbbcXLM2/BQ34G3yGZEbORQbRe8DcejuVz
|
||||
hdxKIdVB+U649e0hkwmRwoxrBKSEqzr+NWT6a6eNQKZkiTCErCiZWgF5d8DfiNqp
|
||||
dV/EUa6oRXvS4aKBKWDNe80=
|
||||
-----END CERTIFICATE-----
|
||||
@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEowIBAAKCAQEA2YdIAoX0Xw2QfkxPE4lBykEVwm/9qMcXg8bdjP4ZpLJrCzVP
|
||||
tD18QAoEMyr9EHL3Y2OZWz3seO7GTcgOTL7yP+MCdFeawf4VlWNO5yzrcPJryLoB
|
||||
osqhx3b/OOTCsGb8hdKvDyKB1ILr1bDmaRQ33Y2tKc6TaFrO9Hd2b3gTtsgv/uC2
|
||||
fvspFr7i9UU7OVtS3Ca3ygy2HPyoOAvdwfQEmy04yaUtPvFCiFOiOxfP1Twr1mp/
|
||||
bwWNxbddZB6DG+fsgD1tNMFmsuZd2aduRnUUvxAWxfxHjmP65bS98rngy+p1+Wju
|
||||
fY/qjxqfNCd6Sp+F/T4Xp5bD0E5QoqLgRZLQtQIDAQABAoIBAAWs//YA5MVuJy0E
|
||||
dLO/yxWp6RVvsqCqwTRRBgrdvnGLrjtWosPDLvDE0iM7peq99TKEsMWusfLd2BLD
|
||||
e4wJF20PUUsT1hflt050juR9SY9i4+kS4WQMAXig5DvpzCKqLUCYpLSyY8zVta2X
|
||||
tgtb2bFQNwp2N2ZrqCa8zzxNV8ZXGoW+ZlvBJEDtBwt1DCDhY39/pqHfIhFl4Vwk
|
||||
YhhbVjID145D1j/fP6vLceM2YA4uRmF1itj1iQ6YNNpXRspUGE4DXdqR6HcbduiX
|
||||
trZjmdtKXY8mJg6jyLZxYbjFlKV/LvqKRYF3Jb9K0vdd4juBdZoy7DQzoLhcnzui
|
||||
pEnPLakCgYEA9tN6KdQGKGBXGuF+ZqhXfB/XSkKUf8o/5j62cbu11ZIJ+iEBx+d6
|
||||
lQAxTz5hHUL6a3c5qiM+AWBxYuFD6oqptIlTlBfIXI978neDNvEWWffivPvQLbt9
|
||||
o9ohOirfK1iGPvtrpAwjv5ylE5SiTmJ/6wDvQWjNGAnJ3aaxkesJUSMCgYEA4Z0K
|
||||
UHZVtnKLtzzIY7KfLbuKF/fJEDfMNr4Wgl6ny21vqO9kJGmA7SaoNdhx8RDcKmeV
|
||||
/Vey4ug6YlOG48eapKLTthdRz5mx+jIkUfdOhj81m28xm/OPTqCrviTHCNOHeYDy
|
||||
NKAIlJMo2z0vTKJn5eP6CsYmDWLpHQNyXY5qcEcCgYAzDBWt5O3JF/Or2Yr8zEAb
|
||||
qbIq544yx69jfQDakMnQe72Yf48Quuz9N+b6zpnjJWEJLMU+TL+cJUgN/SzAqyDh
|
||||
96zTaf/ENOCbiuAWUtIelUfNcf7iFm6rnodUsl0pZ8uL5w+iA+i4zjrNy+WtdG2k
|
||||
OrNAwd345L1dHAaJeSSaJQKBgQCUnF3r7Fa/TCpt87LHwSQK+sqWyRf+/9IbiRDI
|
||||
pVL/s8FmVPHw7jIHhHwuo7lCImnz4LGy5C6oOnIizIRAy/04Ty0Hd8ri5YmPlbHI
|
||||
8A8gbMiB7zeNU1zlXP5jzFPyo2tMhLyGH5gnTdwOtfnPD/dCPe45ZJYyISIOg3O0
|
||||
3peMBwKBgH20cskAOCNclfoG+Nis52h8FqmDlflJ8waUarvk26JhO1e009kOytw8
|
||||
x/qSuttpGtTG+4fdc2wJvFNczr4h9ZlftBdgZXj8PKgRpcIe8q97Xg8PUj+Xfu/t
|
||||
vD/QV+tVcGoAMsQq4NeFxiTbPfwVyXdYFT1XVCu6JEdLL+gpWh5W
|
||||
-----END RSA PRIVATE KEY-----
|
||||
36
test/test_fallback.data/nodefault.yml
Normal file
36
test/test_fallback.data/nodefault.yml
Normal file
@ -0,0 +1,36 @@
|
||||
services:
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
- ./nodefault.certs:/etc/nginx/certs:ro
|
||||
https-and-http:
|
||||
image: web
|
||||
expose:
|
||||
- "81"
|
||||
environment:
|
||||
WEB_PORTS: "81"
|
||||
VIRTUAL_HOST: https-and-http.nginx-proxy.test
|
||||
https-only:
|
||||
image: web
|
||||
expose:
|
||||
- "82"
|
||||
environment:
|
||||
WEB_PORTS: "82"
|
||||
VIRTUAL_HOST: https-only.nginx-proxy.test
|
||||
HTTPS_METHOD: nohttp
|
||||
http-only:
|
||||
image: web
|
||||
expose:
|
||||
- "83"
|
||||
environment:
|
||||
WEB_PORTS: "83"
|
||||
VIRTUAL_HOST: http-only.nginx-proxy.test
|
||||
HTTPS_METHOD: nohttps
|
||||
missing-cert:
|
||||
image: web
|
||||
expose:
|
||||
- "84"
|
||||
environment:
|
||||
WEB_PORTS: "84"
|
||||
VIRTUAL_HOST: missing-cert.nginx-proxy.test
|
||||
16
test/test_fallback.data/nohttp-on-app.yml
Normal file
16
test/test_fallback.data/nohttp-on-app.yml
Normal file
@ -0,0 +1,16 @@
|
||||
services:
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
- ./withdefault.certs:/etc/nginx/certs:ro
|
||||
environment:
|
||||
HTTPS_METHOD: redirect
|
||||
https-only:
|
||||
image: web
|
||||
expose:
|
||||
- "82"
|
||||
environment:
|
||||
WEB_PORTS: "82"
|
||||
HTTPS_METHOD: nohttp
|
||||
VIRTUAL_HOST: https-only.nginx-proxy.test
|
||||
22
test/test_fallback.data/nohttp-with-missing-cert.yml
Normal file
22
test/test_fallback.data/nohttp-with-missing-cert.yml
Normal file
@ -0,0 +1,22 @@
|
||||
services:
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
- ./withdefault.certs:/etc/nginx/certs:ro
|
||||
environment:
|
||||
HTTPS_METHOD: nohttp
|
||||
https-only:
|
||||
image: web
|
||||
expose:
|
||||
- "82"
|
||||
environment:
|
||||
WEB_PORTS: "82"
|
||||
VIRTUAL_HOST: https-only.nginx-proxy.test
|
||||
missing-cert:
|
||||
image: web
|
||||
expose:
|
||||
- "84"
|
||||
environment:
|
||||
WEB_PORTS: "84"
|
||||
VIRTUAL_HOST: missing-cert.nginx-proxy.test
|
||||
15
test/test_fallback.data/nohttp.yml
Normal file
15
test/test_fallback.data/nohttp.yml
Normal file
@ -0,0 +1,15 @@
|
||||
services:
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
- ./withdefault.certs:/etc/nginx/certs:ro
|
||||
environment:
|
||||
HTTPS_METHOD: nohttp
|
||||
https-only:
|
||||
image: web
|
||||
expose:
|
||||
- "82"
|
||||
environment:
|
||||
WEB_PORTS: "82"
|
||||
VIRTUAL_HOST: https-only.nginx-proxy.test
|
||||
15
test/test_fallback.data/nohttps-on-app.yml
Normal file
15
test/test_fallback.data/nohttps-on-app.yml
Normal file
@ -0,0 +1,15 @@
|
||||
services:
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
environment:
|
||||
HTTPS_METHOD: redirect
|
||||
http-only:
|
||||
image: web
|
||||
expose:
|
||||
- "83"
|
||||
environment:
|
||||
WEB_PORTS: "83"
|
||||
HTTPS_METHOD: nohttps
|
||||
VIRTUAL_HOST: http-only.nginx-proxy.test
|
||||
14
test/test_fallback.data/nohttps.yml
Normal file
14
test/test_fallback.data/nohttps.yml
Normal file
@ -0,0 +1,14 @@
|
||||
services:
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
environment:
|
||||
HTTPS_METHOD: nohttps
|
||||
http-only:
|
||||
image: web
|
||||
expose:
|
||||
- "83"
|
||||
environment:
|
||||
WEB_PORTS: "83"
|
||||
VIRTUAL_HOST: http-only.nginx-proxy.test
|
||||
70
test/test_fallback.data/withdefault.certs/default.crt
Normal file
70
test/test_fallback.data/withdefault.certs/default.crt
Normal file
@ -0,0 +1,70 @@
|
||||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number: 4096 (0x1000)
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
Issuer: O=nginx-proxy test suite, CN=www.nginx-proxy.tld
|
||||
Validity
|
||||
Not Before: Feb 9 04:02:23 2023 GMT
|
||||
Not After : Jun 27 04:02:23 2050 GMT
|
||||
Subject: CN=*.nginx-proxy.test
|
||||
Subject Public Key Info:
|
||||
Public Key Algorithm: rsaEncryption
|
||||
RSA Public-Key: (2048 bit)
|
||||
Modulus:
|
||||
00:db:bd:54:de:01:7e:82:4e:c0:f1:5d:12:fd:3a:
|
||||
fb:21:19:4d:44:25:47:ea:ad:d8:11:5c:d1:65:88:
|
||||
af:49:fc:8e:4b:c3:01:c1:0d:6d:22:67:bd:31:66:
|
||||
9f:4a:50:17:9e:47:b3:3b:b3:21:73:1f:81:55:73:
|
||||
52:47:9b:fb:85:6b:e8:d8:09:cc:e1:7d:1c:14:03:
|
||||
1c:ae:84:b4:5b:e5:e5:c7:71:fc:1f:74:33:4f:ae:
|
||||
f7:8d:21:1f:55:8d:93:c7:84:4d:93:01:a1:1c:37:
|
||||
ae:85:5c:70:2c:21:ec:87:35:c3:86:d3:b3:0f:9a:
|
||||
b0:9d:8a:cd:0e:49:e8:99:c5:4c:50:bd:a8:6e:a7:
|
||||
01:3e:a7:dc:cf:c3:48:37:8e:c6:8a:89:b0:41:01:
|
||||
58:ee:45:94:fa:90:eb:df:c8:0e:b7:dd:79:75:13:
|
||||
1e:07:69:ee:54:47:92:18:9d:e0:a9:ee:4e:22:d1:
|
||||
f4:a2:4d:a1:47:ed:9b:35:2a:70:cc:66:fb:3e:f0:
|
||||
49:f7:ee:62:2a:27:a1:d3:52:7b:ff:e9:12:d9:5b:
|
||||
6b:f6:18:bf:9c:9d:5f:00:29:d2:54:b5:f8:a4:a2:
|
||||
9b:3f:fe:a6:ed:14:ae:a0:fe:13:33:18:33:17:a9:
|
||||
8b:fe:fc:75:65:0c:fb:c2:d1:1e:81:ca:43:89:bd:
|
||||
78:dd
|
||||
Exponent: 65537 (0x10001)
|
||||
X509v3 extensions:
|
||||
X509v3 Subject Alternative Name:
|
||||
DNS:*.nginx-proxy.test
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
43:a7:1f:4b:ec:ff:1d:70:c7:f8:6e:eb:fd:15:25:27:b2:54:
|
||||
c7:92:cf:ed:51:31:28:56:76:5c:da:8b:17:31:55:8c:a1:c2:
|
||||
37:95:27:7b:b6:58:e5:92:ef:1e:fe:35:f1:44:ca:c7:1b:7b:
|
||||
75:bf:e1:91:61:6d:8a:6f:35:8b:73:f4:d9:08:60:25:07:7a:
|
||||
3e:c2:79:e7:ae:b4:70:cc:8a:30:cb:80:aa:47:1a:40:82:00:
|
||||
a0:5e:01:67:d1:95:21:3c:b1:52:7d:f5:87:b6:43:41:df:b2:
|
||||
a7:ee:3b:73:17:c4:19:2c:6b:7b:3c:26:9e:4c:00:e3:e8:07:
|
||||
f2:e1:a1:31:79:57:be:b6:b1:a7:93:70:4e:e1:7d:bf:08:c5:
|
||||
e7:a0:de:7d:82:20:24:f7:b0:3f:c2:94:36:88:ef:7b:7d:c0:
|
||||
7f:8a:78:a1:8e:56:42:82:ce:82:e6:8e:3d:1b:b7:ca:dd:a9:
|
||||
a8:e6:f9:a3:f4:4a:a4:a0:9c:15:6f:44:8c:48:20:e5:85:ed:
|
||||
6f:85:22:41:1d:1f:fe:58:e5:43:ad:f2:c4:10:5a:10:ed:36:
|
||||
10:98:ad:73:97:6a:e0:19:18:d6:32:26:03:3d:dd:84:5c:2e:
|
||||
97:ca:a2:f5:63:f2:7a:16:f1:55:ca:d2:a1:54:09:8a:bb:23:
|
||||
f0:53:36:51
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIC+zCCAeOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPzEfMB0GA1UECgwWbmdp
|
||||
bngtcHJveHkgdGVzdCBzdWl0ZTEcMBoGA1UEAwwTd3d3Lm5naW54LXByb3h5LnRs
|
||||
ZDAgFw0yMzAyMDkwNDAyMjNaGA8yMDUwMDYyNzA0MDIyM1owHTEbMBkGA1UEAwwS
|
||||
Ki5uZ2lueC1wcm94eS50ZXN0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC
|
||||
AQEA271U3gF+gk7A8V0S/Tr7IRlNRCVH6q3YEVzRZYivSfyOS8MBwQ1tIme9MWaf
|
||||
SlAXnkezO7Mhcx+BVXNSR5v7hWvo2AnM4X0cFAMcroS0W+Xlx3H8H3QzT673jSEf
|
||||
VY2Tx4RNkwGhHDeuhVxwLCHshzXDhtOzD5qwnYrNDknomcVMUL2obqcBPqfcz8NI
|
||||
N47GiomwQQFY7kWU+pDr38gOt915dRMeB2nuVEeSGJ3gqe5OItH0ok2hR+2bNSpw
|
||||
zGb7PvBJ9+5iKieh01J7/+kS2Vtr9hi/nJ1fACnSVLX4pKKbP/6m7RSuoP4TMxgz
|
||||
F6mL/vx1ZQz7wtEegcpDib143QIDAQABoyEwHzAdBgNVHREEFjAUghIqLm5naW54
|
||||
LXByb3h5LnRlc3QwDQYJKoZIhvcNAQELBQADggEBAEOnH0vs/x1wx/hu6/0VJSey
|
||||
VMeSz+1RMShWdlzaixcxVYyhwjeVJ3u2WOWS7x7+NfFEyscbe3W/4ZFhbYpvNYtz
|
||||
9NkIYCUHej7CeeeutHDMijDLgKpHGkCCAKBeAWfRlSE8sVJ99Ye2Q0HfsqfuO3MX
|
||||
xBksa3s8Jp5MAOPoB/LhoTF5V762saeTcE7hfb8Ixeeg3n2CICT3sD/ClDaI73t9
|
||||
wH+KeKGOVkKCzoLmjj0bt8rdqajm+aP0SqSgnBVvRIxIIOWF7W+FIkEdH/5Y5UOt
|
||||
8sQQWhDtNhCYrXOXauAZGNYyJgM93YRcLpfKovVj8noW8VXK0qFUCYq7I/BTNlE=
|
||||
-----END CERTIFICATE-----
|
||||
27
test/test_fallback.data/withdefault.certs/default.key
Normal file
27
test/test_fallback.data/withdefault.certs/default.key
Normal file
@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEowIBAAKCAQEA271U3gF+gk7A8V0S/Tr7IRlNRCVH6q3YEVzRZYivSfyOS8MB
|
||||
wQ1tIme9MWafSlAXnkezO7Mhcx+BVXNSR5v7hWvo2AnM4X0cFAMcroS0W+Xlx3H8
|
||||
H3QzT673jSEfVY2Tx4RNkwGhHDeuhVxwLCHshzXDhtOzD5qwnYrNDknomcVMUL2o
|
||||
bqcBPqfcz8NIN47GiomwQQFY7kWU+pDr38gOt915dRMeB2nuVEeSGJ3gqe5OItH0
|
||||
ok2hR+2bNSpwzGb7PvBJ9+5iKieh01J7/+kS2Vtr9hi/nJ1fACnSVLX4pKKbP/6m
|
||||
7RSuoP4TMxgzF6mL/vx1ZQz7wtEegcpDib143QIDAQABAoIBAGUd9QXMTjkMoIDx
|
||||
QaHCGHocuI+ZUETQBtPGkJ1WjsNPMvPuIsqBsSzZ7Bflj3uU66lseTAJuGTPpKZ7
|
||||
0Ose/llhVN7Fc8B34AndfL9aVdzMKDblXw3iXRJYA5awHUkzQ0PWwBPb9hWUEf1Q
|
||||
klXcrolx1i4fEREnMArvKnlezWikpXcqDYRcmUfEvVozaq75heavHpOcOq2dg7vo
|
||||
N/gcJmfG4aDOhrZC1f22u5cNePvbVj+DdXOUHMEEfXOFbxk97VhmcIaH75ugvVh4
|
||||
EMMg87mcGLZiqPO5k6SYcuGyquc32Tf5sK80mpt/+SAEHCvSmUt9c1ynQrS9IhNp
|
||||
OGfZhQkCgYEA+LonwScVGVEgHg1A9E7BKhIrgUOlwWNM43s+o8Uuz1T72VUVZ6N/
|
||||
aO0+2Panw1qjsb0CUC2zft3zZTiZd81gWRmBYQ0R9dHWyWHbJlOv8rAmJ+60Gr2a
|
||||
UVTLHEdZKx6svSDNhL0HfxxfWwePgHB4NVa2RUA3KQ5y5C96EXb8WbsCgYEA4iow
|
||||
nIIbRZ9ILDz1oThxE+dFifKWXWFOwa58EFBY+/y34itL7kXRu2+4ZIltwL0L8m5j
|
||||
GUALUabuoOASKg4CFBhCvoAAlWZRr6L6EOecrElUnrefUrKuCWPCVo3MnCMuLXDp
|
||||
p1mEGIwEZBCY+jrSBMrRCawsMRkcymLJhEBFYkcCgYB6xIey0vObF2ve6XPSIr09
|
||||
YtKObzF1jun4rnBwrXc5Zx0YXOK/0PemdtO6i6SqzCZYKI7nvGcIi80DfThi5cBU
|
||||
uj4eBTGEQBrgM6jT9iK2izOKKkxDlqqA0nWec6kTm4Rvpa1Lg3Ibz4lRiR3Pq7Pp
|
||||
v+8fp16SqUsUTkrWLADK2QKBgCRIhHf3X4yx2xBNz1JIDcwVpFBXPMxKWio0Ze7w
|
||||
FPaIOq/sJkhZpyYc7EYkzhjHu2zvTLK2VZqJ32qrx/47NRYoNjz9qBpPyfcVfGzN
|
||||
25LASPUVnFfWFpmnCXx9T0AVXMkpfjK857ZQcDvldcVfPmZKa3LTzlsqHjZR1uaC
|
||||
sR7tAoGBANBfInPZVZRJfqqkPN1K8j4P7uCGjTIBmys/vxoilh1d0scTgZrdqt92
|
||||
EKi/3UsJW2ndqQNDLbvi5kcW8a6UU3UB1LLvpyQ5zuS81x3+kKfv+5cDM8rt/M4A
|
||||
MXnJA5eDZZ4SlHFzdblUv/MZdT+1x0tivMn3zFKNNj2SmaSGkQ0m
|
||||
-----END RSA PRIVATE KEY-----
|
||||
@ -0,0 +1,71 @@
|
||||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number: 4096 (0x1000)
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
Issuer: O=nginx-proxy test suite, CN=www.nginx-proxy.tld
|
||||
Validity
|
||||
Not Before: Feb 7 21:54:16 2023 GMT
|
||||
Not After : Jun 25 21:54:16 2050 GMT
|
||||
Subject: CN=http-only.nginx-proxy.test
|
||||
Subject Public Key Info:
|
||||
Public Key Algorithm: rsaEncryption
|
||||
RSA Public-Key: (2048 bit)
|
||||
Modulus:
|
||||
00:b4:62:61:07:54:2e:6d:55:83:2d:24:b7:e2:15:
|
||||
34:13:bd:79:21:e9:10:75:3f:4c:f8:ba:60:29:87:
|
||||
e5:8e:2a:1e:fd:33:51:5a:8a:3a:6f:60:ff:24:f1:
|
||||
1b:27:30:8c:ac:43:04:b7:79:cb:7a:ec:c6:08:a4:
|
||||
a0:15:b0:0f:ee:6b:15:84:24:11:bc:85:2b:48:06:
|
||||
04:0a:58:bb:8c:e8:4d:48:f5:06:c5:91:fe:5d:99:
|
||||
0a:29:31:8a:f1:9b:0c:e0:39:75:a1:06:9b:d4:f5:
|
||||
06:74:8f:46:5e:64:ba:2f:d0:3d:7c:3d:30:03:e9:
|
||||
7c:35:17:69:04:f6:2e:29:d4:93:d6:d6:d2:6c:04:
|
||||
38:06:21:06:05:30:8a:b9:9d:05:8d:12:6e:48:39:
|
||||
bb:f6:93:4f:ba:a5:84:c7:96:2f:be:92:25:e9:d0:
|
||||
95:2a:d9:23:8a:b3:28:0b:b6:19:1c:3b:be:a2:91:
|
||||
70:44:a8:77:18:94:4b:df:61:f4:5c:c9:78:76:34:
|
||||
b5:87:0f:c0:92:04:26:b6:ca:62:cd:9b:5d:eb:bf:
|
||||
10:ac:df:af:72:5f:af:09:38:b1:dc:e1:3d:13:db:
|
||||
a0:ac:b7:2e:ca:39:5c:4c:f1:1e:81:a8:b4:44:a2:
|
||||
72:d5:3b:c0:71:cc:dc:16:0d:fa:38:96:44:b3:00:
|
||||
d6:65
|
||||
Exponent: 65537 (0x10001)
|
||||
X509v3 extensions:
|
||||
X509v3 Subject Alternative Name:
|
||||
DNS:http-only.nginx-proxy.test
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
3b:54:95:48:4d:f6:93:38:42:40:02:ab:b7:17:3b:50:3b:ca:
|
||||
c7:12:69:b0:da:cb:d7:3e:0e:1f:bf:a2:59:c7:fe:c2:5c:43:
|
||||
84:92:b9:3a:be:8f:7e:2e:81:3c:ed:f3:a9:77:21:c2:35:f1:
|
||||
da:cf:3a:1e:e2:ee:a2:ce:72:55:97:87:0e:ad:59:61:f7:75:
|
||||
46:c0:2b:d4:88:b7:36:97:11:fb:5e:28:89:e9:2a:92:f1:15:
|
||||
f1:43:8e:c1:38:85:8d:3a:26:7d:25:72:93:17:96:8d:5a:ed:
|
||||
e8:73:3a:d5:8d:80:f2:af:38:84:ff:85:2e:d1:36:7d:2e:e1:
|
||||
f0:2c:d8:15:5f:fc:c5:70:5d:25:6a:22:f3:2a:cd:0f:25:ad:
|
||||
d4:93:d3:9a:3e:50:bc:da:a5:6c:86:ea:1d:d9:b9:c5:90:db:
|
||||
f5:02:c8:c9:77:5c:ef:77:fe:74:60:41:33:d9:3c:a2:e1:73:
|
||||
aa:14:18:5d:36:58:c8:41:63:4c:59:0e:4b:3d:c5:65:5a:01:
|
||||
b0:16:50:0f:d0:4f:0d:ca:97:f6:11:47:06:6b:b1:ae:bb:26:
|
||||
30:34:8b:7a:91:5d:8a:22:c7:f9:05:0d:bb:a5:b7:60:c0:20:
|
||||
ce:d0:0e:c0:66:b3:e7:c4:61:ec:c5:40:e6:52:11:41:c3:11:
|
||||
18:04:c7:1e
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDCzCCAfOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPzEfMB0GA1UECgwWbmdp
|
||||
bngtcHJveHkgdGVzdCBzdWl0ZTEcMBoGA1UEAwwTd3d3Lm5naW54LXByb3h5LnRs
|
||||
ZDAgFw0yMzAyMDcyMTU0MTZaGA8yMDUwMDYyNTIxNTQxNlowJTEjMCEGA1UEAwwa
|
||||
aHR0cC1vbmx5Lm5naW54LXByb3h5LnRlc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IB
|
||||
DwAwggEKAoIBAQC0YmEHVC5tVYMtJLfiFTQTvXkh6RB1P0z4umAph+WOKh79M1Fa
|
||||
ijpvYP8k8RsnMIysQwS3ect67MYIpKAVsA/uaxWEJBG8hStIBgQKWLuM6E1I9QbF
|
||||
kf5dmQopMYrxmwzgOXWhBpvU9QZ0j0ZeZLov0D18PTAD6Xw1F2kE9i4p1JPW1tJs
|
||||
BDgGIQYFMIq5nQWNEm5IObv2k0+6pYTHli++kiXp0JUq2SOKsygLthkcO76ikXBE
|
||||
qHcYlEvfYfRcyXh2NLWHD8CSBCa2ymLNm13rvxCs369yX68JOLHc4T0T26Csty7K
|
||||
OVxM8R6BqLREonLVO8BxzNwWDfo4lkSzANZlAgMBAAGjKTAnMCUGA1UdEQQeMByC
|
||||
Gmh0dHAtb25seS5uZ2lueC1wcm94eS50ZXN0MA0GCSqGSIb3DQEBCwUAA4IBAQA7
|
||||
VJVITfaTOEJAAqu3FztQO8rHEmmw2svXPg4fv6JZx/7CXEOEkrk6vo9+LoE87fOp
|
||||
dyHCNfHazzoe4u6iznJVl4cOrVlh93VGwCvUiLc2lxH7XiiJ6SqS8RXxQ47BOIWN
|
||||
OiZ9JXKTF5aNWu3oczrVjYDyrziE/4Uu0TZ9LuHwLNgVX/zFcF0laiLzKs0PJa3U
|
||||
k9OaPlC82qVshuod2bnFkNv1AsjJd1zvd/50YEEz2Tyi4XOqFBhdNljIQWNMWQ5L
|
||||
PcVlWgGwFlAP0E8Nypf2EUcGa7GuuyYwNIt6kV2KIsf5BQ27pbdgwCDO0A7AZrPn
|
||||
xGHsxUDmUhFBwxEYBMce
|
||||
-----END CERTIFICATE-----
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user