Compare commits
511 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0f1c79d40 | ||
|
|
3d2f5e2389 | ||
|
|
b079c99fb9 | ||
|
|
2e403c6ebc | ||
|
|
f75a05584e | ||
|
|
148edf6814 | ||
|
|
a19d8aa041 | ||
|
|
480cff86bc | ||
|
|
35df3423d0 | ||
|
|
29f4069de7 | ||
|
|
72e4384596 | ||
|
|
a4a2647737 | ||
|
|
892e533694 | ||
|
|
a056141609 | ||
|
|
0772a9ba8e | ||
|
|
33e0ffd5b1 | ||
|
|
4cb3e089e3 | ||
|
|
8808f161c5 | ||
|
|
1c60ec9804 | ||
|
|
b13ff34569 | ||
|
|
58f2926e95 | ||
|
|
9de628f3eb | ||
|
|
6cc1abc893 | ||
|
|
a824e15684 | ||
|
|
fd52bb7c8d | ||
|
|
0938b20eb8 | ||
|
|
b948e08bd5 | ||
|
|
fde14d1621 | ||
|
|
8a4eb3f2a3 | ||
|
|
2a0b84074a | ||
|
|
aec22d1a81 | ||
|
|
028fc61b4f | ||
|
|
a903960b4c | ||
|
|
a28f06f08f | ||
|
|
6c8bc6b349 | ||
|
|
2b3b4a5c3f | ||
|
|
57e4247eab | ||
|
|
f9d4e90894 | ||
|
|
4f024ec566 | ||
|
|
bc46fc3d4c | ||
|
|
0be1da18a6 | ||
|
|
3cedc0ae13 | ||
|
|
f1d5c07cc1 | ||
|
|
c9a6b6c27d | ||
|
|
b199464a73 | ||
|
|
4a9d64d9d9 | ||
|
|
31536a3fe2 | ||
|
|
7b47c7304f | ||
|
|
83e7ce9cde | ||
|
|
0ad5159a33 | ||
|
|
6240d8e28d | ||
|
|
2f80f64dd5 | ||
|
|
e98da9b637 | ||
|
|
d9f7706969 | ||
|
|
75f299978c | ||
|
|
ef34b2cec1 | ||
|
|
9b9110214a | ||
|
|
9e2a8070e4 | ||
|
|
733136ac1a | ||
|
|
fa172ce5a9 | ||
|
|
f6a9184ae9 | ||
|
|
d37dc2b629 | ||
|
|
f7c115edff | ||
|
|
dfbb091361 | ||
|
|
8e4a65feca | ||
|
|
0573ba7b5a | ||
|
|
bcd421de09 | ||
|
|
2ec28c79cb | ||
|
|
fec60a4b14 | ||
|
|
dd7d1a2c78 | ||
|
|
0c1883472d | ||
|
|
4e6eab794d | ||
|
|
b23135b663 | ||
|
|
ace9be3979 | ||
|
|
8958e5107c | ||
|
|
b2cfc15c2a | ||
|
|
94bef079a8 | ||
|
|
50266c2285 | ||
|
|
22e2fe869f | ||
|
|
55186bbef5 | ||
|
|
d8286ced7c | ||
|
|
44de2253d2 | ||
|
|
6d73fbdedb | ||
|
|
b6809266af | ||
|
|
4e178b474c | ||
|
|
021147f9d9 | ||
|
|
5a26d06c87 | ||
|
|
bc01427def | ||
|
|
652614f41b | ||
|
|
24d9cce82f | ||
|
|
f866ef6325 | ||
|
|
1a32e7c02c | ||
|
|
7180378d0c | ||
|
|
6e66571fb9 | ||
|
|
f44e41cede | ||
|
|
26db144df4 | ||
|
|
a68ad53c3f | ||
|
|
01bba1d3f6 | ||
|
|
0597074438 | ||
|
|
bc3c17a2f0 | ||
|
|
556836b499 | ||
|
|
22612f1757 | ||
|
|
50c279617b | ||
|
|
ef8969e2cf | ||
|
|
0dc2a5ec25 | ||
|
|
9a207dfdc5 | ||
|
|
a60fbbb5b3 | ||
|
|
a1b9010d9e | ||
|
|
3178545c2f | ||
|
|
36b8760d4d | ||
|
|
8bb6676f58 | ||
|
|
4234f82c01 | ||
|
|
b99fb27df5 | ||
|
|
876fcd1814 | ||
|
|
26dc796155 | ||
|
|
280d189864 | ||
|
|
5f845680ff | ||
|
|
d12369c900 | ||
|
|
366e39f591 | ||
|
|
71741b2d34 | ||
|
|
2fca4cd014 | ||
|
|
fccf14627f | ||
|
|
b3684efaf6 | ||
|
|
82548378ae | ||
|
|
b926b0db62 | ||
|
|
6713f56ec1 | ||
|
|
2b923c05c1 | ||
|
|
71cf3cf5c1 | ||
|
|
8e3dbf1c70 | ||
|
|
49ada6a8c5 | ||
|
|
947e86f7c3 | ||
|
|
a12561a85b | ||
|
|
6b19bd0264 | ||
|
|
6738b28b99 | ||
|
|
010c0fd6d4 | ||
|
|
ecf30a71f7 | ||
|
|
ffc4fc950e | ||
|
|
b9955699b7 | ||
|
|
860fd1ace5 | ||
|
|
eb5d13fb8d | ||
|
|
ca41987cd6 | ||
|
|
3af1b397fa | ||
|
|
72a09eac6d | ||
|
|
0d3f7d3925 | ||
|
|
6be082e0a9 | ||
|
|
4947796c99 | ||
|
|
ba197dfa43 | ||
|
|
4dd1ff8479 | ||
|
|
f771ec43f1 | ||
|
|
e241b0c939 | ||
|
|
d03a1a6e3b | ||
|
|
2c9c9fb62c | ||
|
|
deb28c5991 | ||
|
|
2ea7331dad | ||
|
|
92ee40819e | ||
|
|
2ccfb26e81 | ||
|
|
70f9f8417e | ||
|
|
c4aef1d606 | ||
|
|
a385183d88 | ||
|
|
cec47f3a75 | ||
|
|
c894c8370e | ||
|
|
f73b088f79 | ||
|
|
130c6752dd | ||
|
|
f97ea67855 | ||
|
|
8504299861 | ||
|
|
4a8da40cf2 | ||
|
|
0114c7b09f | ||
|
|
bebe89afb0 | ||
|
|
b2cceb608c | ||
|
|
37f5e4ed71 | ||
|
|
98568a57c9 | ||
|
|
4991922878 | ||
|
|
bcb8acc364 | ||
|
|
a9279053a4 | ||
|
|
60057a17e3 | ||
|
|
d0366fcc0d | ||
|
|
b448d91ca8 | ||
|
|
e309ce6fd5 | ||
|
|
37090dc66e | ||
|
|
6bb6facd88 | ||
|
|
a1fcbd4b83 | ||
|
|
09a2a4f9e5 | ||
|
|
1e02368e8a | ||
|
|
bbb5134a39 | ||
|
|
b0f93fb840 | ||
|
|
c892f037db | ||
|
|
731c0f61df | ||
|
|
93543d3962 | ||
|
|
5ec9e6ab49 | ||
|
|
cc0d0af8d2 | ||
|
|
43d2097d14 | ||
|
|
f880e5e2aa | ||
|
|
9636013f5e | ||
|
|
15bdb076c8 | ||
|
|
d62c4f466d | ||
|
|
ad52ef3260 | ||
|
|
3bd3b6fd7a | ||
|
|
e41acc20c2 | ||
|
|
3c721dc2a0 | ||
|
|
491d879fec | ||
|
|
52534510ec | ||
|
|
2c7337576d | ||
|
|
9e4961ccb5 | ||
|
|
01857d8ac0 | ||
|
|
ab9f9e0a4c | ||
|
|
29dc64ca30 | ||
|
|
b5cd4e0375 | ||
|
|
16101144c5 | ||
|
|
95510e6e1d | ||
|
|
dd5890e760 | ||
|
|
c3a437fa82 | ||
|
|
518ddd3236 | ||
|
|
177a82ee6e | ||
|
|
39db7b368f | ||
|
|
9442e59141 | ||
|
|
fcc6b3b5e4 | ||
|
|
678ad70b01 | ||
|
|
e8f5db0b29 | ||
|
|
8295f6aeba | ||
|
|
388fc1a0e8 | ||
|
|
62217a3210 | ||
|
|
53e433b1a4 | ||
|
|
f640157b1f | ||
|
|
d646f3e5b7 | ||
|
|
4b31d005eb | ||
|
|
d2135c19c0 | ||
|
|
8cda1baf77 | ||
|
|
445032406b | ||
|
|
74fb015366 | ||
|
|
ee178de6ab | ||
|
|
7323525b69 | ||
|
|
82e47f147d | ||
|
|
2db967ad1d | ||
|
|
1d96620ae6 | ||
|
|
99c259bf18 | ||
|
|
c7b81cfc10 | ||
|
|
dfce0c06dd | ||
|
|
0f8e56a668 | ||
|
|
f950abdc24 | ||
|
|
4a73ae8197 | ||
|
|
e2f02ee91e | ||
|
|
a991b262ef | ||
|
|
a8bc17e836 | ||
|
|
ec19f93081 | ||
|
|
23aa053003 | ||
|
|
289ad106cb | ||
|
|
bbc5bbc9e9 | ||
|
|
633a07686f | ||
|
|
996c45df42 | ||
|
|
801530baf3 | ||
|
|
c65dda3917 | ||
|
|
ea891969c1 | ||
|
|
698ae17c49 | ||
|
|
6645632846 | ||
|
|
16e5ede130 | ||
|
|
8260746fe1 | ||
|
|
de560490d3 | ||
|
|
96db3a450d | ||
|
|
73543f4b0e | ||
|
|
d9bb97be50 | ||
|
|
863283d090 | ||
|
|
600484b16e | ||
|
|
7c6a13c549 | ||
|
|
b3bb4ec40f | ||
|
|
69f4657208 | ||
|
|
d02985d213 | ||
|
|
b0ca85ff75 | ||
|
|
2f115c444d | ||
|
|
7f15741ea2 | ||
|
|
288b8eb851 | ||
|
|
61c08fb97b | ||
|
|
01ef47a669 | ||
|
|
71515a9101 | ||
|
|
a33d0658c6 | ||
|
|
0b3ff6a9f4 | ||
|
|
eb2d0d330d | ||
|
|
5bcbb38638 | ||
|
|
ca660b2501 | ||
|
|
3a34436cd8 | ||
|
|
b1d03cd11c | ||
|
|
42c3fb8740 | ||
|
|
f1c043604a | ||
|
|
fd61df205f | ||
|
|
009d6fb5ae | ||
|
|
ba4185a42e | ||
|
|
70976d0fbc | ||
|
|
062a39c63a | ||
|
|
83841b290a | ||
|
|
10dc58cb6d | ||
|
|
668754686c | ||
|
|
84b1933f63 | ||
|
|
15f6d0a32a | ||
|
|
e628361a89 | ||
|
|
f8d71e067e | ||
|
|
02ae3b6bd3 | ||
|
|
2fb0e7c473 | ||
|
|
9adcc2f1a7 | ||
|
|
7b98db4d14 | ||
|
|
ddb2b85916 | ||
|
|
da1a460a64 | ||
|
|
07be626842 | ||
|
|
3bb164395e | ||
|
|
bc2568a172 | ||
|
|
5ec74880d8 | ||
|
|
f84fd7c9a2 | ||
|
|
6521d7a27a | ||
|
|
813607fbc3 | ||
|
|
843644f806 | ||
|
|
19fa0eb25f | ||
|
|
b4df287228 | ||
|
|
5ce41edc03 | ||
|
|
a3cfb50b4d | ||
|
|
25494acace | ||
|
|
a98dae1fb6 | ||
|
|
1a7abab570 | ||
|
|
42b7a57f01 | ||
|
|
02f9fbe5fc | ||
|
|
69fe066777 | ||
|
|
74417abc9c | ||
|
|
ba7524a419 | ||
|
|
b55aafb997 | ||
|
|
deeb7a76a2 | ||
|
|
ee8aaa4e7e | ||
|
|
605d59a45c | ||
|
|
b85c991b6e | ||
|
|
0d3658adf0 | ||
|
|
0b22209c96 | ||
|
|
e44a1f3e14 | ||
|
|
aa614f82f9 | ||
|
|
c03d410b0a | ||
|
|
e190167bfc | ||
|
|
31e72dce1c | ||
|
|
b8105fc558 | ||
|
|
e73c10fd80 | ||
|
|
a122a259c0 | ||
|
|
7c4894d3b8 | ||
|
|
533c2a1034 | ||
|
|
5611d544d6 | ||
|
|
397182f18d | ||
|
|
c5c5fb17b5 | ||
|
|
017a7780fb | ||
|
|
34d9db7a8b | ||
|
|
361c66ca61 | ||
|
|
afc6678855 | ||
|
|
c40fb33175 | ||
|
|
93ad3c0b51 | ||
|
|
ceed904882 | ||
|
|
b8027d2bac | ||
|
|
8d03a14a6a | ||
|
|
d16f4517a4 | ||
|
|
89ca91b3ff | ||
|
|
6a714e2ece | ||
|
|
0d3da03534 | ||
|
|
33163f65b3 | ||
|
|
a2543384cd | ||
|
|
3591715f21 | ||
|
|
95f7ca5b2d | ||
|
|
816fa47cbb | ||
|
|
7756c2df3c | ||
|
|
7509ec2f2c | ||
|
|
6e93575e16 | ||
|
|
ba4c977550 | ||
|
|
781e4c8cbb | ||
|
|
e04c783d1e | ||
|
|
e12b656bd5 | ||
|
|
cae05447d3 | ||
|
|
4b58e22657 | ||
|
|
6b56e21a09 | ||
|
|
544a09e8da | ||
|
|
8386dd4a2a | ||
|
|
f052a25168 | ||
|
|
43750f5536 | ||
|
|
9142afdb54 | ||
|
|
66c4fed791 | ||
|
|
f41846e9d6 | ||
|
|
92cc705b92 | ||
|
|
47fb3a05b3 | ||
|
|
5940f402c7 | ||
|
|
d9ca275d53 | ||
|
|
8353bd9c85 | ||
|
|
d902e2f297 | ||
|
|
1a8b8043c8 | ||
|
|
65120a7e97 | ||
|
|
b093a47554 | ||
|
|
73dbf03c9a | ||
|
|
6ee746236a | ||
|
|
fa935eb6e3 | ||
|
|
cf231e13cb | ||
|
|
d5d699252c | ||
|
|
50f95420b5 | ||
|
|
dc382c3e04 | ||
|
|
0026328f25 | ||
|
|
9023ab5aed | ||
|
|
124474ad66 | ||
|
|
eac9c8f513 | ||
|
|
1ee490de6d | ||
|
|
825e6a747e | ||
|
|
09a984c86b | ||
|
|
fd7afa17b3 | ||
|
|
b9b7fdfcc4 | ||
|
|
58e1d66bc7 | ||
|
|
7026643f8a | ||
|
|
06f688fe97 | ||
|
|
c65b78b1cc | ||
|
|
f9b9b9546f | ||
|
|
b5fe6335c7 | ||
|
|
951f3957fd | ||
|
|
0f520b8914 | ||
|
|
569ad75c42 | ||
|
|
bd7b6af668 | ||
|
|
459bb8ea1c | ||
|
|
208b5acb30 | ||
|
|
59b2fed416 | ||
|
|
a4871a915e | ||
|
|
026783f018 | ||
|
|
8115853453 | ||
|
|
c5f283b00e | ||
|
|
03ce7a6483 | ||
|
|
3f7e2c54b3 | ||
|
|
bb0f46d8af | ||
|
|
c5b32dfc4c | ||
|
|
9a4f96ad18 | ||
|
|
f258426f55 | ||
|
|
119e963612 | ||
|
|
373988670a | ||
|
|
2a956f2cd3 | ||
|
|
15a37a8682 | ||
|
|
3a3d527907 | ||
|
|
e6b5f460c9 | ||
|
|
002e3ed2ba | ||
|
|
7b55acbe8b | ||
|
|
559b7835d4 | ||
|
|
4ea01bd93f | ||
|
|
a73891a3b8 | ||
|
|
26199f52c8 | ||
|
|
5c3f94a84f | ||
|
|
043fcdc136 | ||
|
|
b86ded3d1c | ||
|
|
92569679b6 | ||
|
|
15e74e4860 | ||
|
|
fd0a6412d0 | ||
|
|
419fdfc86e | ||
|
|
0bc1f652b4 | ||
|
|
6c7461e298 | ||
|
|
d01bc5e014 | ||
|
|
75c69c8105 | ||
|
|
e26b8482aa | ||
|
|
f618c73e6c | ||
|
|
78c1e5c676 | ||
|
|
481e10d3ef | ||
|
|
aae2a71983 | ||
|
|
f3bf04e390 | ||
|
|
36cbb927c0 | ||
|
|
95153dbc5d | ||
|
|
26947179a4 | ||
|
|
88f27bfeb8 | ||
|
|
3cc1615c4d | ||
|
|
8bacf722a6 | ||
|
|
2bfc4b41fa | ||
|
|
587d4a92eb | ||
|
|
c311d0c825 | ||
|
|
0d03f49ebc | ||
|
|
2112c306a8 | ||
|
|
8f9dcc5ab8 | ||
|
|
2fe05d3fd3 | ||
|
|
db04c0345c | ||
|
|
ed8bd902b1 | ||
|
|
3a7aa5d9c0 | ||
|
|
9ec9de6ca2 | ||
|
|
791342cbe6 | ||
|
|
2f23671c3b | ||
|
|
e350a717ff | ||
|
|
e818acb0d1 | ||
|
|
b92f74ed98 | ||
|
|
9688e66508 | ||
|
|
700dfc0184 | ||
|
|
42e4298b5c | ||
|
|
813b42cfa9 | ||
|
|
58fcf0a725 | ||
|
|
5879183802 | ||
|
|
2032596880 | ||
|
|
eaf817d57a | ||
|
|
dd7768c856 | ||
|
|
fe1d724c9f | ||
|
|
0635eb368b | ||
|
|
fbf81c94be | ||
|
|
ed451877ae | ||
|
|
0f18e9c552 | ||
|
|
8f7cb5318e | ||
|
|
60fbbc1013 | ||
|
|
0f0593456c | ||
|
|
8cdc155ac0 | ||
|
|
1abe1da89e | ||
|
|
f18c054b42 | ||
|
|
4dea1975e2 | ||
|
|
c2b05c463c | ||
|
|
2da51d92a6 | ||
|
|
bd7997497b | ||
|
|
e89e34a84f | ||
|
|
ff02878dd8 | ||
|
|
44b016be93 | ||
|
|
36c4f3e065 | ||
|
|
798f6c726d | ||
|
|
761c14a0b8 | ||
|
|
4a07eca696 | ||
|
|
e1274a6082 | ||
|
|
3ec81cd849 | ||
|
|
95752ff0c4 | ||
|
|
8623510f8c | ||
|
|
95a76b11fa | ||
|
|
b0e4740a7d |
17
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
17
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Something is not working as expected
|
||||||
|
title: "[BUG]"
|
||||||
|
labels: bug
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Description**
|
||||||
|
Concise description of what you're trying to do, the expected behavior and the current bug.
|
||||||
|
|
||||||
|
**How to reproduce**
|
||||||
|
Give steps on how to reproduce the bug (e.g. : commands, configs, tests, environment, version, ...).
|
||||||
|
|
||||||
|
**Logs**
|
||||||
|
The logs generated by bunkerized-nginx. **DON'T FORGET TO REMOVE PRIVATE DATA LIKE IP ADDRESSES !**
|
||||||
14
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
14
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: "[FEATURE]"
|
||||||
|
labels: enhancement
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**What's needed and why ?**
|
||||||
|
Describe the feature you would like to see in the project and why it should be implemented.
|
||||||
|
|
||||||
|
**Implementations ideas (optional)**
|
||||||
|
How it should be used and integrated into the project ? List some posts, research papers or codes that we can use as implementation.
|
||||||
83
.github/workflows/build-bunkerized-nginx-autoconf.yml
vendored
Normal file
83
.github/workflows/build-bunkerized-nginx-autoconf.yml
vendored
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
name: Build and push bunkerized-nginx-autoconf
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [dev, master]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Checkout source code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
# temp fix : can't use buildx + load because of manifest error
|
||||||
|
# so we need to build the image the traditional way
|
||||||
|
- name: Temp build to check security issues
|
||||||
|
run: docker build -t bunkerized-nginx-autoconf -f autoconf/Dockerfile .
|
||||||
|
|
||||||
|
- name: Run Trivy security scanner
|
||||||
|
uses: aquasecurity/trivy-action@master
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
image-ref: 'bunkerized-nginx-autoconf'
|
||||||
|
format: 'table'
|
||||||
|
exit-code: '1'
|
||||||
|
ignore-unfixed: true
|
||||||
|
severity: 'UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL'
|
||||||
|
|
||||||
|
- name: Set variables
|
||||||
|
run: |
|
||||||
|
VER=$(cat VERSION | tr -d '\n')
|
||||||
|
echo "VERSION=$VER" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Setup QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
|
||||||
|
- name: Setup Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Setup Docker cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
if: github.ref == 'refs/heads/dev'
|
||||||
|
with:
|
||||||
|
path: /tmp/.buildx-cache
|
||||||
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-buildx-
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push (dev)
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
if: github.ref == 'refs/heads/dev'
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: autoconf/Dockerfile
|
||||||
|
platforms: linux/amd64,linux/386,linux/arm/v7,linux/arm64/v8
|
||||||
|
push: true
|
||||||
|
tags: bunkerity/bunkerized-nginx-autoconf:dev
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local,dest=/tmp/.buildx-cache-new
|
||||||
|
|
||||||
|
- name: Move Docker cache
|
||||||
|
if: github.ref == 'refs/heads/dev'
|
||||||
|
run: |
|
||||||
|
rm -rf /tmp/.buildx-cache
|
||||||
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||||
|
|
||||||
|
- name: Build and push (master)
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: autoconf/Dockerfile
|
||||||
|
platforms: linux/amd64,linux/386,linux/arm/v7,linux/arm64/v8
|
||||||
|
push: true
|
||||||
|
tags: bunkerity/bunkerized-nginx-autoconf:latest,bunkerity/bunkerized-nginx-autoconf:${{ env.VERSION }}
|
||||||
|
|
||||||
82
.github/workflows/build-bunkerized-nginx-ui.yml
vendored
Normal file
82
.github/workflows/build-bunkerized-nginx-ui.yml
vendored
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
name: Build and push bunkerized-nginx-ui
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [dev, master]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Checkout source code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
# temp fix : can't use buildx + load because of manifest error
|
||||||
|
# so we need to build the image the traditional way
|
||||||
|
- name: Temp build to check security issues
|
||||||
|
run: docker build -t bunkerized-nginx-ui -f ui/Dockerfile .
|
||||||
|
|
||||||
|
- name: Run Trivy security scanner
|
||||||
|
uses: aquasecurity/trivy-action@master
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
image-ref: 'bunkerized-nginx-ui'
|
||||||
|
format: 'table'
|
||||||
|
exit-code: '1'
|
||||||
|
ignore-unfixed: true
|
||||||
|
severity: 'UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL'
|
||||||
|
|
||||||
|
- name: Set variables
|
||||||
|
run: |
|
||||||
|
VER=$(cat VERSION | tr -d '\n')
|
||||||
|
echo "VERSION=$VER" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Setup QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
|
||||||
|
- name: Setup Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Setup Docker cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
if: github.ref == 'refs/heads/dev'
|
||||||
|
with:
|
||||||
|
path: /tmp/.buildx-cache
|
||||||
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-buildx-
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push (dev)
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
if: github.ref == 'refs/heads/dev'
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ui/Dockerfile
|
||||||
|
platforms: linux/amd64,linux/386,linux/arm/v7,linux/arm64/v8
|
||||||
|
push: true
|
||||||
|
tags: bunkerity/bunkerized-nginx-ui:dev
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local,dest=/tmp/.buildx-cache-new
|
||||||
|
|
||||||
|
- name: Move Docker cache
|
||||||
|
if: github.ref == 'refs/heads/dev'
|
||||||
|
run: |
|
||||||
|
rm -rf /tmp/.buildx-cache
|
||||||
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||||
|
|
||||||
|
- name: Build and push (master)
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ui/Dockerfile
|
||||||
|
platforms: linux/amd64,linux/386,linux/arm/v7,linux/arm64/v8
|
||||||
|
push: true
|
||||||
|
tags: bunkerity/bunkerized-nginx-ui:latest,bunkerity/bunkerized-nginx-ui:${{ env.VERSION }}
|
||||||
83
.github/workflows/build-bunkerized-nginx.yml
vendored
Normal file
83
.github/workflows/build-bunkerized-nginx.yml
vendored
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
name: Build and push bunkerized-nginx
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [dev, master]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Checkout source code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
# temp fix : can't use buildx + load because of manifest error
|
||||||
|
# so we need to build the image the traditional way
|
||||||
|
- name: Temp build to check security issues
|
||||||
|
run: docker build -t bunkerized-nginx .
|
||||||
|
|
||||||
|
- name: Run Trivy security scanner
|
||||||
|
uses: aquasecurity/trivy-action@master
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
image-ref: 'bunkerized-nginx'
|
||||||
|
format: 'table'
|
||||||
|
exit-code: '1'
|
||||||
|
ignore-unfixed: true
|
||||||
|
severity: 'UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL'
|
||||||
|
|
||||||
|
- name: Run autotest
|
||||||
|
run: docker run bunkerized-nginx test
|
||||||
|
|
||||||
|
- name: Set variables
|
||||||
|
run: |
|
||||||
|
VER=$(cat VERSION | tr -d '\n')
|
||||||
|
echo "VERSION=$VER" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Setup QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
|
||||||
|
- name: Setup Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Setup Docker cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
if: github.ref == 'refs/heads/dev'
|
||||||
|
with:
|
||||||
|
path: /tmp/.buildx-cache
|
||||||
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-buildx-
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push (dev)
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
if: github.ref == 'refs/heads/dev'
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64,linux/386,linux/arm/v7,linux/arm64/v8
|
||||||
|
push: true
|
||||||
|
tags: bunkerity/bunkerized-nginx:dev
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local,dest=/tmp/.buildx-cache-new
|
||||||
|
|
||||||
|
- name: Move Docker cache
|
||||||
|
if: github.ref == 'refs/heads/dev'
|
||||||
|
run: |
|
||||||
|
rm -rf /tmp/.buildx-cache
|
||||||
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||||
|
|
||||||
|
- name: Build and push (master)
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64,linux/386,linux/arm/v7,linux/arm64/v8
|
||||||
|
push: true
|
||||||
|
tags: bunkerity/bunkerized-nginx:latest,bunkerity/bunkerized-nginx:${{ env.VERSION }}
|
||||||
30
.github/workflows/linux-bunkerized-nginx.yml
vendored
Normal file
30
.github/workflows/linux-bunkerized-nginx.yml
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
name: Automatic test for Linux
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [dev, master]
|
||||||
|
pull_request:
|
||||||
|
branches: [dev, master]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout source code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Build Debian with systemd
|
||||||
|
run: docker build -t debian-systemd -f tests/Dockerfile-debian .
|
||||||
|
- name: Build Ubuntu with systemd
|
||||||
|
run: docker build -t ubuntu-systemd -f tests/Dockerfile-ubuntu .
|
||||||
|
- name: Build CentOS with systemd
|
||||||
|
run: docker build -t centos-systemd -f tests/Dockerfile-centos .
|
||||||
|
- name: Build Fedora with systemd
|
||||||
|
run: docker build -t fedora-systemd -f tests/Dockerfile-fedora .
|
||||||
|
- name: Debian test
|
||||||
|
run: ./tests/linux-run.sh debian-systemd test-debian
|
||||||
|
- name: Ubuntu test
|
||||||
|
run: ./tests/linux-run.sh ubuntu-systemd test-ubuntu
|
||||||
|
- name: CentOS test
|
||||||
|
run: ./tests/linux-run.sh centos-systemd test-centos
|
||||||
|
- name: Fedora test
|
||||||
|
run: ./tests/linux-run.sh fedora-systemd test-fedora
|
||||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
.idea/
|
||||||
|
docs/_build/
|
||||||
7
.gitmodules
vendored
Normal file
7
.gitmodules
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[submodule "bunkerized-nginx-crowdsec"]
|
||||||
|
path = examples/crowdsec/bunkerized-nginx-crowdsec
|
||||||
|
url = https://github.com/bunkerity/bunkerized-nginx-crowdsec
|
||||||
|
|
||||||
|
[submodule "examples/clamav/bunkerized-nginx-clamav"]
|
||||||
|
path = examples/clamav/bunkerized-nginx-clamav
|
||||||
|
url = https://github.com/bunkerity/bunkerized-nginx-clamav.git
|
||||||
78
CHANGELOG.md
Normal file
78
CHANGELOG.md
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## v1.3.1 - 2021/09/02
|
||||||
|
|
||||||
|
- Use ModSecurity v3.0.4 instead of v3.0.5 to fix memory leak
|
||||||
|
- Fix ignored variables to control jobs
|
||||||
|
- Fix bug when LISTEN_HTTP=no and MULTISITE=yes
|
||||||
|
- Add CUSTOM_HEADER variable
|
||||||
|
- Add REVERSE_PROXY_BUFFERING variable
|
||||||
|
- Fix documentation for modsec and modsec-crs special folders
|
||||||
|
|
||||||
|
## v1.3.0 - 2021/08/23
|
||||||
|
|
||||||
|
- Kubernetes integration in beta
|
||||||
|
- Linux integration in beta
|
||||||
|
- autoconf refactoring
|
||||||
|
- jobs refactoring
|
||||||
|
- UI refactoring
|
||||||
|
- UI security : login/password authentication and CRSF protection
|
||||||
|
- various dependencies updates
|
||||||
|
- move CrowdSec as an external plugin
|
||||||
|
- Authelia support
|
||||||
|
- improve various regexes
|
||||||
|
- add INJECT_BODY variable
|
||||||
|
- add WORKER_PROCESSES variable
|
||||||
|
- add USE_LETS_ENCRYPT_STAGING variable
|
||||||
|
- add LOCAL_PHP and LOCAL_PHP_PATH variables
|
||||||
|
- add REDIRECT_TO variable
|
||||||
|
|
||||||
|
## v1.2.8 - 2021/07/22
|
||||||
|
|
||||||
|
- Fix broken links in README
|
||||||
|
- Fix regex for EMAIL_LETS_ENCRYPT
|
||||||
|
- Fix regex for REMOTE_PHP and REMOTE_PHP_PATH
|
||||||
|
- Fix regex for SELF_SIGNED_*
|
||||||
|
- Fix various bugs related to web UI
|
||||||
|
- Fix bug in autoconf (missing instances parameter to reload function)
|
||||||
|
- Remove old .env files when generating a new configuration
|
||||||
|
|
||||||
|
## v1.2.7 - 2021/06/14
|
||||||
|
|
||||||
|
- Add custom robots.txt and sitemap to RTD
|
||||||
|
- Fix missing GeoIP DB bug when using BLACKLIST/WHITELIST_COUNTRY
|
||||||
|
- Add underscore "_" to allowed chars for CUSTOM_HTTPS_CERT/KEY
|
||||||
|
- Fix bug when using automatic self-signed certificate
|
||||||
|
- Build and push images from GitHub actions instead of Docker Hub autobuild
|
||||||
|
- Display the reason when generator is ignoring a variable
|
||||||
|
- Various bug fixes related to certbot and jobs
|
||||||
|
- Split jobs into pre and post jobs
|
||||||
|
- Add HEALTHCHECK to image
|
||||||
|
- Fix race condition when using autoconf without Swarm by checking healthy state
|
||||||
|
- Bump modsecurity-nginx to v1.0.2
|
||||||
|
- Community chat with bridged platforms
|
||||||
|
|
||||||
|
## v1.2.6 - 2021/06/06
|
||||||
|
|
||||||
|
- Move from "ghetto-style" shell scripts to generic jinja2 templating
|
||||||
|
- Init work on a basic plugins system
|
||||||
|
- Move ClamAV to external plugin
|
||||||
|
- Reduce image size by removing unnecessary dependencies
|
||||||
|
- Fix CrowdSec example
|
||||||
|
- Change some global variables to multisite
|
||||||
|
- Add LOG_LEVEL environment variable
|
||||||
|
- Read-only container support
|
||||||
|
- Improved antibot javascript with a basic proof of work
|
||||||
|
- Update nginx to 1.20.1
|
||||||
|
- Support of docker-socket-proxy with web UI
|
||||||
|
- Add certbot-cloudflare example
|
||||||
|
- Disable DNSBL checks when IP is local
|
||||||
|
|
||||||
|
## v1.2.5 - 2021/05/14
|
||||||
|
|
||||||
|
- Performance improvement : move some nginx security checks to LUA and external blacklist parsing enhancement
|
||||||
|
- Init work on official documentation on readthedocs
|
||||||
|
- Fix default value for CONTENT_SECURITY_POLICY to allow file downloads
|
||||||
|
- Add ROOT_SITE_SUBFOLDER environment variable
|
||||||
|
|
||||||
|
## TODO - retrospective changelog
|
||||||
24
CONTRIBUTING.md
Normal file
24
CONTRIBUTING.md
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Contributing to bunkerized-nginx
|
||||||
|
|
||||||
|
First off all, thanks for being here and showing your support to the project !
|
||||||
|
|
||||||
|
We accept many types of contributions whether they are technical or not. Every community feedback, work or help is, and will always be, appreciated.
|
||||||
|
|
||||||
|
## Talk about the project
|
||||||
|
|
||||||
|
The first thing you can do is to talk about the project. You can share it on social media, make a blog post about it or simply tell your friends/colleagues that's an awesome project.
|
||||||
|
|
||||||
|
## Join the community chat
|
||||||
|
|
||||||
|
You can join [the community chat](https://coso.me/bunkerity-chat) to talk about the project and ask for help. Please note that you can choose the platform you want, thanks to [matterbridge](https://github.com/42wim/matterbridge) all messages coming from a platform are relayed to the others.
|
||||||
|
|
||||||
|
## Reporting bugs / ask for features
|
||||||
|
|
||||||
|
The preferred way to report bugs and asking for features is using [issues](https://github.com/bunkerity/bunkerized-nginx/issues). Before opening a new one, please check if a related issue is already opened using the "filters" bar. When creating a new issue please select and fill the "Bug report" or "Feature request" template.
|
||||||
|
|
||||||
|
## Code contribution
|
||||||
|
|
||||||
|
The preferred way to contribute code is using [pull requests](https://github.com/bunkerity/bunkerized-nginx/pulls). Before creating a pull request, please check if your code is related to an opened issue. If that's not the case, you should first create an issue so we can discuss about it. This procedure is here to avoid wasting your time in case the PR will be rejected. For minor changes (e.g. : typo, quick fix, ...), opening an issue might be facultative. **Don't forget to edit the documentations when needed !**
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
41
Dockerfile
41
Dockerfile
@@ -1,29 +1,26 @@
|
|||||||
FROM nginx:stable-alpine
|
FROM nginx:1.20.1-alpine
|
||||||
|
|
||||||
COPY nginx-keys/ /tmp/nginx-keys
|
COPY . /tmp/bunkerized-nginx-docker
|
||||||
COPY compile.sh /tmp/compile.sh
|
COPY helpers/install.sh /tmp/install.sh
|
||||||
RUN chmod +x /tmp/compile.sh && \
|
RUN apk --no-cache add bash && \
|
||||||
/tmp/compile.sh && \
|
chmod +x /tmp/install.sh && \
|
||||||
rm -rf /tmp/*
|
/tmp/install.sh && \
|
||||||
|
rm -f /tmp/install.sh
|
||||||
|
|
||||||
COPY entrypoint.sh /opt/entrypoint.sh
|
COPY helpers/docker.sh /tmp/docker.sh
|
||||||
COPY confs/ /opt/confs
|
RUN chmod +x /tmp/docker.sh && \
|
||||||
COPY scripts/ /opt/scripts
|
/tmp/docker.sh && \
|
||||||
COPY fail2ban/ /opt/fail2ban
|
rm -f /tmp/docker.sh
|
||||||
COPY logs/ /opt/logs
|
|
||||||
COPY lua/ /opt/lua
|
|
||||||
|
|
||||||
RUN apk --no-cache add certbot libstdc++ libmaxminddb geoip pcre yajl fail2ban clamav apache2-utils rsyslog openssl lua libgd && \
|
# Fix CVE-2021-22901, CVE-2021-22898, CVE-2021-22897, CVE-2021-33560 and CVE-2021-36159
|
||||||
chmod +x /opt/entrypoint.sh /opt/scripts/* && \
|
RUN apk add "curl>=7.77.0-r0" "libgcrypt>=1.8.8-r0" "apk-tools>=2.12.6-r0"
|
||||||
mkdir /opt/entrypoint.d && \
|
|
||||||
rm -f /var/log/nginx/* && \
|
|
||||||
chown root:nginx /var/log/nginx && \
|
|
||||||
chmod 750 /var/log/nginx && \
|
|
||||||
touch /var/log/nginx/error.log /var/log/nginx/modsec_audit.log && \
|
|
||||||
chown nginx:nginx /var/log/nginx/*.log
|
|
||||||
|
|
||||||
VOLUME /www /http-confs /server-confs /modsec-confs /modsec-crs-confs
|
VOLUME /www /http-confs /server-confs /modsec-confs /modsec-crs-confs /cache /pre-server-confs /acme-challenge /plugins
|
||||||
|
|
||||||
EXPOSE 8080/tcp 8443/tcp
|
EXPOSE 8080/tcp 8443/tcp
|
||||||
|
|
||||||
ENTRYPOINT ["/opt/entrypoint.sh"]
|
USER nginx:nginx
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 CMD [ -f /tmp/nginx.pid ] || [ -f /tmp/nginx-temp.pid ] || exit 1
|
||||||
|
|
||||||
|
ENTRYPOINT ["/opt/bunkerized-nginx/entrypoint/entrypoint.sh"]
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
FROM amd64/nginx:stable-alpine
|
|
||||||
|
|
||||||
COPY nginx-keys/ /tmp/nginx-keys
|
|
||||||
COPY compile.sh /tmp/compile.sh
|
|
||||||
RUN chmod +x /tmp/compile.sh && \
|
|
||||||
/tmp/compile.sh && \
|
|
||||||
rm -rf /tmp/*
|
|
||||||
|
|
||||||
COPY entrypoint.sh /opt/entrypoint.sh
|
|
||||||
COPY confs/ /opt/confs
|
|
||||||
COPY scripts/ /opt/scripts
|
|
||||||
COPY fail2ban/ /opt/fail2ban
|
|
||||||
COPY logs/ /opt/logs
|
|
||||||
COPY lua/ /opt/lua
|
|
||||||
|
|
||||||
RUN apk --no-cache add certbot libstdc++ libmaxminddb geoip pcre yajl fail2ban clamav apache2-utils rsyslog openssl lua libgd && \
|
|
||||||
chmod +x /opt/entrypoint.sh /opt/scripts/* && \
|
|
||||||
mkdir /opt/entrypoint.d && \
|
|
||||||
rm -f /var/log/nginx/* && \
|
|
||||||
chown root:nginx /var/log/nginx && \
|
|
||||||
chmod 750 /var/log/nginx && \
|
|
||||||
touch /var/log/nginx/error.log /var/log/nginx/modsec_audit.log && \
|
|
||||||
chown nginx:nginx /var/log/nginx/*.log
|
|
||||||
|
|
||||||
VOLUME /www /http-confs /server-confs /modsec-confs /modsec-crs-confs
|
|
||||||
|
|
||||||
EXPOSE 8080/tcp 8443/tcp
|
|
||||||
|
|
||||||
ENTRYPOINT ["/opt/entrypoint.sh"]
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
FROM alpine AS builder
|
|
||||||
|
|
||||||
ENV QEMU_URL https://github.com/balena-io/qemu/releases/download/v4.0.0%2Bbalena2/qemu-4.0.0.balena2-arm.tar.gz
|
|
||||||
RUN apk add curl && curl -L ${QEMU_URL} | tar zxvf - -C . --strip-components 1
|
|
||||||
|
|
||||||
FROM arm32v7/nginx:stable-alpine
|
|
||||||
|
|
||||||
COPY --from=builder qemu-arm-static /usr/bin
|
|
||||||
|
|
||||||
COPY nginx-keys/ /tmp/nginx-keys
|
|
||||||
COPY compile.sh /tmp/compile.sh
|
|
||||||
RUN chmod +x /tmp/compile.sh && \
|
|
||||||
/tmp/compile.sh && \
|
|
||||||
rm -rf /tmp/*
|
|
||||||
|
|
||||||
COPY entrypoint.sh /opt/entrypoint.sh
|
|
||||||
COPY confs/ /opt/confs
|
|
||||||
COPY scripts/ /opt/scripts
|
|
||||||
COPY fail2ban/ /opt/fail2ban
|
|
||||||
COPY logs/ /opt/logs
|
|
||||||
COPY lua/ /opt/lua
|
|
||||||
|
|
||||||
RUN apk --no-cache add certbot libstdc++ libmaxminddb geoip pcre yajl fail2ban clamav apache2-utils rsyslog openssl lua libgd && \
|
|
||||||
chmod +x /opt/entrypoint.sh /opt/scripts/* && \
|
|
||||||
mkdir /opt/entrypoint.d && \
|
|
||||||
rm -f /var/log/nginx/* && \
|
|
||||||
chown root:nginx /var/log/nginx && \
|
|
||||||
chmod 750 /var/log/nginx && \
|
|
||||||
touch /var/log/nginx/error.log /var/log/nginx/modsec_audit.log && \
|
|
||||||
chown nginx:nginx /var/log/nginx/*.log
|
|
||||||
|
|
||||||
VOLUME /www /http-confs /server-confs /modsec-confs /modsec-crs-confs
|
|
||||||
|
|
||||||
EXPOSE 8080/tcp 8443/tcp
|
|
||||||
|
|
||||||
ENTRYPOINT ["/opt/entrypoint.sh"]
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
FROM alpine AS builder
|
|
||||||
|
|
||||||
ENV QEMU_URL https://github.com/balena-io/qemu/releases/download/v4.0.0%2Bbalena2/qemu-4.0.0.balena2-aarch64.tar.gz
|
|
||||||
RUN apk add curl && curl -L ${QEMU_URL} | tar zxvf - -C . --strip-components 1
|
|
||||||
|
|
||||||
FROM arm64v8/nginx:stable-alpine
|
|
||||||
|
|
||||||
COPY --from=builder qemu-aarch64-static /usr/bin
|
|
||||||
|
|
||||||
COPY nginx-keys/ /tmp/nginx-keys
|
|
||||||
COPY compile.sh /tmp/compile.sh
|
|
||||||
RUN chmod +x /tmp/compile.sh && \
|
|
||||||
/tmp/compile.sh && \
|
|
||||||
rm -rf /tmp/*
|
|
||||||
|
|
||||||
COPY entrypoint.sh /opt/entrypoint.sh
|
|
||||||
COPY confs/ /opt/confs
|
|
||||||
COPY scripts/ /opt/scripts
|
|
||||||
COPY fail2ban/ /opt/fail2ban
|
|
||||||
COPY logs/ /opt/logs
|
|
||||||
COPY lua/ /opt/lua
|
|
||||||
|
|
||||||
RUN apk --no-cache add certbot libstdc++ libmaxminddb geoip pcre yajl fail2ban clamav apache2-utils rsyslog openssl lua libgd && \
|
|
||||||
chmod +x /opt/entrypoint.sh /opt/scripts/* && \
|
|
||||||
mkdir /opt/entrypoint.d && \
|
|
||||||
rm -f /var/log/nginx/* && \
|
|
||||||
chown root:nginx /var/log/nginx && \
|
|
||||||
chmod 750 /var/log/nginx && \
|
|
||||||
touch /var/log/nginx/error.log /var/log/nginx/modsec_audit.log && \
|
|
||||||
chown nginx:nginx /var/log/nginx/*.log
|
|
||||||
|
|
||||||
VOLUME /www /http-confs /server-confs /modsec-confs /modsec-crs-confs
|
|
||||||
|
|
||||||
EXPOSE 8080/tcp 8443/tcp
|
|
||||||
|
|
||||||
ENTRYPOINT ["/opt/entrypoint.sh"]
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
FROM i386/nginx:stable-alpine
|
|
||||||
|
|
||||||
COPY nginx-keys/ /tmp/nginx-keys
|
|
||||||
COPY compile.sh /tmp/compile.sh
|
|
||||||
RUN chmod +x /tmp/compile.sh && \
|
|
||||||
/tmp/compile.sh && \
|
|
||||||
rm -rf /tmp/*
|
|
||||||
|
|
||||||
COPY entrypoint.sh /opt/entrypoint.sh
|
|
||||||
COPY confs/ /opt/confs
|
|
||||||
COPY scripts/ /opt/scripts
|
|
||||||
COPY fail2ban/ /opt/fail2ban
|
|
||||||
COPY logs/ /opt/logs
|
|
||||||
COPY lua/ /opt/lua
|
|
||||||
|
|
||||||
RUN apk --no-cache add certbot libstdc++ libmaxminddb geoip pcre yajl fail2ban clamav apache2-utils rsyslog openssl lua libgd && \
|
|
||||||
chmod +x /opt/entrypoint.sh /opt/scripts/* && \
|
|
||||||
mkdir /opt/entrypoint.d && \
|
|
||||||
rm -f /var/log/nginx/* && \
|
|
||||||
chown root:nginx /var/log/nginx && \
|
|
||||||
chmod 750 /var/log/nginx && \
|
|
||||||
touch /var/log/nginx/error.log /var/log/nginx/modsec_audit.log && \
|
|
||||||
chown nginx:nginx /var/log/nginx/*.log
|
|
||||||
|
|
||||||
VOLUME /www /http-confs /server-confs /modsec-confs /modsec-crs-confs
|
|
||||||
|
|
||||||
EXPOSE 8080/tcp 8443/tcp
|
|
||||||
|
|
||||||
ENTRYPOINT ["/opt/entrypoint.sh"]
|
|
||||||
660
LICENSE.md
Normal file
660
LICENSE.md
Normal file
@@ -0,0 +1,660 @@
|
|||||||
|
### GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
|
||||||
|
Version 3, 19 November 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||||
|
<https://fsf.org/>
|
||||||
|
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies of this
|
||||||
|
license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
### Preamble
|
||||||
|
|
||||||
|
The GNU Affero General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works, specifically designed to ensure
|
||||||
|
cooperation with the community in the case of network server software.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
our General Public Licenses are intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains
|
||||||
|
free software for all its users.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
Developers that use our General Public Licenses protect your rights
|
||||||
|
with two steps: (1) assert copyright on the software, and (2) offer
|
||||||
|
you this License which gives you legal permission to copy, distribute
|
||||||
|
and/or modify the software.
|
||||||
|
|
||||||
|
A secondary benefit of defending all users' freedom is that
|
||||||
|
improvements made in alternate versions of the program, if they
|
||||||
|
receive widespread use, become available for other developers to
|
||||||
|
incorporate. Many developers of free software are heartened and
|
||||||
|
encouraged by the resulting cooperation. However, in the case of
|
||||||
|
software used on network servers, this result may fail to come about.
|
||||||
|
The GNU General Public License permits making a modified version and
|
||||||
|
letting the public access it on a server without ever releasing its
|
||||||
|
source code to the public.
|
||||||
|
|
||||||
|
The GNU Affero General Public License is designed specifically to
|
||||||
|
ensure that, in such cases, the modified source code becomes available
|
||||||
|
to the community. It requires the operator of a network server to
|
||||||
|
provide the source code of the modified version running there to the
|
||||||
|
users of that server. Therefore, public use of a modified version, on
|
||||||
|
a publicly accessible server, gives the public access to the source
|
||||||
|
code of the modified version.
|
||||||
|
|
||||||
|
An older license, called the Affero General Public License and
|
||||||
|
published by Affero, was designed to accomplish similar goals. This is
|
||||||
|
a different license, not a version of the Affero GPL, but Affero has
|
||||||
|
released a new version of the Affero GPL which permits relicensing
|
||||||
|
under this license.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
### TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
#### 0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU Affero General Public
|
||||||
|
License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds
|
||||||
|
of works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of
|
||||||
|
an exact copy. The resulting work is called a "modified version" of
|
||||||
|
the earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user
|
||||||
|
through a computer network, with no transfer of a copy, is not
|
||||||
|
conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices" to
|
||||||
|
the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
#### 1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work for
|
||||||
|
making modifications to it. "Object code" means any non-source form of
|
||||||
|
a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users can
|
||||||
|
regenerate automatically from other parts of the Corresponding Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that same
|
||||||
|
work.
|
||||||
|
|
||||||
|
#### 2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not convey,
|
||||||
|
without conditions so long as your license otherwise remains in force.
|
||||||
|
You may convey covered works to others for the sole purpose of having
|
||||||
|
them make modifications exclusively for you, or provide you with
|
||||||
|
facilities for running those works, provided that you comply with the
|
||||||
|
terms of this License in conveying all material for which you do not
|
||||||
|
control copyright. Those thus making or running the covered works for
|
||||||
|
you must do so exclusively on your behalf, under your direction and
|
||||||
|
control, on terms that prohibit them from making any copies of your
|
||||||
|
copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under the
|
||||||
|
conditions stated below. Sublicensing is not allowed; section 10 makes
|
||||||
|
it unnecessary.
|
||||||
|
|
||||||
|
#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such
|
||||||
|
circumvention is effected by exercising rights under this License with
|
||||||
|
respect to the covered work, and you disclaim any intention to limit
|
||||||
|
operation or modification of the work as a means of enforcing, against
|
||||||
|
the work's users, your or third parties' legal rights to forbid
|
||||||
|
circumvention of technological measures.
|
||||||
|
|
||||||
|
#### 4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
#### 5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these
|
||||||
|
conditions:
|
||||||
|
|
||||||
|
- a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
- b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under
|
||||||
|
section 7. This requirement modifies the requirement in section 4
|
||||||
|
to "keep intact all notices".
|
||||||
|
- c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
- d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
#### 6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms of
|
||||||
|
sections 4 and 5, provided that you also convey the machine-readable
|
||||||
|
Corresponding Source under the terms of this License, in one of these
|
||||||
|
ways:
|
||||||
|
|
||||||
|
- a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
- b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the Corresponding
|
||||||
|
Source from a network server at no charge.
|
||||||
|
- c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
- d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
- e) Convey the object code using peer-to-peer transmission,
|
||||||
|
provided you inform other peers where the object code and
|
||||||
|
Corresponding Source of the work are being offered to the general
|
||||||
|
public at no charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal,
|
||||||
|
family, or household purposes, or (2) anything designed or sold for
|
||||||
|
incorporation into a dwelling. In determining whether a product is a
|
||||||
|
consumer product, doubtful cases shall be resolved in favor of
|
||||||
|
coverage. For a particular product received by a particular user,
|
||||||
|
"normally used" refers to a typical or common use of that class of
|
||||||
|
product, regardless of the status of the particular user or of the way
|
||||||
|
in which the particular user actually uses, or expects or is expected
|
||||||
|
to use, the product. A product is a consumer product regardless of
|
||||||
|
whether the product has substantial commercial, industrial or
|
||||||
|
non-consumer uses, unless such uses represent the only significant
|
||||||
|
mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to
|
||||||
|
install and execute modified versions of a covered work in that User
|
||||||
|
Product from a modified version of its Corresponding Source. The
|
||||||
|
information must suffice to ensure that the continued functioning of
|
||||||
|
the modified object code is in no case prevented or interfered with
|
||||||
|
solely because modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or
|
||||||
|
updates for a work that has been modified or installed by the
|
||||||
|
recipient, or for the User Product in which it has been modified or
|
||||||
|
installed. Access to a network may be denied when the modification
|
||||||
|
itself materially and adversely affects the operation of the network
|
||||||
|
or violates the rules and protocols for communication across the
|
||||||
|
network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
#### 7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders
|
||||||
|
of that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
- a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
- b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
- c) Prohibiting misrepresentation of the origin of that material,
|
||||||
|
or requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
- d) Limiting the use for publicity purposes of names of licensors
|
||||||
|
or authors of the material; or
|
||||||
|
- e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
- f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions
|
||||||
|
of it) with contractual assumptions of liability to the recipient,
|
||||||
|
for any liability that these contractual assumptions directly
|
||||||
|
impose on those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions; the
|
||||||
|
above requirements apply either way.
|
||||||
|
|
||||||
|
#### 8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your license
|
||||||
|
from a particular copyright holder is reinstated (a) provisionally,
|
||||||
|
unless and until the copyright holder explicitly and finally
|
||||||
|
terminates your license, and (b) permanently, if the copyright holder
|
||||||
|
fails to notify you of the violation by some reasonable means prior to
|
||||||
|
60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
#### 9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or run
|
||||||
|
a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
#### 10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
#### 11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims owned
|
||||||
|
or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within the
|
||||||
|
scope of its coverage, prohibits the exercise of, or is conditioned on
|
||||||
|
the non-exercise of one or more of the rights that are specifically
|
||||||
|
granted under this License. You may not convey a covered work if you
|
||||||
|
are a party to an arrangement with a third party that is in the
|
||||||
|
business of distributing software, under which you make payment to the
|
||||||
|
third party based on the extent of your activity of conveying the
|
||||||
|
work, and under which the third party grants, to any of the parties
|
||||||
|
who would receive the covered work from you, a discriminatory patent
|
||||||
|
license (a) in connection with copies of the covered work conveyed by
|
||||||
|
you (or copies made from those copies), or (b) primarily for and in
|
||||||
|
connection with specific products or compilations that contain the
|
||||||
|
covered work, unless you entered into that arrangement, or that patent
|
||||||
|
license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
#### 12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under
|
||||||
|
this License and any other pertinent obligations, then as a
|
||||||
|
consequence you may not convey it at all. For example, if you agree to
|
||||||
|
terms that obligate you to collect a royalty for further conveying
|
||||||
|
from those to whom you convey the Program, the only way you could
|
||||||
|
satisfy both those terms and this License would be to refrain entirely
|
||||||
|
from conveying the Program.
|
||||||
|
|
||||||
|
#### 13. Remote Network Interaction; Use with the GNU General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, if you modify the
|
||||||
|
Program, your modified version must prominently offer all users
|
||||||
|
interacting with it remotely through a computer network (if your
|
||||||
|
version supports such interaction) an opportunity to receive the
|
||||||
|
Corresponding Source of your version by providing access to the
|
||||||
|
Corresponding Source from a network server at no charge, through some
|
||||||
|
standard or customary means of facilitating copying of software. This
|
||||||
|
Corresponding Source shall include the Corresponding Source for any
|
||||||
|
work covered by version 3 of the GNU General Public License that is
|
||||||
|
incorporated pursuant to the following paragraph.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the work with which it is combined will remain governed by version
|
||||||
|
3 of the GNU General Public License.
|
||||||
|
|
||||||
|
#### 14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the GNU Affero General Public License from time to time. Such new
|
||||||
|
versions will be similar in spirit to the present version, but may
|
||||||
|
differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program
|
||||||
|
specifies that a certain numbered version of the GNU Affero General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU Affero General Public License, you may choose any version ever
|
||||||
|
published by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future versions
|
||||||
|
of the GNU Affero General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
#### 15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
|
||||||
|
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
||||||
|
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
||||||
|
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
|
||||||
|
CORRECTION.
|
||||||
|
|
||||||
|
#### 16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
|
||||||
|
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
||||||
|
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
|
||||||
|
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
|
||||||
|
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
|
||||||
|
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
|
||||||
|
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
#### 17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
### How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these
|
||||||
|
terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest to
|
||||||
|
attach them to the start of each source file to most effectively state
|
||||||
|
the exclusion of warranty; and each file should have at least the
|
||||||
|
"copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper
|
||||||
|
mail.
|
||||||
|
|
||||||
|
If your software can interact with users remotely through a computer
|
||||||
|
network, you should also make sure that it provides a way for users to
|
||||||
|
get its source. For example, if your program is a web application, its
|
||||||
|
interface could display a "Source" link that leads users to an archive
|
||||||
|
of the code. There are many ways you could offer source, and different
|
||||||
|
solutions will be better for different programs; see section 13 for
|
||||||
|
the specific requirements.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||||
|
necessary. For more information on this, and how to apply and follow
|
||||||
|
the GNU AGPL, see <https://www.gnu.org/licenses/>.
|
||||||
811
README.md
811
README.md
@@ -1,685 +1,222 @@
|
|||||||
# bunkerized-nginx
|
<p align="center">
|
||||||
|
<img src="https://github.com/bunkerity/bunkerized-nginx/blob/master/docs/img/logo.png?raw=true" width="425" />
|
||||||
|
</p>
|
||||||
|
|
||||||
<img src="https://github.com/bunkerity/bunkerized-nginx/blob/master/logo.png?raw=true" width="425" />
|
<p align="center">
|
||||||
|
<img src="https://img.shields.io/badge/bunkerized--nginx-1.3.1-blue" />
|
||||||
|
<img src="https://img.shields.io/badge/nginx-1.20.1-blue" />
|
||||||
|
<img src="https://img.shields.io/github/last-commit/bunkerity/bunkerized-nginx" />
|
||||||
|
<img src="https://img.shields.io/github/workflow/status/bunkerity/bunkerized-nginx/Automatic%20test?label=automatic%20test" />
|
||||||
|
<img src="https://img.shields.io/github/workflow/status/bunkerity/bunkerized-nginx/Build%20and%20push%20bunkerized-nginx?label=docker%20build" />
|
||||||
|
<img src="https://img.shields.io/readthedocs/bunkerized-nginx" />
|
||||||
|
</p>
|
||||||
|
|
||||||
<img src="https://img.shields.io/badge/nginx-1.18.0-blue" /> <img src="https://img.shields.io/docker/cloud/build/bunkerity/bunkerized-nginx" /> <img src="https://img.shields.io/github/last-commit/bunkerity/bunkerized-nginx" />
|
<p align="center">
|
||||||
|
<strong>
|
||||||
|
<a href="https://bunkerized-nginx.readthedocs.io">Documentation</a>
|
||||||
|
|
|
||||||
|
<a href="https://github.com/bunkerity/bunkerized-nginx/tree/master/examples">Examples</a>
|
||||||
|
|
|
||||||
|
<a href="https://www.bunkerity.com/category/bunkerized-nginx/">Blog posts</a>
|
||||||
|
|
|
||||||
|
<a href="https://coso.me/bunkerity-chat">Community chat</a>
|
||||||
|
|
|
||||||
|
<a href="https://coso.me/bunkerity">Follow us</a>
|
||||||
|
</strong>
|
||||||
|
</p>
|
||||||
|
|
||||||
nginx Docker image secure by default.
|
> Make security by default great again !
|
||||||
|
|
||||||
Avoid the hassle of following security best practices each time you need a web server or reverse proxy. Bunkerized-nginx provides generic security configs, settings and tools so you don't need to do it yourself.
|
bunkerized-nginx is a web server based on the notorious nginx and focused on security. It integrates into existing environments (Linux, Docker, Swarm, Kubernetes, ...) to make your web services "secure by default" without any hassle. The security best practices are automatically applied for you while keeping control of every settings to meet your own use case.
|
||||||
|
|
||||||
|
<img src="https://github.com/bunkerity/bunkerized-nginx/blob/master/docs/img/overview.png?raw=true" />
|
||||||
|
|
||||||
Non-exhaustive list of features :
|
Non-exhaustive list of features :
|
||||||
- HTTPS support with transparent Let's Encrypt automation
|
- HTTPS support with transparent Let's Encrypt automation
|
||||||
- State-of-the-art web security : HTTP security headers, php.ini hardening, prevent leaks, ...
|
- State-of-the-art web security : HTTP security headers, prevent leaks, TLS hardening, ...
|
||||||
- Integrated ModSecurity WAF with the OWASP Core Rule Set
|
- Integrated ModSecurity WAF with the OWASP Core Rule Set
|
||||||
- Automatic ban of strange behaviors with fail2ban
|
- Automatic ban of strange behaviors
|
||||||
- Antibot challenge through cookie, javascript, captcha or recaptcha v3
|
- Antibot challenge through cookie, javascript, captcha or recaptcha v3
|
||||||
- Block TOR, proxies, bad user-agents, countries, ...
|
- Block TOR, proxies, bad user-agents, countries, ...
|
||||||
- Perform automatic DNSBL checks to block known bad IP
|
- Block known bad IP with DNSBL
|
||||||
- Prevent bruteforce attacks with rate limiting
|
- Prevent bruteforce attacks with rate limiting
|
||||||
- Detect bad files with ClamAV
|
- Plugins system for external security checks (ClamAV, CrowdSec, ...)
|
||||||
- Easy to configure with environment variables
|
- Easy to configure with environment variables or web UI
|
||||||
|
- Seamless integration into existing environments : Linux, Docker, Swarm, Kubernetes, ...
|
||||||
|
|
||||||
Fooling automated tools/scanners :
|
Fooling automated tools/scanners :
|
||||||
|
|
||||||
<img src="https://github.com/bunkerity/bunkerized-nginx/blob/master/demo.gif?raw=true" />
|
<img src="https://github.com/bunkerity/bunkerized-nginx/blob/master/docs/img/demo.gif?raw=true" />
|
||||||
|
|
||||||
|
You can find a live demo at [https://demo-nginx.bunkerity.com](https://demo-nginx.bunkerity.com), feel free to do some security tests.
|
||||||
|
|
||||||
# Table of contents
|
# Table of contents
|
||||||
- [bunkerized-nginx](#bunkerized-nginx)
|
<details>
|
||||||
|
<summary>Click to show</summary>
|
||||||
|
|
||||||
- [Table of contents](#table-of-contents)
|
- [Table of contents](#table-of-contents)
|
||||||
- [Live demo](#live-demo)
|
- [Integrations](#integrations)
|
||||||
- [Quickstart guide](#quickstart-guide)
|
* [Docker](#docker)
|
||||||
* [Run HTTP server with default settings](#run-http-server-with-default-settings)
|
* [Docker autoconf](#docker-autoconf)
|
||||||
* [In combination with PHP](#in-combination-with-php)
|
* [Swarm](#swarm)
|
||||||
* [Run HTTPS server with automated Let's Encrypt](#run-https-server-with-automated-lets-encrypt)
|
* [Kubernetes](#kubernetes)
|
||||||
* [Behind a reverse proxy](#behind-a-reverse-proxy)
|
* [Linux](#linux)
|
||||||
* [As a reverse proxy](#as-a-reverse-proxy)
|
- [Configuration](#configuration)
|
||||||
* [Antibot challenge](#antibot-challenge)
|
* [Singlesite](#singlesite)
|
||||||
- [Tutorials and examples](#tutorials-and-examples)
|
* [Multisite](#multisite)
|
||||||
- [List of environment variables](#list-of-environment-variables)
|
* [Special folders](#special-folders)
|
||||||
* [nginx](#nginx)
|
- [Web UI](#web-ui)
|
||||||
+ [Misc](#misc)
|
- [Security tuning](#security-tuning)
|
||||||
+ [Information leak](#information-leak)
|
- [Going further](#going-further)
|
||||||
+ [Custom error pages](#custom-error-pages)
|
- [License](#license)
|
||||||
+ [HTTP basic authentication](#http-basic-authentication)
|
- [Contributing](#contributing)
|
||||||
+ [Reverse proxy](#reverse-proxy)
|
- [Security policy](#security-policy)
|
||||||
* [HTTPS](#https)
|
</details>
|
||||||
+ [Let's Encrypt](#let-s-encrypt)
|
|
||||||
+ [HTTP](#http)
|
|
||||||
+ [Custom certificate](#custom-certificate)
|
|
||||||
+ [Self-signed certificate](#self-signed-certificate)
|
|
||||||
+ [Misc](#misc)
|
|
||||||
* [ModSecurity](#modsecurity)
|
|
||||||
* [Security headers](#security-headers)
|
|
||||||
* [Blocking](#blocking)
|
|
||||||
+ [Antibot](#antibot)
|
|
||||||
+ [External blacklist](#external-blacklist)
|
|
||||||
+ [DNSBL](#dnsbl)
|
|
||||||
+ [Custom whitelisting](#custom-whitelisting)
|
|
||||||
+ [Custom blacklisting](#custom-blacklisting)
|
|
||||||
+ [Requests limiting](#requests-limiting)
|
|
||||||
+ [Countries](#countries)
|
|
||||||
* [PHP](#php)
|
|
||||||
* [Fail2ban](#fail2ban)
|
|
||||||
* [ClamAV](#clamav)
|
|
||||||
* [Misc](#misc-2)
|
|
||||||
- [Create your own image](#create-your-own-image)
|
|
||||||
- [Include custom configurations](#include-custom-configurations)
|
|
||||||
|
|
||||||
# Live demo
|
# Integrations
|
||||||
You can find a live demo at https://demo-nginx.bunkerity.com.
|
|
||||||
|
|
||||||
# Quickstart guide
|
## Docker
|
||||||
|
|
||||||
## Run HTTP server with default settings
|
|
||||||
|
|
||||||
|
You can get official prebuilt Docker images of bunkerized-nginx for x86, x64, armv7 and aarch64/arm64 architectures on Docker Hub :
|
||||||
```shell
|
```shell
|
||||||
docker run -p 80:8080 -v /path/to/web/files:/www bunkerity/bunkerized-nginx
|
$ docker pull bunkerity/bunkerized-nginx
|
||||||
```
|
```
|
||||||
|
|
||||||
Web files are stored in the /www directory, the container will serve files from there.
|
Or you can build it from source if you wish :
|
||||||
|
|
||||||
## In combination with PHP
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker network create mynet
|
$ git clone https://github.com/bunkerity/bunkerized-nginx.git
|
||||||
docker run --network mynet -p 80:8080 -v /path/to/web/files:/www -e REMOTE_PHP=myphp -e REMOTE_PHP_PATH=/app bunkerity/bunkerized-nginx
|
$ cd bunkerized-nginx
|
||||||
docker run --network mynet --name=myphp -v /path/to/web/files:/app php:fpm
|
$ docker build -t bunkerized-nginx .
|
||||||
```
|
```
|
||||||
|
|
||||||
The `REMOTE_PHP` environment variable lets you define the address of a remote PHP-FPM instance that will execute the .php files. `REMOTE_PHP_PATH` must be set to the directory where the PHP container will find the files.
|
To use bunkerized-nginx as a Docker container you have to pass specific environment variables, mount volumes and redirect ports to make it accessible from the outside.
|
||||||
|
|
||||||
## Run HTTPS server with automated Let's Encrypt
|
<img src="https://github.com/bunkerity/bunkerized-nginx/blob/master/docs/img/docker.png?raw=true" />
|
||||||
```shell
|
|
||||||
docker run -p 80:8080 -p 443:8443 -v /path/to/web/files:/www -v /where/to/save/certificates:/etc/letsencrypt -e SERVER_NAME=www.yourdomain.com -e AUTO_LETS_ENCRYPT=yes -e REDIRECT_HTTP_TO_HTTPS=yes bunkerity/bunkerized-nginx
|
You will find more information about Docker integration in the [documentation](https://bunkerized-nginx.readthedocs.io/en/latest/integrations.html#docker).
|
||||||
|
|
||||||
|
## Docker autoconf
|
||||||
|
|
||||||
|
The downside of using environment variables is that the container needs to be recreated each time there is an update which is not very convenient. To counter that issue, you can use another image called bunkerized-nginx-autoconf which will listen for Docker events and automatically configure bunkerized-nginx instance in real time without recreating the container. Instead of defining environment variables for the bunkerized-nginx container, you simply add labels to your web services and bunkerized-nginx-autoconf will "automagically" take care of the rest.
|
||||||
|
|
||||||
|
<img src="https://github.com/bunkerity/bunkerized-nginx/blob/master/docs/img/autoconf-docker.png?raw=true" />
|
||||||
|
|
||||||
|
You will find more information about Docker autoconf feature in the [documentation](https://bunkerized-nginx.readthedocs.io/en/latest/integrations.html#docker-autoconf).
|
||||||
|
|
||||||
|
## Swarm
|
||||||
|
|
||||||
|
Using bunkerized-nginx in a Docker Swarm cluster requires a shared folder accessible from both managers and workers (anything like NFS, GlusterFS, CephFS or even SSHFS will work). The deployment and configuration is very similar to the "Docker autoconf" one but with services instead of containers. A service based on the bunkerized-nginx-autoconf image needs to be scheduled on a manager node (don't worry it doesn't expose any network port for obvious security reasons). This service will listen for Docker Swarm events like service creation or deletion and generate the configuration according to the labels of each service. Once configuration generation is done, the bunkerized-nginx-autoconf service will send a reload order to all the bunkerized-nginx tasks so they can load the new configuration.
|
||||||
|
|
||||||
|
<img src="https://github.com/bunkerity/bunkerized-nginx/blob/master/docs/img/swarm.png?raw=true" />
|
||||||
|
|
||||||
|
You will find more information about Docker Swarm integration in the [documentation](https://bunkerized-nginx.readthedocs.io/en/latest/integrations.html#docker-swarm).
|
||||||
|
|
||||||
|
## Kubernetes
|
||||||
|
|
||||||
|
**This integration is still in beta, please fill an issue if you find a bug or have an idea on how to improve it.**
|
||||||
|
|
||||||
|
Using bunkerized-nginx in a Kubernetes cluster requires a shared folder accessible from the nodes (anything like NFS, GlusterFS, CephFS or even SSHFS will work). The bunkerized-nginx-autoconf acts as an Ingress Controller and connects to the k8s API to get cluster events and generate a new configuration when it's needed. Once the configuration is generated, the Ingress Controller sends a reload order to the bunkerized-nginx instances running in the cluster.
|
||||||
|
|
||||||
|
<img src="https://github.com/bunkerity/bunkerized-nginx/blob/master/docs/img/kubernetes.png?raw=true" />
|
||||||
|
|
||||||
|
You will find more information about Kubernetes integration in the [documentation](https://bunkerized-nginx.readthedocs.io/en/latest/integrations.html#kubernetes).
|
||||||
|
|
||||||
|
## Linux
|
||||||
|
|
||||||
|
**This integration is still in beta, please fill an issue if you find a bug or have an idea on how to improve it.**
|
||||||
|
|
||||||
|
List of supported Linux distributions :
|
||||||
|
- Debian buster (10)
|
||||||
|
- Ubuntu focal (20.04)
|
||||||
|
- CentOS 7
|
||||||
|
- Fedora 34
|
||||||
|
|
||||||
|
Unlike containers, Linux integration can be tedious because bunkerized-nginx has a bunch of dependencies that need to be installed before we can use it. Fortunately, we provide a [helper script](https://github.com/bunkerity/bunkerized-nginx/blob/master/helpers/install.sh) to make the process easier and automatic. Once installed, the configuration is really simple, all you have to do is to edit the `/opt/bunkerized-nginx/variables.env` configuration file and run the `bunkerized-nginx` command to apply it.
|
||||||
|
|
||||||
|
You will find more information about Linux integration in the [documentation](https://bunkerized-nginx.readthedocs.io/en/latest/integrations.html#linux).
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
|
||||||
|
The configuration is made through what we call "environment variables" as a form of key/value pairs. You will find the [quickstart guide](https://bunkerized-nginx.readthedocs.io/en/latest/quickstart_guide.html) and the complete [list of environment variables](https://bunkerized-nginx.readthedocs.io/en/latest/environment_variables.html) in the documentation.
|
||||||
|
|
||||||
|
## Singlesite
|
||||||
|
|
||||||
|
By default, bunkerized-nginx will only create one server block in the nginx configuration. This cover the simplest use-case where you want to protect one service easily and quickly.
|
||||||
|
|
||||||
|
Here is a dummy configuration as an example :
|
||||||
|
```conf
|
||||||
|
SERVER_NAME=example.com www.example.com
|
||||||
|
AUTO_LETS_ENCRYPT=yes
|
||||||
|
DISABLE_DEFAULT_SERVER=yes
|
||||||
|
USE_REVERSE_PROXY=yes
|
||||||
|
REVERSE_PROXY_URL=/
|
||||||
|
REVERSE_PROXY_HOST=http://internal-service.example.local:8080
|
||||||
|
# Uncomment the HTTP_PORT and HTTPS_PORTS variables when using Linux configuration
|
||||||
|
#HTTP_PORT=80
|
||||||
|
#HTTPS_PORT=443
|
||||||
```
|
```
|
||||||
|
|
||||||
Certificates are stored in the /etc/letsencrypt directory, you should save it on your local drive.
|
## Multisite
|
||||||
If you don't want your webserver to listen on HTTP add the environment variable `LISTEN_HTTP` with a *no* value. But Let's Encrypt needs the port 80 to be opened so redirecting the port is mandatory.
|
|
||||||
|
|
||||||
Here you have three environment variables :
|
If you have multiple services to protect, the easiest way to do it is by enabling the "multisite" mode. When using multisite, bunkerized-nginx will create one server block per server defined in the `SERVER_NAME` environment variable. You can configure each servers independently by adding the server name as a prefix.
|
||||||
- `SERVER_NAME` : define the FQDN of your webserver, this is mandatory for Let's Encrypt (www.yourdomain.com should point to your IP address)
|
|
||||||
- `AUTO_LETS_ENCRYPT` : enable automatic Let's Encrypt creation and renewal of certificates
|
|
||||||
- `REDIRECT_HTTP_TO_HTTPS` : enable HTTP to HTTPS redirection
|
|
||||||
|
|
||||||
## Behind a reverse proxy
|
Here is a dummy configuration as an example :
|
||||||
```shell
|
```conf
|
||||||
docker run -p 80:8080 -v /path/to/web/files:/www -e PROXY_REAL_IP=yes bunkerity/bunkerized-nginx
|
SERVER_NAME=app1.example.com app2.example.com
|
||||||
|
# Without prefix the variables are applied globally but can still be overriden
|
||||||
|
AUTO_LETS_ENCRYPT=yes
|
||||||
|
DISABLE_DEFAULT_SERVER=yes
|
||||||
|
# Specific configurations for first service
|
||||||
|
app1.example.com_USE_REVERSE_PROXY=yes
|
||||||
|
app1.example.com_REVERSE_PROXY_URL=/
|
||||||
|
app1.example.com_REVERSE_PROXY_HOST=http://internal-service.example.local:8080
|
||||||
|
# Specific configuration for second service
|
||||||
|
app2.example.com_REMOTE_PHP=my-fpm
|
||||||
|
app2.example.com_REMOTE_PHP_PATH=/var/www/html
|
||||||
|
# Uncomment the HTTP_PORT and HTTPS_PORTS variables when using Linux configuration
|
||||||
|
#HTTP_PORT=80
|
||||||
|
#HTTPS_PORT=443
|
||||||
```
|
```
|
||||||
|
|
||||||
The `PROXY_REAL_IP` environment variable, when set to *yes*, activates the [ngx_http_realip_module](https://nginx.org/en/docs/http/ngx_http_realip_module.html) to get the real client IP from the reverse proxy.
|
## Special folders
|
||||||
|
|
||||||
See [this section](#reverse-proxy) if you need to tweak some values (trusted ip/network, header, ...).
|
| Name | Location | Purpose | Multisite |
|
||||||
|
|:----------------:|:--------------------------------------------------------------------------------:|:-----------------------------------------------------------------------:|:---------:|
|
||||||
|
| www | /www (container)<br> /opt/bunkerized-nginx/www (Linux) | Static files that need to be delivered by bunkerized-nginx. | Yes |
|
||||||
|
| http-confs | /http-confs (container)<br> /opt/bunkerized-nginx/http-confs (Linux) | Custom nginx configuration files loaded at http context. | No |
|
||||||
|
| server-confs | /server-confs (container)<br> /opt/bunkerized-nginx/server-confs (Linux) | Custom nginx configuration files loaded at server context. | Yes |
|
||||||
|
| modsec-confs | /modsec-confs (container)<br> /opt/bunkerized-nginx/modsec-confs (Linux) | Custom ModSecurity configuration files loaded before the Core Rule Set. | Yes |
|
||||||
|
| modsec-crs-confs | /modsec-crs-confs (container)<br> /opt/bunkerized-nginx/modsec-crs-confs (Linux) | Custom ModSecurity configuration files loaded after the Core Rule Set. | Yes |
|
||||||
|
| plugins | /plugins (container)<br> /opt/bunkerized-nginx/plugins (Linux) | Location of bunkerized-nginx plugins. | No |
|
||||||
|
| cache | /cache (container)<br> /opt/bunkerized-nginx/plugins (Linux) | Placeholder for caching data like external blacklists. | No |
|
||||||
|
| acme-challenge | /acme-challenge (container)<br> /opt/bunkerized-nginx/acme-challenge (Linux) | Placeholder for Let's Encrypt challenges. | No |
|
||||||
|
|
||||||
## As a reverse proxy
|
You will find more information about the special folders in the [documentation](https://bunkerized-nginx.readthedocs.io/en/latest/special_folders.html).
|
||||||
You can setup a reverse proxy by adding your own custom configurations at server context.
|
|
||||||
For example, this is a dummy reverse proxy configuration :
|
|
||||||
```shell
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
location / {
|
|
||||||
if ($host = www.website1.com) {
|
|
||||||
proxy_pass http://192.168.42.10$request_uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($host = www.website2.com) {
|
# Web UI
|
||||||
proxy_pass http://192.168.42.11$request_uri;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
All files (ending with .conf) in /server-confs inside the container will be included at server context. You can simply mount a volume where your config files are located :
|
|
||||||
```shell
|
|
||||||
docker run -p 80:8080 -e SERVER_NAME="www.website1.com www.website2.com" -e SERVE_FILES=no -e DISABLE_DEFAULT_SERVER=yes -v /path/to/server/conf:/server-confs bunkerity/bunkerized-nginx
|
|
||||||
```
|
|
||||||
|
|
||||||
Here you have three environment variables :
|
<img src="https://github.com/bunkerity/bunkerized-nginx/blob/master/docs/img/web-ui.gif?raw=true" />
|
||||||
- `SERVER_NAME` : list of valid Host headers sent by clients
|
|
||||||
- `SERVE_FILES` : nginx will not serve files from the /www directory
|
|
||||||
- `DISABLE_DEFAULT_SERVER` : nginx will not respond to requests if Host header is not in the SERVER_NAME list
|
|
||||||
|
|
||||||
## Antibot challenge
|
You will find more information about the web UI in the [documentation](https://bunkerized-nginx.readthedocs.io/en/latest/web_ui.html).
|
||||||
```shell
|
|
||||||
docker run -p 80:8080 -v /path/to/web/files:/www -e USE_ANTIBOT=captcha bunkerity/bunkerized-nginx
|
|
||||||
```
|
|
||||||
|
|
||||||
When `USE_ANTIBOT` is set to *captcha*, every users visiting your website must complete a captcha before accessing the pages. Others challenges are also available : *cookie*, *javascript* or *recaptcha* (more info [here](#antibot)).
|
# Security tuning
|
||||||
|
|
||||||
# Tutorials and examples
|
bunkerized-nginx comes with a set of predefined security settings that you can (and you should) tune to meet your own use case. We recommend you to read the [security tuning](https://bunkerized-nginx.readthedocs.io/en/latest/security_tuning.html) section of the documentation.
|
||||||
|
|
||||||
You will find some docker-compose.yml examples in the [examples directory](https://github.com/bunkerity/bunkerized-nginx/tree/master/examples) and tutorials about bunkerized-nginx in our [blog](https://www.bunkerity.com/category/bunkerized-nginx/).
|
# Going further
|
||||||
|
|
||||||
# List of environment variables
|
- [Official documentation](https://bunkerized-nginx.readthedocs.io/)
|
||||||
|
- [Full concrete examples](https://github.com/bunkerity/bunkerized-nginx/tree/master/examples)
|
||||||
|
- [Tutorials in our blog](https://www.bunkerity.com/blog)
|
||||||
|
|
||||||
## nginx
|
# License
|
||||||
|
|
||||||
### Misc
|
This project is licensed under the terms of the [GNU Affero General Public License (AGPL) version 3](https://github.com/bunkerity/bunkerized-nginx/blob/master/LICENSE.md).
|
||||||
|
|
||||||
`SERVER_NAME`
|
# Contributing
|
||||||
Values : *<first name> <second name> ...*
|
|
||||||
Default value : *www.bunkerity.com*
|
|
||||||
Sets the host names of the webserver separated with spaces. This must match the Host header sent by clients.
|
|
||||||
Useful when used with `AUTO_LETSENCRYPT=yes` and/or `DISABLE_DEFAULT_SERVER=yes`.
|
|
||||||
|
|
||||||
`MAX_CLIENT_SIZE`
|
If you would like to contribute to the project you can read the [contributing guidelines](https://github.com/bunkerity/bunkerized-nginx/blob/master/CONTRIBUTING.md) to get started.
|
||||||
Values : *0* | *Xm*
|
|
||||||
Default value : *10m*
|
|
||||||
Sets the maximum body size before nginx returns a 413 error code.
|
|
||||||
Setting to 0 means "infinite" body size.
|
|
||||||
|
|
||||||
`ALLOWED_METHODS`
|
# Security policy
|
||||||
Values : *allowed HTTP methods separated with | char*
|
|
||||||
Default value : *GET|POST|HEAD*
|
|
||||||
Only the HTTP methods listed here will be accepted by nginx. If not listed, nginx will close the connection.
|
|
||||||
|
|
||||||
`DISABLE_DEFAULT_SERVER`
|
We take security bugs as serious issues and encourage responsible disclosure, see our [security policy](https://github.com/bunkerity/bunkerized-nginx/blob/master/SECURITY.md) for more information.
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *no*
|
|
||||||
If set to yes, nginx will only respond to HTTP request when the Host header match a FQDN specified in the `SERVER_NAME` environment variable.
|
|
||||||
For example, it will close the connection if a bot access the site with direct ip.
|
|
||||||
|
|
||||||
`SERVE_FILES`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *yes*
|
|
||||||
If set to yes, nginx will serve files from /www directory within the container.
|
|
||||||
A use case to not serving files is when you setup bunkerized-nginx as a reverse proxy via a custom configuration.
|
|
||||||
|
|
||||||
`DNS_RESOLVERS`
|
|
||||||
Values : *\<two IP addresses separated with a space\>*
|
|
||||||
Default value : *127.0.0.11 8.8.8.8*
|
|
||||||
The IP addresses of the DNS resolvers to use when performing DNS lookups.
|
|
||||||
|
|
||||||
`WRITE_ACCESS`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *no*
|
|
||||||
If set to yes, nginx will be granted write access to the /www directory.
|
|
||||||
Set it to yes if your website uses file upload or creates dynamic files for example.
|
|
||||||
|
|
||||||
`ROOT_FOLDER`
|
|
||||||
Values : *\<any valid path to web files\>
|
|
||||||
Default value : */www*
|
|
||||||
The default folder where nginx will search for web files. Don't change it unless you want to make your own image.
|
|
||||||
|
|
||||||
### Information leak
|
|
||||||
|
|
||||||
`SERVER_TOKENS`
|
|
||||||
Values : *on* | *off*
|
|
||||||
Default value : *off*
|
|
||||||
If set to on, nginx will display server version in Server header and default error pages.
|
|
||||||
|
|
||||||
`HEADER_SERVER`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *no*
|
|
||||||
If set to no, nginx will remove the Server header in HTTP responses.
|
|
||||||
|
|
||||||
### Custom error pages
|
|
||||||
|
|
||||||
`ERROR_XXX`
|
|
||||||
Values : *\<relative path to the error page\>*
|
|
||||||
Default value :
|
|
||||||
Use this kind of environment variable to define custom error page depending on the HTTP error code. Replace XXX with HTTP code.
|
|
||||||
For example : `ERROR_404=/404.html` means the /404.html page will be displayed when 404 code is generated. The path is relative to the root web folder.
|
|
||||||
|
|
||||||
### HTTP basic authentication
|
|
||||||
|
|
||||||
`USE_AUTH_BASIC`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *no*
|
|
||||||
If set to yes, enables HTTP basic authentication at the location `AUTH_BASIC_LOCATION` with user `AUTH_BASIC_USER` and password `AUTH_BASIC_PASSWORD`.
|
|
||||||
|
|
||||||
`AUTH_BASIC_LOCATION`
|
|
||||||
Values : *sitewide* | */somedir* | *\<any valid location\>*
|
|
||||||
Default value : *sitewide*
|
|
||||||
The location to restrict when `USE_AUTH_BASIC` is set to *yes*. If the special value *sitewide* is used then auth basic will be set at server level outside any location context.
|
|
||||||
|
|
||||||
`AUTH_BASIC_USER`
|
|
||||||
Values : *\<any valid username\>*
|
|
||||||
Default value : *changeme*
|
|
||||||
The username allowed to access `AUTH_BASIC_LOCATION` when `USE_AUTH_BASIC` is set to yes.
|
|
||||||
|
|
||||||
`AUTH_BASIC_PASSWORD`
|
|
||||||
Values : *\<any valid password\>*
|
|
||||||
Default value : *changeme*
|
|
||||||
The password of `AUTH_BASIC_USER` when `USE_AUTH_BASIC` is set to yes.
|
|
||||||
|
|
||||||
`AUTH_BASIC_TEXT`
|
|
||||||
Values : *\<any valid text\>*
|
|
||||||
Default value : *Restricted area*
|
|
||||||
The text displayed inside the login prompt when `USE_AUTH_BASIC` is set to yes.
|
|
||||||
|
|
||||||
### Reverse proxy
|
|
||||||
|
|
||||||
`PROXY_REAL_IP`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *no*
|
|
||||||
Set this environment variable to *yes* if you're using bunkerized-nginx behind a reverse proxy. This means you will see the real client address instead of the proxy one inside your logs. Modsecurity, fail2ban and others security tools will also then work correctly.
|
|
||||||
|
|
||||||
`PROXY_REAL_IP_FROM`
|
|
||||||
Values : *\<list of trusted IP addresses and/or networks separated with spaces\>*
|
|
||||||
Default value : *192.168.0.0/16 172.16.0.0/12 10.0.0.0/8*
|
|
||||||
When `PROXY_REAL_IP` is set to *yes*, lets you define the trusted IPs/networks allowed to send the correct client address.
|
|
||||||
|
|
||||||
`PROXY_REAL_IP_HEADER`
|
|
||||||
Values : *X-Forwarded-For* | *X-Real-IP* | *custom header*
|
|
||||||
Default value : *X-Forwarded-For*
|
|
||||||
When `PROXY_REAL_IP` is set to *yes*, lets you define the header that contains the real client IP address.
|
|
||||||
|
|
||||||
`PROXY_REAL_IP_RECURSIVE`
|
|
||||||
Values : *on* | *off*
|
|
||||||
Default value : *on*
|
|
||||||
When `PROXY_REAL_IP` is set to *yes*, setting this to *on* avoid spoofing attacks using the header defined in `PROXY_REAL_IP_HEADER`.
|
|
||||||
|
|
||||||
## HTTPS
|
|
||||||
|
|
||||||
### Let's Encrypt
|
|
||||||
|
|
||||||
`AUTO_LETS_ENCRYPT`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *no*
|
|
||||||
If set to yes, automatic certificate generation and renewal will be setup through Let's Encrypt. This will enable HTTPS on your website for free.
|
|
||||||
You will need to redirect both 80 and 443 port to your container and also set the `SERVER_NAME` environment variable.
|
|
||||||
|
|
||||||
### HTTP
|
|
||||||
|
|
||||||
`LISTEN_HTTP`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *yes*
|
|
||||||
If set to no, nginx will not in listen on HTTP (port 80).
|
|
||||||
Useful if you only want HTTPS access to your website.
|
|
||||||
|
|
||||||
`REDIRECT_HTTP_TO_HTTPS`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *no*
|
|
||||||
If set to yes, nginx will redirect all HTTP requests to HTTPS.
|
|
||||||
|
|
||||||
### Custom certificate
|
|
||||||
|
|
||||||
`USE_CUSTOM_HTTPS`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *no*
|
|
||||||
If set to yes, HTTPS will be enabled with certificate/key of your choice.
|
|
||||||
|
|
||||||
`CUSTOM_HTTPS_CERT`
|
|
||||||
Values : *\<any valid path inside the container\>*
|
|
||||||
Default value :
|
|
||||||
Full path of the certificate file to use when `USE_CUSTOM_HTTPS` is set to yes.
|
|
||||||
|
|
||||||
`CUSTOM_HTTPS_KEY`
|
|
||||||
Values : *\<any valid path inside the container\>*
|
|
||||||
Default value :
|
|
||||||
Full path of the key file to use when `USE_CUSTOM_HTTPS` is set to yes.
|
|
||||||
|
|
||||||
### Self-signed certificate
|
|
||||||
|
|
||||||
`GENERATE_SELF_SIGNED_SSL`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *no*
|
|
||||||
If set to yes, HTTPS will be enabled with a container generated self-signed certificate.
|
|
||||||
|
|
||||||
`SELF_SIGNED_SSL_EXPIRY`
|
|
||||||
Values : *integer*
|
|
||||||
Default value : *365* (1 year)
|
|
||||||
Needs `GENERATE_SELF_SIGNED_SSL` to work.
|
|
||||||
Sets the expiry date for the self generated certificate.
|
|
||||||
|
|
||||||
`SELF_SIGNED_SSL_COUNTRY`
|
|
||||||
Values : *text*
|
|
||||||
Default value : *Switzerland*
|
|
||||||
Needs `GENERATE_SELF_SIGNED_SSL` to work.
|
|
||||||
Sets the country for the self generated certificate.
|
|
||||||
|
|
||||||
`SELF_SIGNED_SSL_STATE`
|
|
||||||
Values : *text*
|
|
||||||
Default value : *Switzerland*
|
|
||||||
Needs `GENERATE_SELF_SIGNED_SSL` to work.
|
|
||||||
Sets the state for the self generated certificate.
|
|
||||||
|
|
||||||
`SELF_SIGNED_SSL_CITY`
|
|
||||||
Values : *text*
|
|
||||||
Default value : *Bern*
|
|
||||||
Needs `GENERATE_SELF_SIGNED_SSL` to work.
|
|
||||||
Sets the city for the self generated certificate.
|
|
||||||
|
|
||||||
`SELF_SIGNED_SSL_ORG`
|
|
||||||
Values : *text*
|
|
||||||
Default value : *AcmeInc*
|
|
||||||
Needs `GENERATE_SELF_SIGNED_SSL` to work.
|
|
||||||
Sets the organisation name for the self generated certificate.
|
|
||||||
|
|
||||||
`SELF_SIGNED_SSL_OU`
|
|
||||||
Values : *text*
|
|
||||||
Default value : *IT*
|
|
||||||
Needs `GENERATE_SELF_SIGNED_SSL` to work.
|
|
||||||
Sets the organisitional unit for the self generated certificate.
|
|
||||||
|
|
||||||
`SELF_SIGNED_SSL_CN`
|
|
||||||
Values : *text*
|
|
||||||
Default value : *bunkerity-nginx*
|
|
||||||
Needs `GENERATE_SELF_SIGNED_SSL` to work.
|
|
||||||
Sets the CN server name for the self generated certificate.
|
|
||||||
|
|
||||||
### Misc
|
|
||||||
|
|
||||||
`HTTP2`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *yes*
|
|
||||||
If set to yes, nginx will use HTTP2 protocol when HTTPS is enabled.
|
|
||||||
|
|
||||||
## ModSecurity
|
|
||||||
|
|
||||||
`USE_MODSECURITY`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *yes*
|
|
||||||
If set to yes, the ModSecurity WAF will be enabled.
|
|
||||||
You can include custom rules by adding .conf files into the /modsec-confs/ directory inside the container (i.e : through a volume).
|
|
||||||
|
|
||||||
`USE_MODSECURITY_CRS`
|
|
||||||
Values: *yes* | *no*
|
|
||||||
Default value : *yes*
|
|
||||||
If set to yes, the [OWASP ModSecurity Core Rule Set](https://coreruleset.org/) will be used. It provides generic rules to detect common web attacks.
|
|
||||||
You can customize the CRS (i.e. : add WordPress exclusions) by adding custom .conf files into the /modsec-crs-confs/ directory inside the container (i.e : through a volume). Files inside this directory are included before the CRS rules. If you need to tweak (i.e. : SecRuleUpdateTargetById) put .conf files inside the /modsec-confs/ which is included after the CRS rules.
|
|
||||||
|
|
||||||
## Security headers
|
|
||||||
|
|
||||||
`X_FRAME_OPTIONS`
|
|
||||||
Values : *DENY* | *SAMEORIGIN* | *ALLOW-FROM https://www.website.net* | *ALLOWALL*
|
|
||||||
Default value : *DENY*
|
|
||||||
Policy to be used when the site is displayed through iframe. Can be used to mitigate clickjacking attacks.
|
|
||||||
More info [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options).
|
|
||||||
|
|
||||||
`X_XSS_PROTECTION`
|
|
||||||
Values : *0* | *1* | *1; mode=block*
|
|
||||||
Default value : *1; mode=block*
|
|
||||||
Policy to be used when XSS is detected by the browser. Only works with Internet Explorer.
|
|
||||||
More info [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection).
|
|
||||||
|
|
||||||
`X_CONTENT_TYPE_OPTIONS`
|
|
||||||
Values : *nosniff*
|
|
||||||
Default value : *nosniff*
|
|
||||||
Tells the browser to be strict about MIME type.
|
|
||||||
More info [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options).
|
|
||||||
|
|
||||||
`REFERRER_POLICY`
|
|
||||||
Values : *no-referrer* | *no-referrer-when-downgrade* | *origin* | *origin-when-cross-origin* | *same-origin* | *strict-origin* | *strict-origin-when-cross-origin* | *unsafe-url*
|
|
||||||
Default value : *no-referrer*
|
|
||||||
Policy to be used for the Referer header.
|
|
||||||
More info [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy).
|
|
||||||
|
|
||||||
`FEATURE_POLICY`
|
|
||||||
Values : *<directive> <allow list>*
|
|
||||||
Default value : *accelerometer 'none'; ambient-light-sensor 'none'; autoplay 'none'; camera 'none'; display-capture 'none'; document-domain 'none'; encrypted-media 'none'; fullscreen 'none'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; midi 'none'; payment 'none'; picture-in-picture 'none'; speaker 'none'; sync-xhr 'none'; usb 'none'; vibrate 'none'; vr 'none'*
|
|
||||||
Tells the browser which features can be used on the website.
|
|
||||||
More info [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Feature-Policy).
|
|
||||||
|
|
||||||
`COOKIE_FLAGS`
|
|
||||||
Values : *\* HttpOnly* | *MyCookie secure SameSite=Lax* | *...*
|
|
||||||
Default value : *\* HttpOnly SameSite=Lax*
|
|
||||||
Adds some security to the cookies set by the server.
|
|
||||||
Accepted value can be found [here](https://github.com/AirisX/nginx_cookie_flag_module).
|
|
||||||
|
|
||||||
`COOKIE_AUTO_SECURE_FLAG`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *yes*
|
|
||||||
When set to *yes*, the *secure* will be automatically added to cookies when using HTTPS.
|
|
||||||
|
|
||||||
`STRICT_TRANSPORT_POLICY`
|
|
||||||
Values : *max-age=expireTime [; includeSubDomains] [; preload]*
|
|
||||||
Default value : *max-age=31536000*
|
|
||||||
Tells the browser to use exclusively HTTPS instead of HTTP when communicating with the server.
|
|
||||||
More info [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security).
|
|
||||||
|
|
||||||
`CONTENT_SECURITY_POLICY`
|
|
||||||
Values : *\<directive 1\>; \<directive 2\>; ...*
|
|
||||||
Default value : *default-src 'self'; frame-ancestors 'self'; form-action 'self'; block-all-mixed-content; sandbox allow-forms allow-same-origin allow-scripts; reflected-xss block; base-uri 'self'; referrer no-referrer*
|
|
||||||
Policy to be used when loading resources (scripts, forms, frames, ...).
|
|
||||||
More info [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy).
|
|
||||||
|
|
||||||
## Blocking
|
|
||||||
|
|
||||||
### Antibot
|
|
||||||
|
|
||||||
`USE_ANTIBOT`
|
|
||||||
Values : *no* | *cookie* | *javascript* | *captcha* | *recaptcha*
|
|
||||||
Default value : *no*
|
|
||||||
If set to another allowed value than *no*, users must complete a "challenge" before accessing the pages on your website :
|
|
||||||
- *cookie* : asks the users to set a cookie
|
|
||||||
- *javascript* : users must execute a javascript code
|
|
||||||
- *captcha* : a text captcha must be resolved by the users
|
|
||||||
- *recaptcha* : use [Google reCAPTCHA v3](https://developers.google.com/recaptcha/intro) score to allow/deny users
|
|
||||||
|
|
||||||
`ANTIBOT_URI`
|
|
||||||
Values : *\<any valid uri\>*
|
|
||||||
Default value : */challenge*
|
|
||||||
A valid and unused URI to redirect users when `USE_ANTIBOT` is used. Be sure that it doesn't exist on your website.
|
|
||||||
|
|
||||||
`ANTIBOT_SESSION_SECRET`
|
|
||||||
Values : *random* | *\<32 chars of your choice\>*
|
|
||||||
Default value : *random*
|
|
||||||
A secret used to generate sessions when `USE_ANTIBOT` is set. Using the special *random* value will generate a random one. Be sure to use the same value when you are in a multi-server environment (so sessions are valid in all the servers).
|
|
||||||
|
|
||||||
`ANTIBOT_RECAPTCHA_SCORE`
|
|
||||||
Values : *\<0.0 to 1.0\>*
|
|
||||||
Default value : *0.7*
|
|
||||||
The minimum score required when `USE_ANTIBOT` is set to *recaptcha*.
|
|
||||||
|
|
||||||
`ANTIBOT_RECAPTCHA_SITEKEY`
|
|
||||||
Values : *\<public key given by Google\>*
|
|
||||||
Default value :
|
|
||||||
The sitekey given by Google when `USE_ANTIBOT` is set to *recaptcha*.
|
|
||||||
|
|
||||||
`ANTIBOT_RECAPTCHA_SECRET`
|
|
||||||
Values : *\<private key given by Google\>*
|
|
||||||
Default value :
|
|
||||||
The secret given by Google when `USE_ANTIBOT` is set to *recaptcha*.
|
|
||||||
|
|
||||||
### External blacklist
|
|
||||||
|
|
||||||
`BLOCK_USER_AGENT`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *yes*
|
|
||||||
If set to yes, block clients with "bad" user agent.
|
|
||||||
Blacklist can be found [here](https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/_generator_lists/bad-user-agents.list).
|
|
||||||
|
|
||||||
`BLOCK_TOR_EXIT_NODE`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *yes*
|
|
||||||
Is set to yes, will block known TOR exit nodes.
|
|
||||||
Blacklist can be found [here](https://iplists.firehol.org/?ipset=tor_exits).
|
|
||||||
|
|
||||||
`BLOCK_PROXIES`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *yes*
|
|
||||||
Is set to yes, will block known proxies.
|
|
||||||
Blacklist can be found [here](https://iplists.firehol.org/?ipset=firehol_proxies).
|
|
||||||
|
|
||||||
`BLOCK_ABUSERS`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *yes*
|
|
||||||
Is set to yes, will block known abusers.
|
|
||||||
Blacklist can be found [here](https://iplists.firehol.org/?ipset=firehol_abusers_30d).
|
|
||||||
|
|
||||||
### DNSBL
|
|
||||||
|
|
||||||
`USE_DNSBL`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *yes*
|
|
||||||
If set to *yes*, DNSBL checks will be performed to the servers specified in the `DNSBL_LIST` environment variable.
|
|
||||||
|
|
||||||
`DNSBL_LIST`
|
|
||||||
Values : *\<list of DNS zones separated with spaces\>*
|
|
||||||
Default value : *bl.blocklist.de problems.dnsbl.sorbs.net sbl.spamhaus.org xbl.spamhaus.org*
|
|
||||||
The list of DNSBL zones to query when `USE_DNSBL` is set to *yes*.
|
|
||||||
|
|
||||||
### Custom whitelisting
|
|
||||||
|
|
||||||
`USE_WHITELIST_IP`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *yes*
|
|
||||||
If set to *yes*, lets you define custom IP addresses to be whitelisted through the `WHITELIST_IP_LIST` environment variable.
|
|
||||||
|
|
||||||
`WHITELIST_IP_LIST`
|
|
||||||
Values : *\<list of IP addresses separated with spaces\>*
|
|
||||||
Default value : *23.21.227.69 40.88.21.235 50.16.241.113 50.16.241.114 50.16.241.117 50.16.247.234 52.204.97.54 52.5.190.19 54.197.234.188 54.208.100.253 54.208.102.37 107.21.1.8*
|
|
||||||
The list of IP addresses to whitelist when `USE_WHITELIST_IP` is set to *yes*. The default list contains IP addresses of the [DuckDuckGo crawler](https://help.duckduckgo.com/duckduckgo-help-pages/results/duckduckbot/).
|
|
||||||
|
|
||||||
`USE_WHITELIST_REVERSE`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *yes*
|
|
||||||
If set to *yes*, lets you define custom reverse DNS suffixes to be whitelisted through the `WHITELIST_REVERSE_LIST` environment variable.
|
|
||||||
|
|
||||||
`WHITELIST_REVERSE_LIST`
|
|
||||||
Values : *\<list of reverse DNS suffixes separated with spaces\>*
|
|
||||||
Default value : *.googlebot.com .google.com .search.msn.com .crawl.yahoot.net .crawl.baidu.jp .crawl.baidu.com .yandex.com .yandex.ru .yandex.net*
|
|
||||||
The list of reverse DNS suffixes to whitelist when `USE_WHITELIST_REVERSE` is set to *yes*. The default list contains suffixes of major search engines.
|
|
||||||
|
|
||||||
### Custom blacklisting
|
|
||||||
|
|
||||||
`USE_BLACKLIST_IP`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *yes*
|
|
||||||
If set to *yes*, lets you define custom IP addresses to be blacklisted through the `BLACKLIST_IP_LIST` environment variable.
|
|
||||||
|
|
||||||
`BLACKLIST_IP_LIST`
|
|
||||||
Values : *\<list of IP addresses separated with spaces\>*
|
|
||||||
Default value :
|
|
||||||
The list of IP addresses to blacklist when `USE_BLACKLIST_IP` is set to *yes*.
|
|
||||||
|
|
||||||
`USE_BLACKLIST_REVERSE`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *yes*
|
|
||||||
If set to *yes*, lets you define custom reverse DNS suffixes to be blacklisted through the `BLACKLIST_REVERSE_LIST` environment variable.
|
|
||||||
|
|
||||||
`BLACKLIST_REVERSE_LIST`
|
|
||||||
Values : *\<list of reverse DNS suffixes separated with spaces\>*
|
|
||||||
Default value : *.shodan.io*
|
|
||||||
The list of reverse DNS suffixes to blacklist when `USE_BLACKLIST_REVERSE` is set to *yes*.
|
|
||||||
|
|
||||||
### Requests limiting
|
|
||||||
|
|
||||||
`USE_LIMIT_REQ`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *yes*
|
|
||||||
If set to yes, the amount of HTTP requests made by a user will be limited during a period of time.
|
|
||||||
More info rate limiting [here](https://www.nginx.com/blog/rate-limiting-nginx/).
|
|
||||||
|
|
||||||
`LIMIT_REQ_RATE`
|
|
||||||
Values : *Xr/s* | *Xr/m*
|
|
||||||
Default value : *20r/s*
|
|
||||||
The rate limit to apply when `USE_LIMIT_REQ` is set to *yes*. Default is 10 requests per second.
|
|
||||||
|
|
||||||
`LIMIT_REQ_BURST`
|
|
||||||
Values : *<any valid integer\>*
|
|
||||||
Default value : *40*
|
|
||||||
The number of of requests to put in queue before rejecting requests.
|
|
||||||
|
|
||||||
`LIMIT_REQ_CACHE`
|
|
||||||
Values : *Xm* | *Xk*
|
|
||||||
Default value : *10m*
|
|
||||||
The size of the cache to store information about request limiting.
|
|
||||||
|
|
||||||
### Countries
|
|
||||||
|
|
||||||
`BLOCK_COUNTRY`
|
|
||||||
Values : *\<country code 1\> \<country code 2\> ...*
|
|
||||||
Default value :
|
|
||||||
Block some countries from accessing your website. Use 2 letters country code separated with space.
|
|
||||||
|
|
||||||
## PHP
|
|
||||||
|
|
||||||
`REMOTE_PHP`
|
|
||||||
Values : *\<any valid IP/hostname\>*
|
|
||||||
Default value :
|
|
||||||
Set the IP/hostname address of a remote PHP-FPM to execute .php files. See `USE_PHP` if you want to run a PHP-FPM instance on the same container as bunkerized-nginx.
|
|
||||||
|
|
||||||
`REMOTE_PHP_PATH`
|
|
||||||
Values : *\<any valid absolute path\>*
|
|
||||||
Default value : */app*
|
|
||||||
The path where the PHP files are located inside the server specified in `REMOTE_PHP`.
|
|
||||||
|
|
||||||
## Fail2ban
|
|
||||||
|
|
||||||
`USE_FAIL2BAN`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *yes*
|
|
||||||
If set to yes, fail2ban will be used to block users getting too much "strange" HTTP codes in a period of time.
|
|
||||||
Instead of using iptables which is not possible inside a container, fail2ban will dynamically update nginx to ban/unban IP addresses.
|
|
||||||
If a number (`FAIL2BAN_MAXRETRY`) of "strange" HTTP codes (`FAIL2BAN_STATUS_CODES`) is found between a time interval (`FAIL2BAN_FINDTIME`) then the originating IP address will be ban for a specific period of time (`FAIL2BAN_BANTIME`).
|
|
||||||
|
|
||||||
`FAIL2BAN_STATUS_CODES`
|
|
||||||
Values : *\<HTTP status codes separated with | char\>*
|
|
||||||
Default value : *400|401|403|404|405|444*
|
|
||||||
List of "strange" error codes that fail2ban will search for.
|
|
||||||
|
|
||||||
`FAIL2BAN_BANTIME`
|
|
||||||
Values : *<number of seconds>*
|
|
||||||
Default value : *3600*
|
|
||||||
The duration time, in seconds, of a ban.
|
|
||||||
|
|
||||||
`FAIL2BAN_FINDTIME`
|
|
||||||
Values : *<number of seconds>*
|
|
||||||
Default : value : *60*
|
|
||||||
The time interval, in seconds, to search for "strange" HTTP status codes.
|
|
||||||
|
|
||||||
`FAIL2BAN_MAXRETRY`
|
|
||||||
Values : *\<any positive integer\>*
|
|
||||||
Default : value : *15*
|
|
||||||
The number of "strange" HTTP status codes to find between the time interval.
|
|
||||||
|
|
||||||
## ClamAV
|
|
||||||
|
|
||||||
`USE_CLAMAV_UPLOAD`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *yes*
|
|
||||||
If set to yes, ClamAV will scan every file uploads and block the upload if the file is detected.
|
|
||||||
|
|
||||||
`USE_CLAMAV_SCAN`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *yes*
|
|
||||||
If set to yes, ClamAV will scan all the files inside the container every day.
|
|
||||||
|
|
||||||
`CLAMAV_SCAN_REMOVE`
|
|
||||||
Values : *yes* | *no*
|
|
||||||
Default value : *yes*
|
|
||||||
If set to yes, ClamAV will automatically remove the detected files.
|
|
||||||
|
|
||||||
## Misc
|
|
||||||
|
|
||||||
`ADDITIONAL_MODULES`
|
|
||||||
Values : *\<list of packages separated with space\>*
|
|
||||||
Default value :
|
|
||||||
You can specify additional modules to install. All [alpine packages](https://pkgs.alpinelinux.org/packages) are valid.
|
|
||||||
|
|
||||||
`LOGROTATE_MINSIZE`
|
|
||||||
Values : *x* | *xk* | *xM* | *xG*
|
|
||||||
Default value : 10M
|
|
||||||
The minimum size of a log file before being rotated (no letter = bytes, k = kilobytes, M = megabytes, G = gigabytes).
|
|
||||||
|
|
||||||
`LOGROTATE_MAXAGE`
|
|
||||||
Values : *\<any integer\>*
|
|
||||||
Default value : 7
|
|
||||||
The number of days before rotated files are deleted.
|
|
||||||
|
|
||||||
# Create your own image
|
|
||||||
|
|
||||||
You can use bunkerity/bunkerized-nginx as a base image for your web application. Here is a Dockerfile example :
|
|
||||||
```
|
|
||||||
FROM bunkerity/bunkerized-nginx
|
|
||||||
|
|
||||||
# Add your own script to be executed on startup
|
|
||||||
COPY ./my-entrypoint.sh /entrypoint.d/my-entrypoint.sh
|
|
||||||
RUN chmod +x /entrypoint.d/my-entrypoint.sh
|
|
||||||
|
|
||||||
# Edit default settings
|
|
||||||
ENV MAX_CLIENT_SIZE 100m
|
|
||||||
ENV BLOCK_TOR_EXIT_NODE no
|
|
||||||
ENV USE_ANTIBOT captcha
|
|
||||||
```
|
|
||||||
|
|
||||||
# Include custom configurations
|
|
||||||
Custom configurations files (ending with .conf suffix) can be added in some directory inside the container :
|
|
||||||
- /http-confs : http context
|
|
||||||
- /server-confs : server context
|
|
||||||
|
|
||||||
You just need to use a volume like this :
|
|
||||||
```
|
|
||||||
docker run ... -v /path/to/http/confs:/http-confs ... -v /path/to/server/confs:/server-confs ... bunkerity/bunkerized-nginx
|
|
||||||
```
|
|
||||||
|
|||||||
17
SECURITY.md
Normal file
17
SECURITY.md
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Security policy
|
||||||
|
|
||||||
|
Even though this project is focused on security, it is still prone to possible vulnerabilities. We consider every security bug as a serious issue and will try our best to address it.
|
||||||
|
|
||||||
|
## Responsible disclosure
|
||||||
|
|
||||||
|
If you have found a security bug, please send us an email at security \[@\] bunkerity.com with technical details so we can resolve it as soon as possible.
|
||||||
|
|
||||||
|
Here is a non-exhaustive list of issues we consider as high risk :
|
||||||
|
- Vulnerability in the core
|
||||||
|
- Bypass of a security feature
|
||||||
|
- Vulnerability in a third-party dependency
|
||||||
|
- Risk in the supply chain
|
||||||
|
|
||||||
|
## Bounty
|
||||||
|
|
||||||
|
To encourage responsible disclosure, we may reward you with a bounty at the sole discretion of the maintainers.
|
||||||
5
antibot/captcha.data
Normal file
5
antibot/captcha.data
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<form method="POST" action="%s">
|
||||||
|
<img src="data:image/jpeg;base64,%s" /><br>
|
||||||
|
Captcha : <input type="text" name="captcha" /><br />
|
||||||
|
<input type="submit" value="send" />
|
||||||
|
</form>
|
||||||
24
antibot/captcha.html
Normal file
24
antibot/captcha.html
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Website protection</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background-color: #1d70b7;
|
||||||
|
}
|
||||||
|
.centered {
|
||||||
|
position: fixed;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="centered" style="color: white;">
|
||||||
|
<h1>As a security measure, we ask you to complete this captcha to access our website :</h1>
|
||||||
|
%CAPTCHA%
|
||||||
|
<div>🛡️ this website is protected with <a href="https://github.com/bunkerity/bunkerized-nginx" target="_blank">bunkerized-nginx</a> 🛡️</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
29
antibot/javascript.data
Normal file
29
antibot/javascript.data
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<script>
|
||||||
|
async function digestMessage(message) {
|
||||||
|
const msgUint8 = new TextEncoder().encode(message);
|
||||||
|
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8);
|
||||||
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
||||||
|
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
||||||
|
return hashHex;
|
||||||
|
}
|
||||||
|
(async () => {
|
||||||
|
const nonce = '%s';
|
||||||
|
var i = 0;
|
||||||
|
while (true) {
|
||||||
|
var digestHex = await digestMessage(nonce + i.toString());
|
||||||
|
if (digestHex.startsWith("0000")) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
xhr = new XMLHttpRequest();
|
||||||
|
xhr.open('POST', '%s');
|
||||||
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||||
|
xhr.onload = function() {
|
||||||
|
if (xhr.status === 200) {
|
||||||
|
window.location.replace('%s');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhr.send(encodeURI('challenge=' + i.toString()));
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
43
antibot/javascript.html
Normal file
43
antibot/javascript.html
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Website protection</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background-color: #1d70b7;
|
||||||
|
}
|
||||||
|
.centered {
|
||||||
|
position: fixed;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.loader {
|
||||||
|
border: 16px solid #1d70b7;
|
||||||
|
border-top: 16px solid #2dab66;
|
||||||
|
border-radius: 50%;
|
||||||
|
width: 120px;
|
||||||
|
height: 120px;
|
||||||
|
animation: spin 2s linear infinite;
|
||||||
|
display: block;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
@keyframes spin {
|
||||||
|
0% { transform: rotate(0deg); }
|
||||||
|
100% { transform: rotate(360deg); }
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="centered" style="color: white;">
|
||||||
|
<div class="loader"></div>
|
||||||
|
<noscript>
|
||||||
|
<h1 style="color: red;">In order to access this website, you need to enable JavaScript.</h1>
|
||||||
|
</noscript>
|
||||||
|
<h1>Please wait while we are doing some security checks...</h1>
|
||||||
|
🛡️ this website is protected with <a href="https://github.com/bunkerity/bunkerized-nginx" target="_blank">bunkerized-nginx</a> 🛡️
|
||||||
|
</div>
|
||||||
|
%JAVASCRIPT%
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
11
antibot/recaptcha-body.data
Normal file
11
antibot/recaptcha-body.data
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<form method="POST" action="%s" id="form">
|
||||||
|
<input type="hidden" name="token" id="token">
|
||||||
|
</form>
|
||||||
|
<script>
|
||||||
|
grecaptcha.ready(function() {
|
||||||
|
grecaptcha.execute('%s', {action: 'recaptcha'}).then(function(token) {
|
||||||
|
document.getElementById("token").value = token;
|
||||||
|
document.getElementById("form").submit();
|
||||||
|
});;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
1
antibot/recaptcha-head.data
Normal file
1
antibot/recaptcha-head.data
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<script src="https://www.google.com/recaptcha/api.js?render=%s"></script>
|
||||||
44
antibot/recaptcha.html
Normal file
44
antibot/recaptcha.html
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Website protection</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background-color: #1d70b7;
|
||||||
|
}
|
||||||
|
.centered {
|
||||||
|
position: fixed;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.loader {
|
||||||
|
border: 16px solid #1d70b7;
|
||||||
|
border-top: 16px solid #2dab66;
|
||||||
|
border-radius: 50%;
|
||||||
|
width: 120px;
|
||||||
|
height: 120px;
|
||||||
|
animation: spin 2s linear infinite;
|
||||||
|
display: block;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
@keyframes spin {
|
||||||
|
0% { transform: rotate(0deg); }
|
||||||
|
100% { transform: rotate(360deg); }
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
%RECAPTCHA_HEAD%
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="centered" style="color: white;">
|
||||||
|
<div class="loader"></div>
|
||||||
|
<noscript>
|
||||||
|
<h1 style="color: red;">In order to access this website, you need to enable JavaScript.</h1>
|
||||||
|
</noscript>
|
||||||
|
<h1>Please wait while we are doing some security checks...</h1>
|
||||||
|
🛡️ this website is protected with <a href="https://github.com/bunkerity/bunkerized-nginx" target="_blank">bunkerized-nginx</a> 🛡️
|
||||||
|
</div>
|
||||||
|
%RECAPTCHA_BODY%
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
27
autoconf/Dockerfile
Normal file
27
autoconf/Dockerfile
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
FROM alpine
|
||||||
|
|
||||||
|
COPY gen/ /opt/bunkerized-nginx/gen
|
||||||
|
COPY entrypoint/ /opt/bunkerized-nginx/entrypoint
|
||||||
|
COPY confs/global/ /opt/bunkerized-nginx/confs/global
|
||||||
|
COPY confs/site/ /opt/bunkerized-nginx/confs/site
|
||||||
|
COPY jobs/ /opt/bunkerized-nginx/jobs
|
||||||
|
COPY settings.json /opt/bunkerized-nginx/
|
||||||
|
COPY misc/cron-autoconf /etc/crontabs/root
|
||||||
|
COPY autoconf/entrypoint.sh /opt/bunkerized-nginx/entrypoint/
|
||||||
|
COPY autoconf/requirements.txt /opt/bunkerized-nginx/entrypoint/
|
||||||
|
COPY autoconf/src/* /opt/bunkerized-nginx/entrypoint/
|
||||||
|
|
||||||
|
RUN apk add --no-cache py3-pip bash certbot curl openssl && \
|
||||||
|
pip3 install -r /opt/bunkerized-nginx/gen/requirements.txt && \
|
||||||
|
pip3 install -r /opt/bunkerized-nginx/entrypoint/requirements.txt && \
|
||||||
|
pip3 install -r /opt/bunkerized-nginx/jobs/requirements.txt
|
||||||
|
|
||||||
|
COPY autoconf/prepare.sh /tmp
|
||||||
|
RUN chmod +x /tmp/prepare.sh && \
|
||||||
|
/tmp/prepare.sh && \
|
||||||
|
rm -f /tmp/prepare.sh
|
||||||
|
|
||||||
|
# Fix CVE-2021-36159
|
||||||
|
RUN apk add "apk-tools>=2.12.6-r0"
|
||||||
|
|
||||||
|
ENTRYPOINT ["/opt/bunkerized-nginx/entrypoint/entrypoint.sh"]
|
||||||
33
autoconf/entrypoint.sh
Normal file
33
autoconf/entrypoint.sh
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "[*] Starting autoconf ..."
|
||||||
|
|
||||||
|
# check permissions
|
||||||
|
su -s "/opt/bunkerized-nginx/entrypoint/permissions.sh" nginx
|
||||||
|
if [ "$?" -ne 0 ] ; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# trap SIGTERM and SIGINT
|
||||||
|
function trap_exit() {
|
||||||
|
echo "[*] Catched stop operation"
|
||||||
|
echo "[*] Stopping crond ..."
|
||||||
|
pkill -TERM crond
|
||||||
|
echo "[*] Stopping autoconf ..."
|
||||||
|
pkill -TERM python3
|
||||||
|
}
|
||||||
|
trap "trap_exit" TERM INT QUIT
|
||||||
|
|
||||||
|
# start cron
|
||||||
|
crond
|
||||||
|
|
||||||
|
# run autoconf app
|
||||||
|
/opt/bunkerized-nginx/entrypoint/app.py &
|
||||||
|
pid="$!"
|
||||||
|
|
||||||
|
# wait while app is up
|
||||||
|
wait "$pid"
|
||||||
|
|
||||||
|
# stop
|
||||||
|
echo "[*] autoconf stopped"
|
||||||
|
exit 0
|
||||||
63
autoconf/prepare.sh
Normal file
63
autoconf/prepare.sh
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# create nginx user
|
||||||
|
addgroup -g 101 nginx
|
||||||
|
adduser -h /var/cache/nginx -g nginx -s /bin/sh -G nginx -D -H -u 101 nginx
|
||||||
|
|
||||||
|
# prepare /opt
|
||||||
|
chown root:nginx /opt
|
||||||
|
chmod 750 /opt
|
||||||
|
|
||||||
|
# prepare /opt/bunkerized-nginx
|
||||||
|
chown -R root:nginx /opt/bunkerized-nginx
|
||||||
|
find /opt/bunkerized-nginx -type f -exec chmod 0740 {} \;
|
||||||
|
find /opt/bunkerized-nginx -type d -exec chmod 0750 {} \;
|
||||||
|
chmod ugo+x /opt/bunkerized-nginx/entrypoint/* /opt/bunkerized-nginx/scripts/*
|
||||||
|
chmod ugo+x /opt/bunkerized-nginx/gen/main.py
|
||||||
|
chmod ugo+x /opt/bunkerized-nginx/jobs/main.py
|
||||||
|
chmod ugo+x /opt/bunkerized-nginx/jobs/reload.py
|
||||||
|
chmod 770 /opt/bunkerized-nginx
|
||||||
|
chmod 440 /opt/bunkerized-nginx/settings.json
|
||||||
|
|
||||||
|
# prepare /var/log
|
||||||
|
mkdir /var/log/nginx
|
||||||
|
chown root:nginx /var/log/nginx
|
||||||
|
chmod 770 /var/log/nginx
|
||||||
|
ln -s /proc/1/fd/1 /var/log/nginx/jobs.log
|
||||||
|
mkdir /var/log/letsencrypt
|
||||||
|
chown nginx:nginx /var/log/letsencrypt
|
||||||
|
chmod 770 /var/log/letsencrypt
|
||||||
|
|
||||||
|
# prepare /etc/letsencrypt
|
||||||
|
mkdir /etc/letsencrypt
|
||||||
|
chown root:nginx /etc/letsencrypt
|
||||||
|
chmod 770 /etc/letsencrypt
|
||||||
|
|
||||||
|
# prepare /var/lib/letsencrypt
|
||||||
|
mkdir /var/lib/letsencrypt
|
||||||
|
chown root:nginx /var/lib/letsencrypt
|
||||||
|
chmod 770 /var/lib/letsencrypt
|
||||||
|
|
||||||
|
# prepare /opt/bunkerized-nginx/cache
|
||||||
|
ln -s /cache /opt/bunkerized-nginx/cache
|
||||||
|
mkdir /cache
|
||||||
|
chown root:nginx /cache
|
||||||
|
chmod 770 /cache
|
||||||
|
|
||||||
|
# prepare /acme-challenge
|
||||||
|
ln -s /acme-challenge /opt/bunkerized-nginx/acme-challenge
|
||||||
|
mkdir /acme-challenge
|
||||||
|
chown root:nginx /acme-challenge
|
||||||
|
chmod 770 /acme-challenge
|
||||||
|
|
||||||
|
# prepare /modsec-confs
|
||||||
|
ln -s /modsec-confs /opt/bunkerized-nginx/modsec-confs
|
||||||
|
mkdir /modsec-confs
|
||||||
|
chown root:nginx /modsec-confs
|
||||||
|
chmod 770 /modsec-confs
|
||||||
|
|
||||||
|
# prepare /modsec-crs-confs
|
||||||
|
ln -s /modsec-crs-confs /opt/bunkerized-nginx/modsec-crs-confs
|
||||||
|
mkdir /modsec-crs-confs
|
||||||
|
chown root:nginx /modsec-crs-confs
|
||||||
|
chmod 770 /modsec-crs-confs
|
||||||
5
autoconf/requirements.txt
Normal file
5
autoconf/requirements.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
docker
|
||||||
|
requests
|
||||||
|
jinja2
|
||||||
|
kubernetes
|
||||||
|
dnspython
|
||||||
158
autoconf/src/Config.py
Normal file
158
autoconf/src/Config.py
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import subprocess, shutil, os, traceback, requests, time, dns.resolver
|
||||||
|
|
||||||
|
import Controller
|
||||||
|
|
||||||
|
from logger import log
|
||||||
|
|
||||||
|
class Config :
|
||||||
|
|
||||||
|
def __init__(self, type, api_uri, http_port="8080") :
|
||||||
|
self.__type = type
|
||||||
|
self.__api_uri = api_uri
|
||||||
|
self.__http_port = http_port
|
||||||
|
|
||||||
|
def __jobs(self) :
|
||||||
|
log("config", "INFO", "starting jobs ...")
|
||||||
|
proc = subprocess.run(["/bin/su", "-c", "/opt/bunkerized-nginx/entrypoint/jobs.sh", "nginx"], capture_output=True)
|
||||||
|
stdout = proc.stdout.decode("ascii")
|
||||||
|
stderr = proc.stderr.decode("ascii")
|
||||||
|
if len(stdout) > 1 :
|
||||||
|
log("config", "INFO", "jobs stdout : " + stdout)
|
||||||
|
if stderr != "" :
|
||||||
|
log("config", "ERROR", "jobs stderr : " + stderr)
|
||||||
|
if proc.returncode != 0 :
|
||||||
|
log("config", "ERROR", "jobs error (return code = " + str(proc.returncode) + ")")
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def gen(self, env) :
|
||||||
|
try :
|
||||||
|
# Write environment variables to a file
|
||||||
|
with open("/tmp/variables.env", "w") as f :
|
||||||
|
for k, v in env.items() :
|
||||||
|
f.write(k + "=" + v + "\n")
|
||||||
|
|
||||||
|
# Call the generator
|
||||||
|
proc = subprocess.run(["/bin/su", "-c", "/opt/bunkerized-nginx/gen/main.py --settings /opt/bunkerized-nginx/settings.json --templates /opt/bunkerized-nginx/confs --output /etc/nginx --variables /tmp/variables.env", "nginx"], capture_output=True)
|
||||||
|
|
||||||
|
# Print stdout/stderr
|
||||||
|
stdout = proc.stdout.decode("ascii")
|
||||||
|
stderr = proc.stderr.decode("ascii")
|
||||||
|
if len(stdout) > 1 :
|
||||||
|
log("config", "INFO", "generator output : " + stdout)
|
||||||
|
if stderr != "" :
|
||||||
|
log("config", "ERROR", "generator error : " + stderr)
|
||||||
|
|
||||||
|
# We're done
|
||||||
|
if proc.returncode == 0 :
|
||||||
|
if self.__type == Controller.Type.SWARM or self.__type == Controller.Type.KUBERNETES :
|
||||||
|
return self.__jobs()
|
||||||
|
return True
|
||||||
|
log("config", "ERROR", "error while generating config (return code = " + str(proc.returncode) + ")")
|
||||||
|
|
||||||
|
except Exception as e :
|
||||||
|
log("config", "ERROR", "exception while generating site config : " + traceback.format_exc())
|
||||||
|
return False
|
||||||
|
|
||||||
|
def reload(self, instances) :
|
||||||
|
ret = True
|
||||||
|
if self.__type == Controller.Type.DOCKER :
|
||||||
|
for instance in instances :
|
||||||
|
try :
|
||||||
|
instance.kill("SIGHUP")
|
||||||
|
except :
|
||||||
|
ret = False
|
||||||
|
elif self.__type == Controller.Type.SWARM :
|
||||||
|
ret = self.__api_call(instances, "/reload")
|
||||||
|
elif self.__type == Controller.Type.KUBERNETES :
|
||||||
|
ret = self.__api_call(instances, "/reload")
|
||||||
|
return ret
|
||||||
|
|
||||||
|
def __ping(self, instances) :
|
||||||
|
return self.__api_call(instances, "/ping")
|
||||||
|
|
||||||
|
def wait(self, instances) :
|
||||||
|
ret = True
|
||||||
|
if self.__type == Controller.Type.DOCKER :
|
||||||
|
ret = self.__wait_docker(instances)
|
||||||
|
elif self.__type == Controller.Type.SWARM or self.__type == Controller.Type.KUBERNETES :
|
||||||
|
ret = self.__wait_api(instances)
|
||||||
|
return ret
|
||||||
|
|
||||||
|
def __wait_docker(self, instances) :
|
||||||
|
all_healthy = False
|
||||||
|
i = 0
|
||||||
|
while i < 120 :
|
||||||
|
one_not_healthy = False
|
||||||
|
for instance in instances :
|
||||||
|
instance.reload()
|
||||||
|
if instance.attrs["State"]["Health"]["Status"] != "healthy" :
|
||||||
|
one_not_healthy = True
|
||||||
|
break
|
||||||
|
if not one_not_healthy :
|
||||||
|
all_healthy = True
|
||||||
|
break
|
||||||
|
time.sleep(1)
|
||||||
|
i += 1
|
||||||
|
return all_healthy
|
||||||
|
|
||||||
|
def __wait_api(self, instances) :
|
||||||
|
try :
|
||||||
|
with open("/etc/nginx/autoconf", "w") as f :
|
||||||
|
f.write("ok")
|
||||||
|
i = 1
|
||||||
|
started = False
|
||||||
|
while i <= 10 :
|
||||||
|
time.sleep(i)
|
||||||
|
if self.__ping(instances) :
|
||||||
|
started = True
|
||||||
|
break
|
||||||
|
i = i + 1
|
||||||
|
log("config", "INFO", "waiting " + str(i) + " seconds before retrying to contact bunkerized-nginx instances")
|
||||||
|
if started :
|
||||||
|
log("config", "INFO", "bunkerized-nginx instances started")
|
||||||
|
return True
|
||||||
|
else :
|
||||||
|
log("config", "ERROR", "bunkerized-nginx instances are not started")
|
||||||
|
except Exception as e :
|
||||||
|
log("config", "ERROR", "exception while waiting for bunkerized-nginx instances : " + traceback.format_exc())
|
||||||
|
return False
|
||||||
|
|
||||||
|
def __api_call(self, instances, path) :
|
||||||
|
ret = True
|
||||||
|
nb = 0
|
||||||
|
urls = []
|
||||||
|
if self.__type == Controller.Type.SWARM :
|
||||||
|
for instance in instances :
|
||||||
|
name = instance.name
|
||||||
|
try :
|
||||||
|
dns_result = dns.resolver.query("tasks." + name)
|
||||||
|
for ip in dns_result :
|
||||||
|
urls.append("http://" + ip.to_text() + ":" + self.__http_port + self.__api_uri + path)
|
||||||
|
except :
|
||||||
|
ret = False
|
||||||
|
elif self.__type == Controller.Type.KUBERNETES :
|
||||||
|
for instance in instances :
|
||||||
|
name = instance.metadata.name
|
||||||
|
try :
|
||||||
|
dns_result = dns.resolver.query(name + "." + instance.metadata.namespace + ".svc.cluster.local")
|
||||||
|
for ip in dns_result :
|
||||||
|
urls.append("http://" + ip.to_text() + ":" + self.__http_port + self.__api_uri + path)
|
||||||
|
except :
|
||||||
|
ret = False
|
||||||
|
|
||||||
|
for url in urls :
|
||||||
|
req = None
|
||||||
|
try :
|
||||||
|
req = requests.post(url)
|
||||||
|
except :
|
||||||
|
pass
|
||||||
|
if req and req.status_code == 200 and req.text == "ok" :
|
||||||
|
log("config", "INFO", "successfully sent API order to " + url)
|
||||||
|
nb += 1
|
||||||
|
else :
|
||||||
|
log("config", "INFO", "failed API order to " + url)
|
||||||
|
ret = False
|
||||||
|
return ret and nb > 0
|
||||||
53
autoconf/src/Controller.py
Normal file
53
autoconf/src/Controller.py
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
from abc import ABC, abstractmethod
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
from Config import Config
|
||||||
|
|
||||||
|
class Type(Enum) :
|
||||||
|
DOCKER = 1
|
||||||
|
SWARM = 2
|
||||||
|
KUBERNETES = 3
|
||||||
|
|
||||||
|
class Controller(ABC) :
|
||||||
|
|
||||||
|
def __init__(self, type, api_uri=None, lock=None, http_port="8080") :
|
||||||
|
self._config = Config(type, api_uri, http_port=http_port)
|
||||||
|
self.lock = lock
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def get_env(self) :
|
||||||
|
pass
|
||||||
|
|
||||||
|
def _fix_env(self, env) :
|
||||||
|
fixed_env = env.copy()
|
||||||
|
blacklist = ["NGINX_VERSION", "NJS_VERSION", "PATH", "PKG_RELEASE"]
|
||||||
|
for key in blacklist :
|
||||||
|
if key in fixed_env :
|
||||||
|
del fixed_env[key]
|
||||||
|
return fixed_env
|
||||||
|
|
||||||
|
def gen_conf(self, env) :
|
||||||
|
try :
|
||||||
|
ret = self._config.gen(env)
|
||||||
|
except :
|
||||||
|
ret = False
|
||||||
|
return ret
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def wait(self) :
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def process_events(self, current_env) :
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def reload(self) :
|
||||||
|
pass
|
||||||
|
|
||||||
|
def _reload(self, instances) :
|
||||||
|
try :
|
||||||
|
ret = self._config.reload(instances)
|
||||||
|
except :
|
||||||
|
ret = False
|
||||||
|
return ret
|
||||||
78
autoconf/src/DockerController.py
Normal file
78
autoconf/src/DockerController.py
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
import docker, time
|
||||||
|
import Controller
|
||||||
|
|
||||||
|
from logger import log
|
||||||
|
|
||||||
|
class DockerController(Controller.Controller) :
|
||||||
|
|
||||||
|
def __init__(self, docker_host) :
|
||||||
|
super().__init__(Controller.Type.DOCKER)
|
||||||
|
self.__client = docker.DockerClient(base_url=docker_host)
|
||||||
|
|
||||||
|
def __get_instances(self) :
|
||||||
|
return self.__client.containers.list(filters={"label" : "bunkerized-nginx.AUTOCONF"})
|
||||||
|
|
||||||
|
def __get_containers(self) :
|
||||||
|
return self.__client.containers.list(filters={"label" : "bunkerized-nginx.SERVER_NAME"})
|
||||||
|
|
||||||
|
def get_env(self) :
|
||||||
|
env = {}
|
||||||
|
for instance in self.__get_instances() :
|
||||||
|
for variable in instance.attrs["Config"]["Env"] :
|
||||||
|
env[variable.split("=")[0]] = variable.replace(variable.split("=")[0] + "=", "", 1)
|
||||||
|
first_servers = []
|
||||||
|
if "SERVER_NAME" in env and env["SERVER_NAME"] != "" :
|
||||||
|
first_servers = env["SERVER_NAME"].split(" ")
|
||||||
|
for container in self.__get_containers() :
|
||||||
|
first_server = container.labels["bunkerized-nginx.SERVER_NAME"].split(" ")[0]
|
||||||
|
first_servers.append(first_server)
|
||||||
|
for variable, value in container.labels.items() :
|
||||||
|
if variable.startswith("bunkerized-nginx.") and variable != "bunkerized-nginx.AUTOCONF" :
|
||||||
|
env[first_server + "_" + variable.replace("bunkerized-nginx.", "", 1)] = value
|
||||||
|
if len(first_servers) == 0 :
|
||||||
|
env["SERVER_NAME"] = ""
|
||||||
|
else :
|
||||||
|
env["SERVER_NAME"] = " ".join(first_servers)
|
||||||
|
return self._fix_env(env)
|
||||||
|
|
||||||
|
def process_events(self, current_env) :
|
||||||
|
old_env = current_env
|
||||||
|
# TODO : check why filter isn't working as expected
|
||||||
|
#for event in self.__client.events(decode=True, filters={"type": "container", "label": ["bunkerized-nginx.AUTOCONF", "bunkerized-nginx.SERVER_NAME"]}) :
|
||||||
|
for event in self.__client.events(decode=True, filters={"type": "container"}) :
|
||||||
|
new_env = self.get_env()
|
||||||
|
if new_env != old_env :
|
||||||
|
try :
|
||||||
|
log("controller", "INFO", "generating new configuration")
|
||||||
|
if self.gen_conf(new_env) :
|
||||||
|
old_env = new_env.copy()
|
||||||
|
log("controller", "INFO", "successfully generated new configuration")
|
||||||
|
if self.reload() :
|
||||||
|
log("controller", "INFO", "successful reload")
|
||||||
|
else :
|
||||||
|
log("controller", "ERROR", "failed reload")
|
||||||
|
else :
|
||||||
|
log("controller", "ERROR", "can't generate new configuration")
|
||||||
|
except :
|
||||||
|
log("controller", "ERROR", "exception while receiving event")
|
||||||
|
|
||||||
|
def reload(self) :
|
||||||
|
return self._reload(self.__get_instances())
|
||||||
|
|
||||||
|
|
||||||
|
def wait(self) :
|
||||||
|
try :
|
||||||
|
# Wait for a container
|
||||||
|
instances = self.__get_instances()
|
||||||
|
while len(instances) == 0 :
|
||||||
|
time.sleep(1)
|
||||||
|
instances = self.__get_instances()
|
||||||
|
# Generate first config
|
||||||
|
env = self.get_env()
|
||||||
|
if not self.gen_conf(env) :
|
||||||
|
return False, env
|
||||||
|
# Wait for nginx
|
||||||
|
return self._config.wait(instances), env
|
||||||
|
except :
|
||||||
|
pass
|
||||||
|
return False, {}
|
||||||
193
autoconf/src/IngressController.py
Normal file
193
autoconf/src/IngressController.py
Normal file
@@ -0,0 +1,193 @@
|
|||||||
|
from kubernetes import client, config, watch
|
||||||
|
from threading import Thread, Lock
|
||||||
|
import time
|
||||||
|
|
||||||
|
import Controller
|
||||||
|
|
||||||
|
from logger import log
|
||||||
|
|
||||||
|
class IngressController(Controller.Controller) :
|
||||||
|
|
||||||
|
def __init__(self, api_uri, http_port) :
|
||||||
|
super().__init__(Controller.Type.KUBERNETES, api_uri=api_uri, lock=Lock(), http_port=http_port)
|
||||||
|
config.load_incluster_config()
|
||||||
|
self.__api = client.CoreV1Api()
|
||||||
|
self.__extensions_api = client.ExtensionsV1beta1Api()
|
||||||
|
self.__old_env = {}
|
||||||
|
|
||||||
|
def __get_pods(self) :
|
||||||
|
return self.__api.list_pod_for_all_namespaces(watch=False, label_selector="bunkerized-nginx").items
|
||||||
|
|
||||||
|
def __get_ingresses(self) :
|
||||||
|
return self.__extensions_api.list_ingress_for_all_namespaces(watch=False, label_selector="bunkerized-nginx").items
|
||||||
|
|
||||||
|
def __get_services(self, autoconf=False) :
|
||||||
|
services = self.__api.list_service_for_all_namespaces(watch=False, label_selector="bunkerized-nginx").items
|
||||||
|
if not autoconf :
|
||||||
|
return services
|
||||||
|
services_autoconf = []
|
||||||
|
for service in services :
|
||||||
|
if service.metadata.annotations != None and "bunkerized-nginx.AUTOCONF" in service.metadata.annotations :
|
||||||
|
services_autoconf.append(service)
|
||||||
|
return services_autoconf
|
||||||
|
|
||||||
|
def __pod_to_env(self, pod_env) :
|
||||||
|
env = {}
|
||||||
|
for env_var in pod_env :
|
||||||
|
env[env_var.name] = env_var.value
|
||||||
|
if env_var.value == None :
|
||||||
|
env[env_var.name] = ""
|
||||||
|
return env
|
||||||
|
|
||||||
|
def __annotations_to_env(self, annotations) :
|
||||||
|
env = {}
|
||||||
|
prefix = annotations["bunkerized-nginx.SERVER_NAME"].split(" ")[0] + "_"
|
||||||
|
for annotation in annotations :
|
||||||
|
if annotation.startswith("bunkerized-nginx.") and annotation.replace("bunkerized-nginx.", "", 1) != "" and annotation.replace("bunkerized-nginx.", "", 1) != "AUTOCONF" :
|
||||||
|
env[prefix + annotation.replace("bunkerized-nginx.", "", 1)] = annotations[annotation]
|
||||||
|
return env
|
||||||
|
|
||||||
|
def __rules_to_env(self, rules, namespace="default") :
|
||||||
|
env = {}
|
||||||
|
first_servers = []
|
||||||
|
for rule in rules :
|
||||||
|
rule = rule.to_dict()
|
||||||
|
prefix = ""
|
||||||
|
if "host" in rule :
|
||||||
|
prefix = rule["host"] + "_"
|
||||||
|
first_servers.append(rule["host"])
|
||||||
|
if not "http" in rule or not "paths" in rule["http"] :
|
||||||
|
continue
|
||||||
|
for path in rule["http"]["paths"] :
|
||||||
|
env[prefix + "USE_REVERSE_PROXY"] = "yes"
|
||||||
|
env[prefix + "REVERSE_PROXY_URL"] = path["path"]
|
||||||
|
env[prefix + "REVERSE_PROXY_HOST"] = "http://" + path["backend"]["service_name"] + "." + namespace + ".svc.cluster.local:" + str(path["backend"]["service_port"])
|
||||||
|
env["SERVER_NAME"] = " ".join(first_servers)
|
||||||
|
return env
|
||||||
|
|
||||||
|
def get_env(self) :
|
||||||
|
pods = self.__get_pods()
|
||||||
|
ingresses = self.__get_ingresses()
|
||||||
|
services = self.__get_services()
|
||||||
|
env = {}
|
||||||
|
first_servers = []
|
||||||
|
for pod in pods :
|
||||||
|
env.update(self.__pod_to_env(pod.spec.containers[0].env))
|
||||||
|
if "SERVER_NAME" in env and env["SERVER_NAME"] != "" :
|
||||||
|
first_servers.extend(env["SERVER_NAME"].split(" "))
|
||||||
|
for ingress in ingresses :
|
||||||
|
env.update(self.__rules_to_env(ingress.spec.rules, namespace=ingress.metadata.namespace))
|
||||||
|
if ingress.spec.tls :
|
||||||
|
for tls_entry in ingress.spec.tls :
|
||||||
|
for host in tls_entry.hosts :
|
||||||
|
env[host + "_AUTO_LETS_ENCRYPT"] = "yes"
|
||||||
|
if "SERVER_NAME" in env and env["SERVER_NAME"] != "" :
|
||||||
|
first_servers.extend(env["SERVER_NAME"].split(" "))
|
||||||
|
for service in services :
|
||||||
|
if service.metadata.annotations != None and "bunkerized-nginx.SERVER_NAME" in service.metadata.annotations :
|
||||||
|
env.update(self.__annotations_to_env(service.metadata.annotations))
|
||||||
|
first_servers.append(service.metadata.annotations["bunkerized-nginx.SERVER_NAME"])
|
||||||
|
first_servers = list(dict.fromkeys(first_servers))
|
||||||
|
if len(first_servers) == 0 :
|
||||||
|
env["SERVER_NAME"] = ""
|
||||||
|
else :
|
||||||
|
env["SERVER_NAME"] = " ".join(first_servers)
|
||||||
|
return self._fix_env(env)
|
||||||
|
|
||||||
|
def process_events(self, current_env) :
|
||||||
|
self.__old_env = current_env
|
||||||
|
t_pod = Thread(target=self.__watch_pod)
|
||||||
|
t_ingress = Thread(target=self.__watch_ingress)
|
||||||
|
t_service = Thread(target=self.__watch_service)
|
||||||
|
t_pod.start()
|
||||||
|
t_ingress.start()
|
||||||
|
t_service.start()
|
||||||
|
t_pod.join()
|
||||||
|
t_ingress.join()
|
||||||
|
t_service.join()
|
||||||
|
|
||||||
|
def __watch_pod(self) :
|
||||||
|
w = watch.Watch()
|
||||||
|
for event in w.stream(self.__api.list_pod_for_all_namespaces, label_selector="bunkerized-nginx") :
|
||||||
|
self.lock.acquire()
|
||||||
|
new_env = self.get_env()
|
||||||
|
if new_env != self.__old_env :
|
||||||
|
try :
|
||||||
|
if self.gen_conf(new_env) :
|
||||||
|
self.__old_env = new_env.copy()
|
||||||
|
log("CONTROLLER", "INFO", "successfully generated new configuration")
|
||||||
|
if self.reload() :
|
||||||
|
log("controller", "INFO", "successful reload")
|
||||||
|
else :
|
||||||
|
log("controller", "ERROR", "failed reload")
|
||||||
|
except :
|
||||||
|
log("controller", "ERROR", "exception while receiving event")
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
|
def __watch_ingress(self) :
|
||||||
|
w = watch.Watch()
|
||||||
|
for event in w.stream(self.__extensions_api.list_ingress_for_all_namespaces, label_selector="bunkerized-nginx") :
|
||||||
|
self.lock.acquire()
|
||||||
|
new_env = self.get_env()
|
||||||
|
if new_env != self.__old_env :
|
||||||
|
try :
|
||||||
|
if self.gen_conf(new_env) :
|
||||||
|
self.__old_env = new_env.copy()
|
||||||
|
log("CONTROLLER", "INFO", "successfully generated new configuration")
|
||||||
|
if self.reload() :
|
||||||
|
log("controller", "INFO", "successful reload")
|
||||||
|
else :
|
||||||
|
log("controller", "ERROR", "failed reload")
|
||||||
|
except :
|
||||||
|
log("controller", "ERROR", "exception while receiving event")
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
|
def __watch_service(self) :
|
||||||
|
w = watch.Watch()
|
||||||
|
for event in w.stream(self.__api.list_service_for_all_namespaces, label_selector="bunkerized-nginx") :
|
||||||
|
self.lock.acquire()
|
||||||
|
new_env = self.get_env()
|
||||||
|
if new_env != self.__old_env :
|
||||||
|
try :
|
||||||
|
if self.gen_conf(new_env) :
|
||||||
|
self.__old_env = new_env.copy()
|
||||||
|
log("CONTROLLER", "INFO", "successfully generated new configuration")
|
||||||
|
if self.reload() :
|
||||||
|
log("controller", "INFO", "successful reload")
|
||||||
|
else :
|
||||||
|
log("controller", "ERROR", "failed reload")
|
||||||
|
except :
|
||||||
|
log("controller", "ERROR", "exception while receiving event")
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
|
def reload(self) :
|
||||||
|
return self._reload(self.__get_services(autoconf=True))
|
||||||
|
|
||||||
|
def wait(self) :
|
||||||
|
self.lock.acquire()
|
||||||
|
try :
|
||||||
|
# Wait for at least one bunkerized-nginx pod
|
||||||
|
pods = self.__get_pods()
|
||||||
|
while len(pods) == 0 :
|
||||||
|
time.sleep(1)
|
||||||
|
pods = self.__get_pods()
|
||||||
|
|
||||||
|
# Wait for at least one bunkerized-nginx service
|
||||||
|
services = self.__get_services(autoconf=True)
|
||||||
|
while len(services) == 0 :
|
||||||
|
time.sleep(1)
|
||||||
|
services = self.__get_services(autoconf=True)
|
||||||
|
|
||||||
|
# Generate first config
|
||||||
|
env = self.get_env()
|
||||||
|
if not self.gen_conf(env) :
|
||||||
|
self.lock.release()
|
||||||
|
return False, env
|
||||||
|
|
||||||
|
# Wait for bunkerized-nginx
|
||||||
|
self.lock.release()
|
||||||
|
return self._config.wait(services), env
|
||||||
|
except :
|
||||||
|
pass
|
||||||
|
self.lock.release()
|
||||||
|
return False, {}
|
||||||
42
autoconf/src/ReloadServer.py
Normal file
42
autoconf/src/ReloadServer.py
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import socketserver, threading, os, stat
|
||||||
|
|
||||||
|
from logger import log
|
||||||
|
|
||||||
|
class ReloadServerHandler(socketserver.StreamRequestHandler):
|
||||||
|
|
||||||
|
def handle(self) :
|
||||||
|
locked = False
|
||||||
|
try :
|
||||||
|
|
||||||
|
while True :
|
||||||
|
data = self.request.recv(512)
|
||||||
|
if not data or not data in [b"lock", b"reload", b"unlock"] :
|
||||||
|
break
|
||||||
|
if data == b"lock" :
|
||||||
|
self.server.controller.lock.acquire()
|
||||||
|
locked = True
|
||||||
|
self.request.sendall(b"ok")
|
||||||
|
elif data == b"unlock" :
|
||||||
|
self.server.controller.lock.release()
|
||||||
|
locked = False
|
||||||
|
self.request.sendall(b"ok")
|
||||||
|
elif data == b"reload" :
|
||||||
|
ret = self.server.controller.reload()
|
||||||
|
if ret :
|
||||||
|
self.request.sendall(b"ok")
|
||||||
|
else :
|
||||||
|
self.request.sendall(b"ko")
|
||||||
|
except Exception as e :
|
||||||
|
log("RELOADSERVER", "ERROR", "exception : " + str(e))
|
||||||
|
if locked :
|
||||||
|
self.server.controller.lock.release()
|
||||||
|
|
||||||
|
def run_reload_server(controller) :
|
||||||
|
server = socketserver.UnixStreamServer("/tmp/autoconf.sock", ReloadServerHandler)
|
||||||
|
os.chown("/tmp/autoconf.sock", 0, 101)
|
||||||
|
os.chmod("/tmp/autoconf.sock", 0o770)
|
||||||
|
server.controller = controller
|
||||||
|
thread = threading.Thread(target=server.serve_forever)
|
||||||
|
thread.daemon = True
|
||||||
|
thread.start()
|
||||||
|
return (server, thread)
|
||||||
85
autoconf/src/SwarmController.py
Normal file
85
autoconf/src/SwarmController.py
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
import docker, time
|
||||||
|
from threading import Lock
|
||||||
|
|
||||||
|
from logger import log
|
||||||
|
|
||||||
|
import Controller
|
||||||
|
|
||||||
|
class SwarmController(Controller.Controller) :
|
||||||
|
|
||||||
|
def __init__(self, docker_host, api_uri, http_port) :
|
||||||
|
super().__init__(Controller.Type.SWARM, api_uri=api_uri, lock=Lock(), http_port=http_port)
|
||||||
|
self.__client = docker.DockerClient(base_url=docker_host)
|
||||||
|
|
||||||
|
def __get_instances(self) :
|
||||||
|
return self.__client.services.list(filters={"label" : "bunkerized-nginx.AUTOCONF"})
|
||||||
|
|
||||||
|
def __get_services(self) :
|
||||||
|
return self.__client.services.list(filters={"label" : "bunkerized-nginx.SERVER_NAME"})
|
||||||
|
|
||||||
|
def get_env(self) :
|
||||||
|
env = {}
|
||||||
|
for instance in self.__get_instances() :
|
||||||
|
for variable in instance.attrs["Spec"]["TaskTemplate"]["ContainerSpec"]["Env"] :
|
||||||
|
env[variable.split("=")[0]] = variable.replace(variable.split("=")[0] + "=", "", 1)
|
||||||
|
first_servers = []
|
||||||
|
if "SERVER_NAME" in env and env["SERVER_NAME"] != "" :
|
||||||
|
first_servers = env["SERVER_NAME"].split(" ")
|
||||||
|
for service in self.__get_services() :
|
||||||
|
first_server = service.attrs["Spec"]["Labels"]["bunkerized-nginx.SERVER_NAME"].split(" ")[0]
|
||||||
|
first_servers.append(first_server)
|
||||||
|
for variable, value in service.attrs["Spec"]["Labels"].items() :
|
||||||
|
if variable.startswith("bunkerized-nginx.") and variable != "bunkerized-nginx.AUTOCONF" :
|
||||||
|
env[first_server + "_" + variable.replace("bunkerized-nginx.", "", 1)] = value
|
||||||
|
if len(first_servers) == 0 :
|
||||||
|
env["SERVER_NAME"] = ""
|
||||||
|
else :
|
||||||
|
env["SERVER_NAME"] = " ".join(first_servers)
|
||||||
|
return self._fix_env(env)
|
||||||
|
|
||||||
|
def process_events(self, current_env) :
|
||||||
|
old_env = current_env
|
||||||
|
# TODO : check why filter isn't working as expected
|
||||||
|
#for event in self.__client.events(decode=True, filters={"type": "service", "label": ["bunkerized-nginx.AUTOCONF", "bunkerized-nginx.SERVER_NAME"]}) :
|
||||||
|
for event in self.__client.events(decode=True, filters={"type": "service"}) :
|
||||||
|
new_env = self.get_env()
|
||||||
|
if new_env != old_env :
|
||||||
|
self.lock.acquire()
|
||||||
|
try :
|
||||||
|
log("controller", "INFO", "generating new configuration")
|
||||||
|
if self.gen_conf(new_env) :
|
||||||
|
old_env = new_env.copy()
|
||||||
|
log("controller", "INFO", "successfully generated new configuration")
|
||||||
|
if self.reload() :
|
||||||
|
log("controller", "INFO", "successful reload")
|
||||||
|
else :
|
||||||
|
log("controller", "ERROR", "failed reload")
|
||||||
|
else :
|
||||||
|
log("controller", "ERROR", "can't generate new configuration")
|
||||||
|
except :
|
||||||
|
log("controller", "ERROR", "exception while receiving event")
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
|
def reload(self) :
|
||||||
|
return self._reload(self.__get_instances())
|
||||||
|
|
||||||
|
def wait(self) :
|
||||||
|
self.lock.acquire()
|
||||||
|
try :
|
||||||
|
# Wait for a service
|
||||||
|
instances = self.__get_instances()
|
||||||
|
while len(instances) == 0 :
|
||||||
|
time.sleep(1)
|
||||||
|
instances = self.__get_instances()
|
||||||
|
# Generate first config
|
||||||
|
env = self.get_env()
|
||||||
|
if not self.gen_conf(env) :
|
||||||
|
self.lock.release()
|
||||||
|
return False, env
|
||||||
|
# Wait for nginx
|
||||||
|
self.lock.release()
|
||||||
|
return self._config.wait(instances), env
|
||||||
|
except :
|
||||||
|
pass
|
||||||
|
self.lock.release()
|
||||||
|
return False, {}
|
||||||
46
autoconf/src/app.py
Normal file
46
autoconf/src/app.py
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
from ReloadServer import run_reload_server
|
||||||
|
|
||||||
|
import docker, os, stat, sys, select, threading
|
||||||
|
|
||||||
|
from DockerController import DockerController
|
||||||
|
from SwarmController import SwarmController
|
||||||
|
from IngressController import IngressController
|
||||||
|
|
||||||
|
from logger import log
|
||||||
|
|
||||||
|
# Get variables
|
||||||
|
swarm = os.getenv("SWARM_MODE", "no") == "yes"
|
||||||
|
kubernetes = os.getenv("KUBERNETES_MODE", "no") == "yes"
|
||||||
|
api_uri = os.getenv("API_URI", "")
|
||||||
|
docker_host = os.getenv("DOCKER_HOST", "unix:///var/run/docker.sock")
|
||||||
|
http_port = os.getenv("HTTP_PORT", "8080")
|
||||||
|
|
||||||
|
# Instantiate the controller
|
||||||
|
if swarm :
|
||||||
|
log("autoconf", "INFO", "swarm mode detected")
|
||||||
|
controller = SwarmController(docker_host, api_uri, http_port)
|
||||||
|
elif kubernetes :
|
||||||
|
log("autoconf", "INFO", "kubernetes mode detected")
|
||||||
|
controller = IngressController(api_uri, http_port)
|
||||||
|
else :
|
||||||
|
log("autoconf", "INFO", "docker mode detected")
|
||||||
|
controller = DockerController(docker_host)
|
||||||
|
|
||||||
|
# Run the reload server in background if needed
|
||||||
|
if swarm or kubernetes :
|
||||||
|
log("autoconf", "INFO", "start reload server in background")
|
||||||
|
(server, thread) = run_reload_server(controller)
|
||||||
|
|
||||||
|
# Wait for instances
|
||||||
|
log("autoconf", "INFO", "wait until a bunkerized-nginx instance is started ...")
|
||||||
|
ret, env = controller.wait()
|
||||||
|
if ret :
|
||||||
|
log("autoconf", "INFO", "bunkerized-nginx instances started")
|
||||||
|
else :
|
||||||
|
log("autoconf", "ERROR", "bunkerized-nginx instances not started")
|
||||||
|
|
||||||
|
# Process events
|
||||||
|
log("autoconf", "INFO", "waiting for events ...")
|
||||||
|
controller.process_events(env)
|
||||||
6
autoconf/src/logger.py
Normal file
6
autoconf/src/logger.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import datetime
|
||||||
|
|
||||||
|
def log(title, severity, msg) :
|
||||||
|
when = datetime.datetime.today().strftime("[%Y-%m-%d %H:%M:%S]")
|
||||||
|
what = title + " - " + severity + " - " + msg
|
||||||
|
print(when + " " + what, flush=True)
|
||||||
135
compile.sh
135
compile.sh
@@ -1,135 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
function git_secure_checkout() {
|
|
||||||
path="$1"
|
|
||||||
commit="$2"
|
|
||||||
ret=$(pwd)
|
|
||||||
cd $path
|
|
||||||
git checkout "${commit}^{commit}"
|
|
||||||
if [ $? -ne 0 ] ; then
|
|
||||||
echo "[!] Commit hash $commit is absent from submodules $path !"
|
|
||||||
exit 3
|
|
||||||
fi
|
|
||||||
cd $ret
|
|
||||||
}
|
|
||||||
|
|
||||||
function git_secure_clone() {
|
|
||||||
repo="$1"
|
|
||||||
commit="$2"
|
|
||||||
folder=$(echo "$repo" | sed -E "s@https://github.com/.*/(.*)\.git@\1@")
|
|
||||||
git clone "$repo"
|
|
||||||
cd "$folder"
|
|
||||||
git checkout "${commit}^{commit}"
|
|
||||||
if [ $? -ne 0 ] ; then
|
|
||||||
echo "[!] Commit hash $commit is absent from repository $repo !"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
cd ..
|
|
||||||
}
|
|
||||||
|
|
||||||
NTASK=$(nproc)
|
|
||||||
|
|
||||||
# install build dependencies
|
|
||||||
apk add --no-cache --virtual build autoconf libtool automake git geoip-dev yajl-dev g++ curl-dev libxml2-dev pcre-dev make linux-headers libmaxminddb-dev musl-dev lua-dev gd-dev gnupg
|
|
||||||
|
|
||||||
# compile and install ModSecurity library
|
|
||||||
cd /tmp
|
|
||||||
git_secure_clone https://github.com/SpiderLabs/ModSecurity.git 753145fbd1d6751a6b14fdd700921eb3cc3a1d35
|
|
||||||
cd ModSecurity
|
|
||||||
./build.sh
|
|
||||||
git submodule init
|
|
||||||
git submodule update
|
|
||||||
git_secure_checkout bindings/python 47a6925df187f96e4593afab18dc92d5f22bd4d5
|
|
||||||
git_secure_checkout others/libinjection bf234eb2f385b969c4f803b35fda53cffdd93922
|
|
||||||
git_secure_checkout test/test-cases/secrules-language-tests d03f4c1e930440df46c1faa37d820a919704d9da
|
|
||||||
./configure --enable-static=no --disable-doxygen-doc --disable-dependency-tracking
|
|
||||||
make -j $NTASK
|
|
||||||
make install-strip
|
|
||||||
|
|
||||||
# download and install CRS rules
|
|
||||||
cd /tmp
|
|
||||||
git_secure_clone https://github.com/coreruleset/coreruleset.git 7776fe23f127fd2315bad0e400bdceb2cabb97dc
|
|
||||||
cd coreruleset
|
|
||||||
cp -r rules /etc/nginx/owasp-crs
|
|
||||||
cp crs-setup.conf.example /etc/nginx/owasp-crs.conf
|
|
||||||
|
|
||||||
# get nginx modules
|
|
||||||
cd /tmp
|
|
||||||
# ModSecurity connector for nginx
|
|
||||||
git_secure_clone https://github.com/SpiderLabs/ModSecurity-nginx.git 22e53aba4e3ae8c7d59a3672d6727e49246afe96
|
|
||||||
# headers more
|
|
||||||
git_secure_clone https://github.com/openresty/headers-more-nginx-module.git d6d7ebab3c0c5b32ab421ba186783d3e5d2c6a17
|
|
||||||
# geoip
|
|
||||||
git_secure_clone https://github.com/leev/ngx_http_geoip2_module.git 1cabd8a1f68ea3998f94e9f3504431970f848fbf
|
|
||||||
# cookie
|
|
||||||
git_secure_clone https://github.com/AirisX/nginx_cookie_flag_module.git c4ff449318474fbbb4ba5f40cb67ccd54dc595d4
|
|
||||||
|
|
||||||
# LUA requirements
|
|
||||||
git_secure_clone https://github.com/openresty/luajit2.git fe32831adcb3f5fe9259a9ce404fc54e1399bba3
|
|
||||||
cd luajit2
|
|
||||||
make -j $NTASK
|
|
||||||
make install
|
|
||||||
cd /tmp
|
|
||||||
git_secure_clone https://github.com/openresty/lua-resty-core.git b7d0a681bb41e6e3f29e8ddc438ef26fd819bb19
|
|
||||||
cd lua-resty-core
|
|
||||||
make install
|
|
||||||
cd /tmp
|
|
||||||
git_secure_clone https://github.com/openresty/lua-resty-lrucache.git b2035269ac353444ac65af3969692bcae4fc1605
|
|
||||||
cd lua-resty-lrucache
|
|
||||||
make install
|
|
||||||
cd /tmp
|
|
||||||
git_secure_clone https://github.com/openresty/lua-resty-dns.git 24c9a69808aedfaf029ae57707cdef75d83e2d19
|
|
||||||
cd lua-resty-dns
|
|
||||||
make install
|
|
||||||
cd /tmp
|
|
||||||
git_secure_clone https://github.com/bungle/lua-resty-session.git f300870ce4eee3f4903e0565c589f1faf0c1c5aa
|
|
||||||
cd lua-resty-session
|
|
||||||
cp -r lib/resty/* /usr/local/lib/lua/resty
|
|
||||||
cd /tmp
|
|
||||||
git_secure_clone https://github.com/bungle/lua-resty-random.git 17b604f7f7dd217557ca548fc1a9a0d373386480
|
|
||||||
cd lua-resty-random
|
|
||||||
make install
|
|
||||||
cd /tmp
|
|
||||||
git_secure_clone https://github.com/openresty/lua-resty-string.git 9a543f8531241745f8814e8e02475351042774ec
|
|
||||||
cd lua-resty-string
|
|
||||||
make install
|
|
||||||
cd /tmp
|
|
||||||
git_secure_clone https://github.com/openresty/lua-cjson.git 0df488874f52a881d14b5876babaa780bb6200ee
|
|
||||||
cd lua-cjson
|
|
||||||
make -j $NTASK
|
|
||||||
make install
|
|
||||||
make install-extra
|
|
||||||
cd /tmp
|
|
||||||
git_secure_clone https://github.com/ittner/lua-gd.git 2ce8e478a8591afd71e607506bc8c64b161bbd30
|
|
||||||
cd lua-gd
|
|
||||||
make -j $NTASK
|
|
||||||
make INSTALL_PATH=/usr/local/lib/lua/5.1 install
|
|
||||||
cd /tmp
|
|
||||||
git_secure_clone https://github.com/ledgetech/lua-resty-http.git 984fdc26054376384e3df238fb0f7dfde01cacf1
|
|
||||||
cd lua-resty-http
|
|
||||||
make install
|
|
||||||
cd /tmp
|
|
||||||
git_secure_clone https://github.com/openresty/lua-nginx-module.git 2d23bc4f0a29ed79aaaa754c11bffb1080aa44ba
|
|
||||||
export LUAJIT_LIB=/usr/local/lib
|
|
||||||
export LUAJIT_INC=/usr/local/include/luajit-2.1
|
|
||||||
|
|
||||||
# compile and install dynamic modules
|
|
||||||
cd /tmp
|
|
||||||
wget https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
|
|
||||||
wget https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz.asc
|
|
||||||
gpg --import /tmp/nginx-keys/*.key
|
|
||||||
check=$(gpg --verify /tmp/nginx-${NGINX_VERSION}.tar.gz.asc /tmp/nginx-${NGINX_VERSION}.tar.gz 2>&1 | grep "^gpg: Good signature from ")
|
|
||||||
if [ "$check" = "" ] ; then
|
|
||||||
echo "[!] Wrong signature from nginx source !"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
tar -xvzf nginx-${NGINX_VERSION}.tar.gz
|
|
||||||
cd nginx-$NGINX_VERSION
|
|
||||||
CONFARGS=$(nginx -V 2>&1 | sed -n -e 's/^.*arguments: //p')
|
|
||||||
CONFARGS=${CONFARGS/-Os -fomit-frame-pointer/-Os}
|
|
||||||
./configure $CONFARGS --add-dynamic-module=/tmp/ModSecurity-nginx --add-dynamic-module=/tmp/headers-more-nginx-module --add-dynamic-module=/tmp/ngx_http_geoip2_module --add-dynamic-module=/tmp/nginx_cookie_flag_module --add-dynamic-module=/tmp/lua-nginx-module
|
|
||||||
make -j $NTASK modules
|
|
||||||
cp ./objs/*.so /usr/lib/nginx/modules
|
|
||||||
|
|
||||||
# remove build dependencies
|
|
||||||
apk del build
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
auth_basic "%AUTH_BASIC_TEXT%";
|
|
||||||
auth_basic_user_file /etc/nginx/.htpasswd;
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
location %AUTH_BASIC_LOCATION% {
|
|
||||||
auth_basic "%AUTH_BASIC_TEXT%";
|
|
||||||
auth_basic_user_file /etc/nginx/.htpasswd;
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
if ($bad_user_agent = yes) {
|
|
||||||
return 444;
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
open_file_cache %CACHE%;
|
|
||||||
open_file_cache_errors %CACHE_ERRORS%;
|
|
||||||
open_file_cache_min_uses %CACHE_USES%;
|
|
||||||
open_file_cache_valid %CACHE_VALID%;
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
more_set_headers "Content-Security-Policy: %CONTENT_SECURITY_POLICY%";
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
set_cookie_flag %COOKIE_FLAGS%;
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
listen 0.0.0.0:443 ssl %HTTP2%;
|
|
||||||
ssl_certificate %HTTPS_CUSTOM_CERT%;
|
|
||||||
ssl_certificate_key %HTTPS_CUSTOM_KEY%;
|
|
||||||
ssl_protocols TLSv1.3;
|
|
||||||
ssl_prefer_server_ciphers off;
|
|
||||||
ssl_session_tickets off;
|
|
||||||
%STRICT_TRANSPORT_SECURITY%
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
if ($host !~ ^(%SERVER_NAME%)$) {
|
|
||||||
return 444;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
error_page %CODE% %PAGE%;
|
|
||||||
|
|
||||||
location = %PAGE% {
|
|
||||||
root %ROOT_FOLDER%;
|
|
||||||
modsecurity off;
|
|
||||||
internal;
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
more_set_headers "Feature-Policy: %FEATURE_POLICY%";
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
if ($allowed_country = no) {
|
|
||||||
return 444;
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
geoip2 /etc/nginx/geoip.mmdb {
|
|
||||||
auto_reload 5m;
|
|
||||||
$geoip2_metadata_country_build metadata build_epoch;
|
|
||||||
$geoip2_data_country_code country iso_code;
|
|
||||||
}
|
|
||||||
|
|
||||||
map $geoip2_data_country_code $allowed_country {
|
|
||||||
default yes;
|
|
||||||
%BLOCK_COUNTRY%
|
|
||||||
}
|
|
||||||
31
confs/global/api-temp.conf
Normal file
31
confs/global/api-temp.conf
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
location ~ ^%API_URI%/ping {
|
||||||
|
return 444;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ %API_URI% {
|
||||||
|
|
||||||
|
rewrite_by_lua_block {
|
||||||
|
|
||||||
|
local api = require "api"
|
||||||
|
local api_whitelist_ip = { %API_WHITELIST_IP% }
|
||||||
|
local api_uri = "%API_URI%"
|
||||||
|
local logger = require "logger"
|
||||||
|
|
||||||
|
if api.is_api_call(api_uri, api_whitelist_ip) then
|
||||||
|
ngx.header.content_type = 'text/plain'
|
||||||
|
if api.do_api_call(api_uri) then
|
||||||
|
logger.log(ngx.NOTICE, "API", "API call " .. ngx.var.request_uri .. " successfull from " .. ngx.var.remote_addr)
|
||||||
|
ngx.say("ok")
|
||||||
|
else
|
||||||
|
logger.log(ngx.WARN, "API", "API call " .. ngx.var.request_uri .. " failed from " .. ngx.var.remote_addr)
|
||||||
|
ngx.say("ko")
|
||||||
|
end
|
||||||
|
|
||||||
|
ngx.exit(ngx.HTTP_OK)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
ngx.exit(ngx.OK)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
24
confs/global/api.conf
Normal file
24
confs/global/api.conf
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# todo : if api_uri == "random"
|
||||||
|
rewrite_by_lua_block {
|
||||||
|
|
||||||
|
local api = require "api"
|
||||||
|
local api_whitelist_ip = {% raw %}{{% endraw %}{% if API_WHITELIST_IP != ""%}{% set elements = API_WHITELIST_IP.split(" ") %}{% for i in range(0, elements|length) %}"{{ elements[i] }}"{% if i < elements|length-1 %},{% endif %}{% endfor %}{% endif %}{% raw %}}{% endraw +%}
|
||||||
|
local api_uri = "{{ API_URI }}"
|
||||||
|
local logger = require "logger"
|
||||||
|
|
||||||
|
if api.is_api_call(api_uri, api_whitelist_ip) then
|
||||||
|
ngx.header.content_type = 'text/plain'
|
||||||
|
if api.do_api_call(api_uri) then
|
||||||
|
logger.log(ngx.NOTICE, "API", "API call " .. ngx.var.request_uri .. " successfull from " .. ngx.var.remote_addr)
|
||||||
|
ngx.print("ok")
|
||||||
|
else
|
||||||
|
logger.log(ngx.WARN, "API", "API call " .. ngx.var.request_uri .. " failed from " .. ngx.var.remote_addr)
|
||||||
|
ngx.print("ko")
|
||||||
|
end
|
||||||
|
|
||||||
|
ngx.exit(ngx.HTTP_OK)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
ngx.exit(ngx.OK)
|
||||||
|
}
|
||||||
5
confs/global/crowdsec.conf
Normal file
5
confs/global/crowdsec.conf
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
API_URL={{ CROWDSEC_HOST }}
|
||||||
|
API_KEY={{ CROWDSEC_KEY }}
|
||||||
|
LOG_FILE=/tmp/lua_mod.log
|
||||||
|
CACHE_EXPIRATION=1
|
||||||
|
CACHE_SIZE=1000
|
||||||
8
confs/global/dhparam
Normal file
8
confs/global/dhparam
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-----
|
||||||
25
confs/global/fastcgi.conf
Normal file
25
confs/global/fastcgi.conf
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
fastcgi_param QUERY_STRING $query_string;
|
||||||
|
fastcgi_param REQUEST_METHOD $request_method;
|
||||||
|
fastcgi_param CONTENT_TYPE $content_type;
|
||||||
|
fastcgi_param CONTENT_LENGTH $content_length;
|
||||||
|
|
||||||
|
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
|
||||||
|
fastcgi_param REQUEST_URI $request_uri;
|
||||||
|
fastcgi_param DOCUMENT_URI $document_uri;
|
||||||
|
fastcgi_param DOCUMENT_ROOT $document_root;
|
||||||
|
fastcgi_param SERVER_PROTOCOL $server_protocol;
|
||||||
|
fastcgi_param REQUEST_SCHEME $scheme;
|
||||||
|
fastcgi_param HTTPS $https if_not_empty;
|
||||||
|
|
||||||
|
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
|
||||||
|
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
|
||||||
|
|
||||||
|
fastcgi_param REMOTE_ADDR $remote_addr;
|
||||||
|
fastcgi_param REMOTE_PORT $remote_port;
|
||||||
|
fastcgi_param SERVER_ADDR $server_addr;
|
||||||
|
fastcgi_param SERVER_PORT $server_port;
|
||||||
|
fastcgi_param SERVER_NAME $server_name;
|
||||||
|
|
||||||
|
# PHP only, required if PHP was built with --enable-force-cgi-redirect
|
||||||
|
fastcgi_param REDIRECT_STATUS 200;
|
||||||
19
confs/global/geoip.conf
Normal file
19
confs/global/geoip.conf
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
geoip2 /etc/nginx/geoip.mmdb {
|
||||||
|
auto_reload 5m;
|
||||||
|
$geoip2_metadata_country_build metadata build_epoch;
|
||||||
|
$geoip2_data_country_code country iso_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
map $geoip2_data_country_code $allowed_country {
|
||||||
|
default {% if WHITELIST_COUNTRY != "" %}no{% else %}yes{% endif +%};
|
||||||
|
{% if WHITELIST_COUNTRY != "" %}
|
||||||
|
{% for country in WHITELIST_COUNTRY.split(" ") +%}
|
||||||
|
{{ country }} yes;
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% if BLACKLIST_COUNTRY != "" %}
|
||||||
|
{% for country in BLACKLIST_COUNTRY.split(" ") +%}
|
||||||
|
{{ country }} no;
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
}
|
||||||
75
confs/global/init-lua.conf
Normal file
75
confs/global/init-lua.conf
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
init_by_lua_block {
|
||||||
|
|
||||||
|
local dataloader = require "dataloader"
|
||||||
|
local logger = require "logger"
|
||||||
|
local cjson = require "cjson"
|
||||||
|
|
||||||
|
local use_redis = {% if USE_REDIS == "yes" %}true{% else %}false{% endif +%}
|
||||||
|
|
||||||
|
local use_proxies = {% if has_value("BLOCK_PROXIES", "yes") %}true{% else %}false{% endif +%}
|
||||||
|
local use_abusers = {% if has_value("BLOCK_ABUSERS", "yes") %}true{% else %}false{% endif +%}
|
||||||
|
local use_tor_exit_nodes = {% if has_value("BLOCK_TOR_EXIT_NODE", "yes") %}true{% else %}false{% endif +%}
|
||||||
|
local use_user_agents = {% if has_value("BLOCK_USER_AGENT", "yes") %}true{% else %}false{% endif +%}
|
||||||
|
local use_referrers = {% if has_value("BLOCK_REFERRER", "yes") %}true{% else %}false{% endif +%}
|
||||||
|
|
||||||
|
if not use_redis then
|
||||||
|
if use_proxies then
|
||||||
|
dataloader.load_ip("/etc/nginx/proxies.list", ngx.shared.proxies_data)
|
||||||
|
end
|
||||||
|
|
||||||
|
if use_abusers then
|
||||||
|
dataloader.load_ip("/etc/nginx/abusers.list", ngx.shared.abusers_data)
|
||||||
|
end
|
||||||
|
|
||||||
|
if use_tor_exit_nodes then
|
||||||
|
dataloader.load_ip("/etc/nginx/tor-exit-nodes.list", ngx.shared.tor_exit_nodes_data)
|
||||||
|
end
|
||||||
|
|
||||||
|
if use_user_agents then
|
||||||
|
dataloader.load_raw("/etc/nginx/user-agents.list", ngx.shared.user_agents_data)
|
||||||
|
end
|
||||||
|
|
||||||
|
if use_referrers then
|
||||||
|
dataloader.load_raw("/etc/nginx/referrers.list", ngx.shared.referrers_data)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Load plugins
|
||||||
|
ngx.shared.plugins_data:safe_set("plugins", nil, 0)
|
||||||
|
local p = io.popen("find /opt/bunkerized-nginx/plugins -maxdepth 1 -type d ! -path /opt/bunkerized-nginx/plugins")
|
||||||
|
for dir in p:lines() do
|
||||||
|
-- read JSON
|
||||||
|
local file = io.open(dir .. "/plugin.json")
|
||||||
|
if file then
|
||||||
|
-- store settings
|
||||||
|
local data = cjson.decode(file:read("*a"))
|
||||||
|
for k, v in pairs(data.settings) do
|
||||||
|
ngx.shared.plugins_data:safe_set(data.id .. "_" .. k, v, 0)
|
||||||
|
end
|
||||||
|
file:close()
|
||||||
|
-- call init
|
||||||
|
local plugin = require(data.id .. "/" .. data.id)
|
||||||
|
local init = true
|
||||||
|
if plugin["init"] ~= nil then
|
||||||
|
init = plugin.init()
|
||||||
|
end
|
||||||
|
-- store plugin
|
||||||
|
if init then
|
||||||
|
local plugins, flags = ngx.shared.plugins_data:get("plugins")
|
||||||
|
if plugins == nil then
|
||||||
|
ngx.shared.plugins_data:safe_set("plugins", data.id, 0)
|
||||||
|
else
|
||||||
|
ngx.shared.plugins_data:safe_set("plugins", plugins .. " " .. data.id, 0)
|
||||||
|
end
|
||||||
|
logger.log(ngx.ERR, "PLUGINS", "*NOT AN ERROR* plugin " .. data.name .. "/" .. data.version .. " has been loaded")
|
||||||
|
else
|
||||||
|
logger.log(ngx.ERR, "PLUGINS", "init failed for plugin " .. data.name .. "/" .. data.version)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
logger.log(ngx.ERR, "PLUGINS", "Can't load " .. dir .. "/plugin.json")
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
p:close()
|
||||||
|
|
||||||
|
}
|
||||||
96
confs/global/mime-types.conf
Normal file
96
confs/global/mime-types.conf
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
types {
|
||||||
|
text/html html htm shtml;
|
||||||
|
text/css css;
|
||||||
|
text/xml xml;
|
||||||
|
image/gif gif;
|
||||||
|
image/jpeg jpeg jpg;
|
||||||
|
application/javascript js;
|
||||||
|
application/atom+xml atom;
|
||||||
|
application/rss+xml rss;
|
||||||
|
|
||||||
|
text/mathml mml;
|
||||||
|
text/plain txt;
|
||||||
|
text/vnd.sun.j2me.app-descriptor jad;
|
||||||
|
text/vnd.wap.wml wml;
|
||||||
|
text/x-component htc;
|
||||||
|
|
||||||
|
image/png png;
|
||||||
|
image/svg+xml svg svgz;
|
||||||
|
image/tiff tif tiff;
|
||||||
|
image/vnd.wap.wbmp wbmp;
|
||||||
|
image/webp webp;
|
||||||
|
image/x-icon ico;
|
||||||
|
image/x-jng jng;
|
||||||
|
image/x-ms-bmp bmp;
|
||||||
|
|
||||||
|
font/woff woff;
|
||||||
|
font/woff2 woff2;
|
||||||
|
|
||||||
|
application/java-archive jar war ear;
|
||||||
|
application/json json;
|
||||||
|
application/mac-binhex40 hqx;
|
||||||
|
application/msword doc;
|
||||||
|
application/pdf pdf;
|
||||||
|
application/postscript ps eps ai;
|
||||||
|
application/rtf rtf;
|
||||||
|
application/vnd.apple.mpegurl m3u8;
|
||||||
|
application/vnd.google-earth.kml+xml kml;
|
||||||
|
application/vnd.google-earth.kmz kmz;
|
||||||
|
application/vnd.ms-excel xls;
|
||||||
|
application/vnd.ms-fontobject eot;
|
||||||
|
application/vnd.ms-powerpoint ppt;
|
||||||
|
application/vnd.oasis.opendocument.graphics odg;
|
||||||
|
application/vnd.oasis.opendocument.presentation odp;
|
||||||
|
application/vnd.oasis.opendocument.spreadsheet ods;
|
||||||
|
application/vnd.oasis.opendocument.text odt;
|
||||||
|
application/vnd.openxmlformats-officedocument.presentationml.presentation
|
||||||
|
pptx;
|
||||||
|
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
|
||||||
|
xlsx;
|
||||||
|
application/vnd.openxmlformats-officedocument.wordprocessingml.document
|
||||||
|
docx;
|
||||||
|
application/vnd.wap.wmlc wmlc;
|
||||||
|
application/x-7z-compressed 7z;
|
||||||
|
application/x-cocoa cco;
|
||||||
|
application/x-java-archive-diff jardiff;
|
||||||
|
application/x-java-jnlp-file jnlp;
|
||||||
|
application/x-makeself run;
|
||||||
|
application/x-perl pl pm;
|
||||||
|
application/x-pilot prc pdb;
|
||||||
|
application/x-rar-compressed rar;
|
||||||
|
application/x-redhat-package-manager rpm;
|
||||||
|
application/x-sea sea;
|
||||||
|
application/x-shockwave-flash swf;
|
||||||
|
application/x-stuffit sit;
|
||||||
|
application/x-tcl tcl tk;
|
||||||
|
application/x-x509-ca-cert der pem crt;
|
||||||
|
application/x-xpinstall xpi;
|
||||||
|
application/xhtml+xml xhtml;
|
||||||
|
application/xspf+xml xspf;
|
||||||
|
application/zip zip;
|
||||||
|
|
||||||
|
application/octet-stream bin exe dll;
|
||||||
|
application/octet-stream deb;
|
||||||
|
application/octet-stream dmg;
|
||||||
|
application/octet-stream iso img;
|
||||||
|
application/octet-stream msi msp msm;
|
||||||
|
|
||||||
|
audio/midi mid midi kar;
|
||||||
|
audio/mpeg mp3;
|
||||||
|
audio/ogg ogg;
|
||||||
|
audio/x-m4a m4a;
|
||||||
|
audio/x-realaudio ra;
|
||||||
|
|
||||||
|
video/3gpp 3gpp 3gp;
|
||||||
|
video/mp2t ts;
|
||||||
|
video/mp4 mp4;
|
||||||
|
video/mpeg mpeg mpg;
|
||||||
|
video/quicktime mov;
|
||||||
|
video/webm webm;
|
||||||
|
video/x-flv flv;
|
||||||
|
video/x-m4v m4v;
|
||||||
|
video/x-mng mng;
|
||||||
|
video/x-ms-asf asx asf;
|
||||||
|
video/x-ms-wmv wmv;
|
||||||
|
video/x-msvideo avi;
|
||||||
|
}
|
||||||
12
confs/global/multisite-default-server-https.conf
Normal file
12
confs/global/multisite-default-server-https.conf
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
listen 0.0.0.0:{{ HTTPS_PORT }} default_server ssl {% if USE_HTTP2 == "yes" %}http2{% endif %};
|
||||||
|
ssl_certificate /etc/nginx/default-cert.pem;
|
||||||
|
ssl_certificate_key /etc/nginx/default-key.pem;
|
||||||
|
ssl_protocols {{ HTTPS_PROTOCOLS }};
|
||||||
|
ssl_prefer_server_ciphers off;
|
||||||
|
ssl_session_tickets off;
|
||||||
|
ssl_session_timeout 1d;
|
||||||
|
ssl_session_cache shared:MozSSL:10m;
|
||||||
|
{% if "TLSv1.2" in HTTPS_PROTOCOLS +%}
|
||||||
|
ssl_dhparam /etc/nginx/dhparam;
|
||||||
|
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;
|
||||||
|
{% endif +%}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
location ~ ^/.well-known/acme-challenge/ {
|
||||||
|
root /opt/bunkerized-nginx/acme-challenge;
|
||||||
|
}
|
||||||
12
confs/global/multisite-default-server.conf
Normal file
12
confs/global/multisite-default-server.conf
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
server {
|
||||||
|
{% if LISTEN_HTTP == "yes" %}listen 0.0.0.0:{{ HTTP_PORT }} default_server;{% endif +%}
|
||||||
|
server_name _;
|
||||||
|
{% if has_value("AUTO_LETS_ENCRYPT", "yes") %}include /etc/nginx/multisite-default-server-https.conf;{% endif +%}
|
||||||
|
include /etc/nginx/multisite-default-server-lets-encrypt-webroot.conf;
|
||||||
|
{% if USE_API == "yes" %}
|
||||||
|
location ^~ {{ API_URI }} {
|
||||||
|
include /etc/nginx/api.conf;
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
|
{% if DISABLE_DEFAULT_SERVER == "yes" %}include /etc/nginx/multisite-disable-default-server.conf;{% endif +%}
|
||||||
|
}
|
||||||
3
confs/global/multisite-disable-default-server.conf
Normal file
3
confs/global/multisite-disable-default-server.conf
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
location / {
|
||||||
|
return 444;
|
||||||
|
}
|
||||||
31
confs/global/nginx-temp.conf
Normal file
31
confs/global/nginx-temp.conf
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
load_module /usr/lib/nginx/modules/ngx_http_lua_module.so;
|
||||||
|
|
||||||
|
daemon on;
|
||||||
|
|
||||||
|
pid /tmp/nginx-temp.pid;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
use epoll;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
proxy_temp_path /tmp/proxy_temp;
|
||||||
|
client_body_temp_path /tmp/client_temp;
|
||||||
|
fastcgi_temp_path /tmp/fastcgi_temp;
|
||||||
|
uwsgi_temp_path /tmp/uwsgi_temp;
|
||||||
|
scgi_temp_path /tmp/scgi_temp;
|
||||||
|
lua_package_path "/opt/bunkerized-nginx/lua/?.lua;/opt/bunkerized-nginx/plugins/?.lua;/opt/bunkerized-nginx/deps/lib/lua/?.lua;;";
|
||||||
|
lua_package_cpath "/opt/bunkerized-nginx/deps/lib/?.so;/opt/bunkerized-nginx/deps/lib/lua/?.so;;";
|
||||||
|
server {
|
||||||
|
listen 0.0.0.0:%HTTP_PORT% default_server;
|
||||||
|
server_name _;
|
||||||
|
location ~ ^/.well-known/acme-challenge/ {
|
||||||
|
root /opt/bunkerized-nginx/acme-challenge;
|
||||||
|
}
|
||||||
|
%USE_API%
|
||||||
|
location / {
|
||||||
|
return 444;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
146
confs/global/nginx.conf
Normal file
146
confs/global/nginx.conf
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
# /etc/nginx/nginx.conf
|
||||||
|
|
||||||
|
# load dynamic modules
|
||||||
|
load_module /usr/lib/nginx/modules/ngx_http_cookie_flag_filter_module.so;
|
||||||
|
load_module /usr/lib/nginx/modules/ngx_http_geoip2_module.so;
|
||||||
|
load_module /usr/lib/nginx/modules/ngx_http_headers_more_filter_module.so;
|
||||||
|
load_module /usr/lib/nginx/modules/ngx_http_lua_module.so;
|
||||||
|
load_module /usr/lib/nginx/modules/ngx_http_modsecurity_module.so;
|
||||||
|
load_module /usr/lib/nginx/modules/ngx_http_brotli_filter_module.so;
|
||||||
|
load_module /usr/lib/nginx/modules/ngx_http_brotli_static_module.so;
|
||||||
|
|
||||||
|
# PID file
|
||||||
|
pid /tmp/nginx.pid;
|
||||||
|
|
||||||
|
# worker number (default = auto)
|
||||||
|
worker_processes {{ WORKER_PROCESSES }};
|
||||||
|
|
||||||
|
# faster regexp
|
||||||
|
pcre_jit on;
|
||||||
|
|
||||||
|
# config files for dynamic modules
|
||||||
|
include /etc/nginx/modules/*.conf;
|
||||||
|
|
||||||
|
# max open files for each worker
|
||||||
|
worker_rlimit_nofile {{ WORKER_RLIMIT_NOFILE }};
|
||||||
|
|
||||||
|
events {
|
||||||
|
# max connections per worker
|
||||||
|
worker_connections {{ WORKER_CONNECTIONS }};
|
||||||
|
|
||||||
|
# epoll seems to be the best on Linux
|
||||||
|
use epoll;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
# zero copy within the kernel
|
||||||
|
sendfile on;
|
||||||
|
|
||||||
|
# send packets only if filled
|
||||||
|
tcp_nopush on;
|
||||||
|
|
||||||
|
# remove 200ms delay
|
||||||
|
tcp_nodelay on;
|
||||||
|
|
||||||
|
# load mime types and set default one
|
||||||
|
include /etc/nginx/mime-types.conf;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
|
||||||
|
# write logs to local syslog
|
||||||
|
log_format logf '{{ LOG_FORMAT }}';
|
||||||
|
access_log /var/log/nginx/access.log logf;
|
||||||
|
error_log /var/log/nginx/error.log {{ LOG_LEVEL }};
|
||||||
|
|
||||||
|
# temp paths
|
||||||
|
proxy_temp_path /tmp/proxy_temp;
|
||||||
|
client_body_temp_path /tmp/client_temp;
|
||||||
|
fastcgi_temp_path /tmp/fastcgi_temp;
|
||||||
|
uwsgi_temp_path /tmp/uwsgi_temp;
|
||||||
|
scgi_temp_path /tmp/scgi_temp;
|
||||||
|
|
||||||
|
# close connections in FIN_WAIT1 state
|
||||||
|
reset_timedout_connection on;
|
||||||
|
|
||||||
|
# timeouts
|
||||||
|
client_body_timeout 10;
|
||||||
|
client_header_timeout 10;
|
||||||
|
keepalive_timeout 15;
|
||||||
|
send_timeout 10;
|
||||||
|
|
||||||
|
# resolvers to use
|
||||||
|
resolver {{ DNS_RESOLVERS }} ipv6=off;
|
||||||
|
|
||||||
|
# remove ports when sending redirects
|
||||||
|
port_in_redirect off;
|
||||||
|
|
||||||
|
# lua path and dicts
|
||||||
|
lua_package_path "/opt/bunkerized-nginx/lua/?.lua;/opt/bunkerized-nginx/plugins/?.lua;/opt/bunkerized-nginx/deps/lib/lua/?.lua;;";
|
||||||
|
lua_package_cpath "/opt/bunkerized-nginx/deps/lib/?.so;/opt/bunkerized-nginx/deps/lib/lua/?.so;;";
|
||||||
|
{% if has_value("USE_WHITELIST_IP", "yes") %}lua_shared_dict whitelist_ip_cache 10m;{% endif +%}
|
||||||
|
{% if has_value("USE_WHITELIST_REVERSE", "yes") %}lua_shared_dict whitelist_reverse_cache 10m;{% endif +%}
|
||||||
|
{% if has_value("USE_BLACKLIST_IP", "yes") %}lua_shared_dict blacklist_ip_cache 10m;{% endif +%}
|
||||||
|
{% if has_value("USE_BLACKLIST_REVERSE", "yes") %}lua_shared_dict blacklist_reverse_cache 10m;{% endif +%}
|
||||||
|
{% if has_value("USE_DNSBL", "yes") %}lua_shared_dict dnsbl_cache 10m;{% endif +%}
|
||||||
|
{% if has_value("BLOCK_PROXIES", "yes") %}lua_shared_dict proxies_data 250m;{% endif +%}
|
||||||
|
{% if has_value("BLOCK_ABUSERS", "yes") %}lua_shared_dict abusers_data 50m;{% endif +%}
|
||||||
|
{% if has_value("BLOCK_TOR_EXIT_NODE", "yes") %}lua_shared_dict tor_exit_nodes_data 1m;{% endif +%}
|
||||||
|
{% if has_value("BLOCK_USER_AGENT", "yes") %}lua_shared_dict user_agents_data 1m;{% endif +%}
|
||||||
|
{% if has_value("BLOCK_USER_AGENT", "yes") %}lua_shared_dict user_agents_cache 10m;{% endif +%}
|
||||||
|
{% if has_value("BLOCK_REFERRER", "yes") %}lua_shared_dict referrers_data 1m;{% endif +%}
|
||||||
|
{% if has_value("BLOCK_REFERRER", "yes") %}lua_shared_dict referrers_cache 10m;{% endif +%}
|
||||||
|
{% if has_value("USE_BAD_BEHAVIOR", "yes") %}lua_shared_dict behavior_ban 10m;{% endif +%}
|
||||||
|
{% if has_value("USE_BAD_BEHAVIOR", "yes") %}lua_shared_dict behavior_count 10m;{% endif +%}
|
||||||
|
lua_shared_dict plugins_data 10m;
|
||||||
|
|
||||||
|
# shared memory zone for limit_req
|
||||||
|
{% if has_value("USE_LIMIT_REQ", "yes") %}limit_req_zone $binary_remote_addr$uri zone=limit:{{ LIMIT_REQ_CACHE }} rate={{ LIMIT_REQ_RATE }};{% endif +%}
|
||||||
|
|
||||||
|
# shared memory zone for limit_conn
|
||||||
|
{% if has_value("USE_LIMIT_CONN", "yes") %}limit_conn_zone $binary_remote_addr zone=ddos:{{ LIMIT_CONN_CACHE }};{% endif +%}
|
||||||
|
|
||||||
|
# whitelist or blacklist country
|
||||||
|
{% if BLACKLIST_COUNTRY != "" or WHITELIST_COUNTRY != "" %}include /etc/nginx/geoip.conf;{% endif +%}
|
||||||
|
|
||||||
|
# zone for proxy_cache
|
||||||
|
{% if has_value("USE_PROXY_CACHE", "yes") %}proxy_cache_path /tmp/proxy_cache keys_zone=proxycache:{{ PROXY_CACHE_PATH_ZONE_SIZE }} {{ PROXY_CACHE_PATH_PARAMS }};{% endif +%}
|
||||||
|
|
||||||
|
# custom http confs
|
||||||
|
include /opt/bunkerized-nginx/http-confs/*.conf;
|
||||||
|
|
||||||
|
# LUA init block
|
||||||
|
include /etc/nginx/init-lua.conf;
|
||||||
|
|
||||||
|
# default server when MULTISITE=yes
|
||||||
|
{% if MULTISITE == "yes" %}include /etc/nginx/multisite-default-server.conf;{% endif +%}
|
||||||
|
|
||||||
|
# server config(s)
|
||||||
|
{% if MULTISITE == "yes" and SERVER_NAME != "" %}
|
||||||
|
{% set map_servers = {} %}
|
||||||
|
{% for server_name in SERVER_NAME.split(" ") %}
|
||||||
|
{% if server_name + "_SERVER_NAME" in all %}
|
||||||
|
{% set x = map_servers.update({server_name : all[server_name + "_SERVER_NAME"].split(" ")}) %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% for server_name in SERVER_NAME.split(" ") %}
|
||||||
|
{% if not server_name in map_servers %}
|
||||||
|
{% set found = {"res": false} %}
|
||||||
|
{% for first_server, servers in map_servers.items() %}
|
||||||
|
{% if server_name in servers %}
|
||||||
|
{% set x = found.update({"res" : true}) %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% if not found["res"] %}
|
||||||
|
{% set x = map_servers.update({server_name : [server_name]}) %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% for first_server in map_servers +%}
|
||||||
|
include /etc/nginx/{{ first_server }}/server.conf;
|
||||||
|
{% endfor %}
|
||||||
|
{% elif MULTISITE == "no" +%}
|
||||||
|
include /etc/nginx/server.conf;
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
# API
|
||||||
|
{% if USE_API == "yes" %}include /etc/nginx/api.conf;{% endif +%}
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
# /etc/nginx/gzip.conf
|
|
||||||
|
|
||||||
# enable/disable gzip compression
|
|
||||||
gzip %USE_GZIP%;
|
|
||||||
gzip_comp_level %GZIP_COMP_LEVEL%;
|
|
||||||
gzip_disable msie6;
|
|
||||||
gzip_min_length %GZIP_MIN_LENGTH%;
|
|
||||||
gzip_proxied any;
|
|
||||||
gzip_types %GZIP_TYPES%;
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
listen 0.0.0.0:8443 ssl %HTTP2%;
|
|
||||||
ssl_certificate %HTTPS_CERT%;
|
|
||||||
ssl_certificate_key %HTTPS_KEY%;
|
|
||||||
ssl_protocols TLSv1.3;
|
|
||||||
ssl_prefer_server_ciphers off;
|
|
||||||
ssl_session_tickets off;
|
|
||||||
%STRICT_TRANSPORT_SECURITY%
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
limit_req_status 429;
|
|
||||||
limit_req zone=limit burst=%LIMIT_REQ_BURST% nodelay;
|
|
||||||
|
|
||||||
@@ -1,137 +0,0 @@
|
|||||||
set $session_secret %ANTIBOT_SESSION_SECRET%;
|
|
||||||
set $session_check_addr on;
|
|
||||||
|
|
||||||
access_by_lua_block {
|
|
||||||
|
|
||||||
local use_whitelist_ip = %USE_WHITELIST_IP%
|
|
||||||
local use_whitelist_reverse = %USE_WHITELIST_REVERSE%
|
|
||||||
local use_blacklist_ip = %USE_BLACKLIST_IP%
|
|
||||||
local use_blacklist_reverse = %USE_BLACKLIST_REVERSE%
|
|
||||||
local use_dnsbl = %USE_DNSBL%
|
|
||||||
local use_antibot_cookie = %USE_ANTIBOT_COOKIE%
|
|
||||||
local use_antibot_javascript = %USE_ANTIBOT_JAVASCRIPT%
|
|
||||||
local use_antibot_captcha = %USE_ANTIBOT_CAPTCHA%
|
|
||||||
local use_antibot_recaptcha = %USE_ANTIBOT_RECAPTCHA%
|
|
||||||
|
|
||||||
-- include LUA code
|
|
||||||
local whitelist = require "whitelist"
|
|
||||||
local blacklist = require "blacklist"
|
|
||||||
local dnsbl = require "dnsbl"
|
|
||||||
local cookie = require "cookie"
|
|
||||||
local javascript = require "javascript"
|
|
||||||
local captcha = require "captcha"
|
|
||||||
local recaptcha = require "recaptcha"
|
|
||||||
|
|
||||||
-- antibot
|
|
||||||
local antibot_uri = "%ANTIBOT_URI%"
|
|
||||||
|
|
||||||
-- check if already in whitelist cache
|
|
||||||
if use_whitelist_ip and whitelist.ip_cached_ok() then
|
|
||||||
ngx.exit(ngx.OK)
|
|
||||||
end
|
|
||||||
if use_whitelist_reverse and whitelist.reverse_cached_ok() then
|
|
||||||
ngx.exit(ngx.OK)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- check if already in blacklist cache
|
|
||||||
if use_blacklist_ip and blacklist.ip_cached_ko() then
|
|
||||||
ngx.exit(ngx.HTTP_FORBIDDEN)
|
|
||||||
end
|
|
||||||
if use_blacklist_reverse and blacklist.reverse_cached_ko() then
|
|
||||||
ngx.exit(ngx.HTTP_FORBIDDEN)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- check if already in dnsbl cache
|
|
||||||
if use_dnsbl and dnsbl.cached_ko() then
|
|
||||||
ngx.exit(ngx.HTTP_FORBIDDEN)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- check if IP is whitelisted (only if not in cache)
|
|
||||||
if use_whitelist_ip and not whitelist.ip_cached() then
|
|
||||||
if whitelist.check_ip() then
|
|
||||||
ngx.exit(ngx.OK)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- check if reverse is whitelisted (only if not in cache)
|
|
||||||
if use_whitelist_reverse and not whitelist.reverse_cached() then
|
|
||||||
if whitelist.check_reverse() then
|
|
||||||
ngx.exit(ngx.OK)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- check if IP is blacklisted (only if not in cache)
|
|
||||||
if use_blacklist_ip and not blacklist.ip_cached() then
|
|
||||||
if blacklist.check_ip() then
|
|
||||||
ngx.exit(ngx.HTTP_FORBIDDEN)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- check if reverse is blacklisted (only if not in cache)
|
|
||||||
if use_blacklist_reverse and not blacklist.reverse_cached() then
|
|
||||||
if blacklist.check_reverse() then
|
|
||||||
ngx.exit(ngx.HTTP_FORBIDDEN)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- check if IP is in DNSBLs (only if not in cache)
|
|
||||||
if use_dnsbl and not dnsbl.cached() then
|
|
||||||
if dnsbl.check() then
|
|
||||||
ngx.exit(ngx.HTTP_FORBIDDEN)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- cookie check
|
|
||||||
if use_antibot_cookie then
|
|
||||||
if not cookie.is_set("uri") then
|
|
||||||
if ngx.var.request_uri ~= antibot_uri then
|
|
||||||
cookie.set({uri = ngx.var.request_uri})
|
|
||||||
return ngx.redirect(antibot_uri)
|
|
||||||
end
|
|
||||||
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
|
||||||
else
|
|
||||||
if ngx.var.request_uri == antibot_uri then
|
|
||||||
return ngx.redirect(cookie.get("uri"))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- javascript check
|
|
||||||
if use_antibot_javascript then
|
|
||||||
if not cookie.is_set("javascript") then
|
|
||||||
if ngx.var.request_uri ~= antibot_uri then
|
|
||||||
cookie.set({uri = ngx.var.request_uri, challenge = javascript.get_challenge()})
|
|
||||||
return ngx.redirect(antibot_uri)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- captcha check
|
|
||||||
if use_antibot_captcha then
|
|
||||||
if not cookie.is_set("captcha") then
|
|
||||||
if ngx.var.request_uri ~= antibot_uri and ngx.var.request_uri ~= "/favicon.ico" then
|
|
||||||
cookie.set({uri = ngx.var.request_uri})
|
|
||||||
return ngx.redirect(antibot_uri)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- recaptcha check
|
|
||||||
if use_antibot_recaptcha then
|
|
||||||
if not cookie.is_set("recaptcha") then
|
|
||||||
if ngx.var.request_uri ~= antibot_uri and ngx.var.request_uri ~= "/favicon.ico" then
|
|
||||||
cookie.set({uri = ngx.var.request_uri})
|
|
||||||
return ngx.redirect(antibot_uri)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
ngx.exit(ngx.OK)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
%INCLUDE_ANTIBOT_JAVASCRIPT%
|
|
||||||
|
|
||||||
%INCLUDE_ANTIBOT_CAPTCHA%
|
|
||||||
|
|
||||||
%INCLUDE_ANTIBOT_RECAPTCHA%
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
map $http_user_agent $bad_user_agent {
|
|
||||||
default no;
|
|
||||||
%BLOCK_USER_AGENT%
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
SecUploadDir /tmp
|
|
||||||
SecUploadKeepFiles On
|
|
||||||
SecRule FILES_TMPNAMES "@inspectFile /opt/scripts/clamav.sh" \
|
|
||||||
"phase:2,t:none,deny,msg:'Virus found in uploaded file',id:'399999'"
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
modsecurity on;
|
|
||||||
modsecurity_rules_file /etc/nginx/modsecurity-rules.conf;
|
|
||||||
111
confs/nginx.conf
111
confs/nginx.conf
@@ -1,111 +0,0 @@
|
|||||||
# /etc/nginx/nginx.conf
|
|
||||||
|
|
||||||
# load dynamic modules
|
|
||||||
load_module /usr/lib/nginx/modules/ngx_http_cookie_flag_filter_module.so;
|
|
||||||
load_module /usr/lib/nginx/modules/ngx_http_geoip2_module.so;
|
|
||||||
load_module /usr/lib/nginx/modules/ngx_http_headers_more_filter_module.so;
|
|
||||||
load_module /usr/lib/nginx/modules/ngx_http_lua_module.so;
|
|
||||||
load_module /usr/lib/nginx/modules/ngx_http_modsecurity_module.so;
|
|
||||||
load_module /usr/lib/nginx/modules/ngx_stream_geoip2_module.so;
|
|
||||||
|
|
||||||
# run as daemon
|
|
||||||
daemon on;
|
|
||||||
|
|
||||||
# PID file
|
|
||||||
pid /tmp/nginx.pid;
|
|
||||||
|
|
||||||
# worker number = CPU core(s)
|
|
||||||
worker_processes auto;
|
|
||||||
|
|
||||||
# faster regexp
|
|
||||||
pcre_jit on;
|
|
||||||
|
|
||||||
# config files for dynamic modules
|
|
||||||
include /etc/nginx/modules/*.conf;
|
|
||||||
|
|
||||||
events {
|
|
||||||
# max connections per worker
|
|
||||||
worker_connections 1024;
|
|
||||||
|
|
||||||
# epoll seems to be the best on Linux
|
|
||||||
use epoll;
|
|
||||||
}
|
|
||||||
|
|
||||||
http {
|
|
||||||
# zero copy within the kernel
|
|
||||||
sendfile on;
|
|
||||||
|
|
||||||
# send packets only if filled
|
|
||||||
tcp_nopush on;
|
|
||||||
|
|
||||||
# remove 200ms delay
|
|
||||||
tcp_nodelay on;
|
|
||||||
|
|
||||||
# load mime types and set default one
|
|
||||||
include /etc/nginx/mime.types;
|
|
||||||
default_type application/octet-stream;
|
|
||||||
|
|
||||||
# load gzip custom config
|
|
||||||
include /etc/nginx/gzip.conf;
|
|
||||||
|
|
||||||
# maximum request body size
|
|
||||||
client_max_body_size %MAX_CLIENT_SIZE%;
|
|
||||||
|
|
||||||
# write logs to local syslog
|
|
||||||
access_log syslog:server=unix:/dev/log,nohostname,facility=local0,severity=notice combined;
|
|
||||||
error_log syslog:server=unix:/dev/log,nohostname,facility=local0 warn;
|
|
||||||
|
|
||||||
# temp paths
|
|
||||||
proxy_temp_path /tmp/proxy_temp;
|
|
||||||
client_body_temp_path /tmp/client_temp;
|
|
||||||
fastcgi_temp_path /tmp/fastcgi_temp;
|
|
||||||
uwsgi_temp_path /tmp/uwsgi_temp;
|
|
||||||
scgi_temp_path /tmp/scgi_temp;
|
|
||||||
|
|
||||||
# load caching custom config
|
|
||||||
include /etc/nginx/cache.conf;
|
|
||||||
|
|
||||||
# close connections in FIN_WAIT1 state
|
|
||||||
reset_timedout_connection on;
|
|
||||||
|
|
||||||
# timeouts
|
|
||||||
client_body_timeout 12;
|
|
||||||
client_header_timeout 12;
|
|
||||||
keepalive_timeout 15;
|
|
||||||
send_timeout 10;
|
|
||||||
|
|
||||||
# enable/disable sending nginx version
|
|
||||||
server_tokens %SERVER_TOKENS%;
|
|
||||||
|
|
||||||
# resolvers to use
|
|
||||||
resolver %DNS_RESOLVERS% ipv6=off;
|
|
||||||
|
|
||||||
# get real IP address if behind a reverse proxy
|
|
||||||
%PROXY_REAL_IP%
|
|
||||||
|
|
||||||
# lua path and dicts
|
|
||||||
lua_package_path "/usr/local/lib/lua/?.lua;;";
|
|
||||||
%WHITELIST_IP_CACHE%
|
|
||||||
%WHITELIST_REVERSE_CACHE%
|
|
||||||
%BLACKLIST_IP_CACHE%
|
|
||||||
%BLACKLIST_REVERSE_CACHE%
|
|
||||||
%DNSBL_CACHE%
|
|
||||||
|
|
||||||
# shared memory zone for limit_req
|
|
||||||
%LIMIT_REQ_ZONE%
|
|
||||||
|
|
||||||
# server config
|
|
||||||
include /etc/nginx/server.conf;
|
|
||||||
|
|
||||||
# list of blocked country
|
|
||||||
%BLOCK_COUNTRY%
|
|
||||||
|
|
||||||
# list of blocker user agents
|
|
||||||
%BLOCK_USER_AGENT%
|
|
||||||
|
|
||||||
# enable/disable ModSecurity
|
|
||||||
%USE_MODSECURITY%
|
|
||||||
|
|
||||||
# custom http confs
|
|
||||||
include /http-confs/*.conf;
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
location ~ \.php$ {
|
|
||||||
fastcgi_pass %REMOTE_PHP%:9000;
|
|
||||||
fastcgi_index index.php;
|
|
||||||
include fastcgi.conf;
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
%PROXY_REAL_IP_FROM%
|
|
||||||
real_ip_header %PROXY_REAL_IP_HEADER%;
|
|
||||||
real_ip_recursive %PROXY_REAL_IP_RECURSIVE%;
|
|
||||||
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
more_set_headers "Referrer-Policy: %REFERRER_POLICY%";
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
server {
|
|
||||||
include /server-confs/*.conf;
|
|
||||||
include /etc/nginx/main-lua.conf;
|
|
||||||
%LISTEN_HTTP%
|
|
||||||
%USE_HTTPS%
|
|
||||||
%REDIRECT_HTTP_TO_HTTPS%
|
|
||||||
server_name %SERVER_NAME%;
|
|
||||||
%DISABLE_DEFAULT_SERVER%
|
|
||||||
%SERVE_FILES%
|
|
||||||
if ($request_method !~ ^(%ALLOWED_METHODS%)$)
|
|
||||||
{
|
|
||||||
return 405;
|
|
||||||
}
|
|
||||||
%LIMIT_REQ%
|
|
||||||
%AUTH_BASIC%
|
|
||||||
%USE_PHP%
|
|
||||||
%HEADER_SERVER%
|
|
||||||
%X_FRAME_OPTIONS%
|
|
||||||
%X_XSS_PROTECTION%
|
|
||||||
%X_CONTENT_TYPE_OPTIONS%
|
|
||||||
%CONTENT_SECURITY_POLICY%
|
|
||||||
%REFERRER_POLICY%
|
|
||||||
%FEATURE_POLICY%
|
|
||||||
%BLOCK_COUNTRY%
|
|
||||||
%BLOCK_USER_AGENT%
|
|
||||||
%BLOCK_TOR_EXIT_NODE%
|
|
||||||
%BLOCK_PROXIES%
|
|
||||||
%BLOCK_ABUSERS%
|
|
||||||
%COOKIE_FLAGS%
|
|
||||||
%ERRORS%
|
|
||||||
%USE_FAIL2BAN%
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
location = %ANTIBOT_URI% {
|
location = {{ ANTIBOT_URI }} {
|
||||||
|
|
||||||
default_type 'text/html';
|
default_type 'text/html';
|
||||||
|
|
||||||
@@ -6,12 +6,14 @@ location = %ANTIBOT_URI% {
|
|||||||
content_by_lua_block {
|
content_by_lua_block {
|
||||||
local cookie = require "cookie"
|
local cookie = require "cookie"
|
||||||
local captcha = require "captcha"
|
local captcha = require "captcha"
|
||||||
|
local logger = require "logger"
|
||||||
if not cookie.is_set("uri") then
|
if not cookie.is_set("uri") then
|
||||||
|
logger.log(ngx.WARN, "ANTIBOT", "captcha fail (1) for " .. ngx.var.remote_addr)
|
||||||
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
||||||
end
|
end
|
||||||
local img, res = captcha.get_challenge()
|
local img, res = captcha.get_challenge()
|
||||||
cookie.set({captchares = res})
|
cookie.set({captchares = res})
|
||||||
local code = captcha.get_code(img, "%ANTIBOT_URI%")
|
local code = captcha.get_code(img, "{{ ANTIBOT_URI }}")
|
||||||
ngx.say(code)
|
ngx.say(code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,18 +22,22 @@ location = %ANTIBOT_URI% {
|
|||||||
access_by_lua_block {
|
access_by_lua_block {
|
||||||
local cookie = require "cookie"
|
local cookie = require "cookie"
|
||||||
local captcha = require "captcha"
|
local captcha = require "captcha"
|
||||||
|
local logger = require "logger"
|
||||||
if not cookie.is_set("captchares") then
|
if not cookie.is_set("captchares") then
|
||||||
|
logger.log(ngx.WARN, "ANTIBOT", "captcha fail (2) for " .. ngx.var.remote_addr)
|
||||||
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
||||||
end
|
end
|
||||||
ngx.req.read_body()
|
ngx.req.read_body()
|
||||||
local args, err = ngx.req.get_post_args(1)
|
local args, err = ngx.req.get_post_args(1)
|
||||||
if err == "truncated" or not args or not args["captcha"] then
|
if err == "truncated" or not args or not args["captcha"] then
|
||||||
|
logger.log(ngx.WARN, "ANTIBOT", "captcha fail (3) for " .. ngx.var.remote_addr)
|
||||||
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
||||||
end
|
end
|
||||||
local captcha_user = args["captcha"]
|
local captcha_user = args["captcha"]
|
||||||
local check = captcha.check(captcha_user, cookie.get("captchares"))
|
local check = captcha.check(captcha_user, cookie.get("captchares"))
|
||||||
if not check then
|
if not check then
|
||||||
return ngx.redirect("%ANTIBOT_URI%")
|
logger.log(ngx.WARN, "ANTIBOT", "captcha fail (4) for " .. ngx.var.remote_addr)
|
||||||
|
return ngx.redirect("{{ ANTIBOT_URI }}")
|
||||||
end
|
end
|
||||||
cookie.set({captcha = "ok"})
|
cookie.set({captcha = "ok"})
|
||||||
return ngx.redirect(cookie.get("uri"))
|
return ngx.redirect(cookie.get("uri"))
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
location = %ANTIBOT_URI% {
|
location = {{ ANTIBOT_URI }} {
|
||||||
|
|
||||||
default_type 'text/html';
|
default_type 'text/html';
|
||||||
|
|
||||||
@@ -6,11 +6,13 @@ location = %ANTIBOT_URI% {
|
|||||||
content_by_lua_block {
|
content_by_lua_block {
|
||||||
local cookie = require "cookie"
|
local cookie = require "cookie"
|
||||||
local javascript = require "javascript"
|
local javascript = require "javascript"
|
||||||
|
local logger = require "logger"
|
||||||
if not cookie.is_set("challenge") then
|
if not cookie.is_set("challenge") then
|
||||||
|
logger.log(ngx.WARN, "ANTIBOT", "javascript fail (1) for " .. ngx.var.remote_addr)
|
||||||
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
||||||
end
|
end
|
||||||
local challenge = cookie.get("challenge")
|
local challenge = cookie.get("challenge")
|
||||||
local code = javascript.get_code(challenge, "%ANTIBOT_URI%", cookie.get("uri"))
|
local code = javascript.get_code(challenge, "{{ ANTIBOT_URI }}", cookie.get("uri"))
|
||||||
ngx.say(code)
|
ngx.say(code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,17 +21,21 @@ location = %ANTIBOT_URI% {
|
|||||||
content_by_lua_block {
|
content_by_lua_block {
|
||||||
local cookie = require "cookie"
|
local cookie = require "cookie"
|
||||||
local javascript = require "javascript"
|
local javascript = require "javascript"
|
||||||
|
local logger = require "logger"
|
||||||
if not cookie.is_set("challenge") then
|
if not cookie.is_set("challenge") then
|
||||||
|
logger.log(ngx.WARN, "ANTIBOT", "javascript fail (2) for " .. ngx.var.remote_addr)
|
||||||
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
||||||
end
|
end
|
||||||
ngx.req.read_body()
|
ngx.req.read_body()
|
||||||
local args, err = ngx.req.get_post_args(1)
|
local args, err = ngx.req.get_post_args(1)
|
||||||
if err == "truncated" or not args or not args["challenge"] then
|
if err == "truncated" or not args or not args["challenge"] then
|
||||||
|
logger.log(ngx.WARN, "ANTIBOT", "javascript fail (3) for " .. ngx.var.remote_addr)
|
||||||
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
||||||
end
|
end
|
||||||
local challenge = args["challenge"]
|
local challenge = args["challenge"]
|
||||||
local check = javascript.check(cookie.get("challenge"), challenge)
|
local check = javascript.check(cookie.get("challenge"), challenge)
|
||||||
if not check then
|
if not check then
|
||||||
|
logger.log(ngx.WARN, "ANTIBOT", "javascript fail (4) for " .. ngx.var.remote_addr)
|
||||||
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
||||||
end
|
end
|
||||||
cookie.set({javascript = "ok"})
|
cookie.set({javascript = "ok"})
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
location = %ANTIBOT_URI% {
|
location = {{ ANTIBOT_URI }} {
|
||||||
|
|
||||||
default_type 'text/html';
|
default_type 'text/html';
|
||||||
|
|
||||||
@@ -6,10 +6,12 @@ location = %ANTIBOT_URI% {
|
|||||||
content_by_lua_block {
|
content_by_lua_block {
|
||||||
local cookie = require "cookie"
|
local cookie = require "cookie"
|
||||||
local recaptcha = require "recaptcha"
|
local recaptcha = require "recaptcha"
|
||||||
|
local loggger = require "logger"
|
||||||
if not cookie.is_set("uri") then
|
if not cookie.is_set("uri") then
|
||||||
|
logger.log(ngx.WARN, "ANTIBOT", "recaptcha fail (1) for " .. ngx.var.remote_addr)
|
||||||
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
||||||
end
|
end
|
||||||
local code = recaptcha.get_code("%ANTIBOT_URI%", "%ANTIBOT_RECAPTCHA_SITEKEY%")
|
local code = recaptcha.get_code("{{ ANTIBOT_URI }}", "{{ ANTIBOT_RECAPTCHA_SITEKEY }}")
|
||||||
ngx.say(code)
|
ngx.say(code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,18 +20,21 @@ location = %ANTIBOT_URI% {
|
|||||||
access_by_lua_block {
|
access_by_lua_block {
|
||||||
local cookie = require "cookie"
|
local cookie = require "cookie"
|
||||||
local recaptcha = require "recaptcha"
|
local recaptcha = require "recaptcha"
|
||||||
|
local logger = require "logger"
|
||||||
if not cookie.is_set("uri") then
|
if not cookie.is_set("uri") then
|
||||||
|
logger.log(ngx.WARN, "ANTIBOT", "recaptcha fail (2) for " .. ngx.var.remote_addr)
|
||||||
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
||||||
end
|
end
|
||||||
ngx.req.read_body()
|
ngx.req.read_body()
|
||||||
local args, err = ngx.req.get_post_args(1)
|
local args, err = ngx.req.get_post_args(1)
|
||||||
if err == "truncated" or not args or not args["token"] then
|
if err == "truncated" or not args or not args["token"] then
|
||||||
|
logger.log(ngx.WARN, "ANTIBOT", "recaptcha fail (3) for " .. ngx.var.remote_addr)
|
||||||
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
||||||
end
|
end
|
||||||
local token = args["token"]
|
local token = args["token"]
|
||||||
local check = recaptcha.check(token, "%ANTIBOT_RECAPTCHA_SECRET%")
|
local check = recaptcha.check(token, "{{ ANTIBOT_RECAPTCHA_SECRET }}")
|
||||||
if check < %ANTIBOT_RECAPTCHA_SCORE% then
|
if check < {{ ANTIBOT_RECAPTCHA_SCORE }} then
|
||||||
ngx.log(ngx.WARN, "client has recaptcha score of " .. tostring(check))
|
logger.log(ngx.WARN, "ANTIBOT", "recaptcha fail (4) for " .. ngx.var.remote_addr .. " (score = " .. tostring(check) .. ")")
|
||||||
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
||||||
end
|
end
|
||||||
cookie.set({recaptcha = "ok"})
|
cookie.set({recaptcha = "ok"})
|
||||||
2
confs/site/auth-basic-sitewide.conf
Normal file
2
confs/site/auth-basic-sitewide.conf
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
auth_basic "{{ AUTH_BASIC_TEXT }}";
|
||||||
|
auth_basic_user_file {{ NGINX_PREFIX }}htpasswd;
|
||||||
4
confs/site/auth-basic.conf
Normal file
4
confs/site/auth-basic.conf
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
location {{ AUTH_BASIC_LOCATION }} {
|
||||||
|
auth_basic "{{ AUTH_BASIC_TEXT }}";
|
||||||
|
auth_basic_user_file {{ NGINX_PREFIX }}htpasswd;
|
||||||
|
}
|
||||||
26
confs/site/authelia-auth-request.conf
Normal file
26
confs/site/authelia-auth-request.conf
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Basic Authelia Config
|
||||||
|
# Send a subsequent request to Authelia to verify if the user is authenticated
|
||||||
|
# and has the right permissions to access the resource.
|
||||||
|
auth_request /authelia;
|
||||||
|
# Set the `target_url` variable based on the request. It will be used to build the portal
|
||||||
|
# URL with the correct redirection parameter.
|
||||||
|
auth_request_set $target_url $scheme://$http_host$request_uri;
|
||||||
|
# Set the X-Forwarded-User and X-Forwarded-Groups with the headers
|
||||||
|
# returned by Authelia for the backends which can consume them.
|
||||||
|
# This is not safe, as the backend must make sure that they come from the
|
||||||
|
# proxy. In the future, it's gonna be safe to just use OAuth.
|
||||||
|
auth_request_set $user $upstream_http_remote_user;
|
||||||
|
auth_request_set $groups $upstream_http_remote_groups;
|
||||||
|
auth_request_set $name $upstream_http_remote_name;
|
||||||
|
auth_request_set $email $upstream_http_remote_email;
|
||||||
|
fastcgi_param REMOTE_USER $user;
|
||||||
|
fastcgi_param REMOTE_GROUPS $groups;
|
||||||
|
fastcgi_param REMOTE_NAME $name;
|
||||||
|
fastcgi_param REMOTE_EMAIL $email;
|
||||||
|
proxy_set_header Remote-User $user;
|
||||||
|
proxy_set_header Remote-Groups $groups;
|
||||||
|
proxy_set_header Remote-Name $name;
|
||||||
|
proxy_set_header Remote-Email $email;
|
||||||
|
{% if AUTHELIA_MODE == "portal" +%}
|
||||||
|
error_page 401 =302 {{ AUTHELIA_BACKEND }}/?rd=$target_url;
|
||||||
|
{% endif %}
|
||||||
40
confs/site/authelia-upstream.conf
Normal file
40
confs/site/authelia-upstream.conf
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
set $upstream_authelia {{ AUTHELIA_UPSTREAM }}/api/verify;
|
||||||
|
|
||||||
|
# Virtual endpoint created by nginx to forward auth requests.
|
||||||
|
location /authelia {
|
||||||
|
internal;
|
||||||
|
proxy_pass_request_body off;
|
||||||
|
proxy_pass $upstream_authelia;
|
||||||
|
proxy_set_header Content-Length "";
|
||||||
|
|
||||||
|
# Timeout if the real server is dead
|
||||||
|
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
|
||||||
|
|
||||||
|
# [REQUIRED] Needed by Authelia to check authorizations of the resource.
|
||||||
|
# Provide either X-Original-URL and X-Forwarded-Proto or
|
||||||
|
# X-Forwarded-Proto, X-Forwarded-Host and X-Forwarded-Uri or both.
|
||||||
|
# Those headers will be used by Authelia to deduce the target url of the user.
|
||||||
|
# Basic Proxy Config
|
||||||
|
client_body_buffer_size 128k;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Original-URL $scheme://$http_host$request_uri;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-Method $request_method;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_set_header X-Forwarded-Host $http_host;
|
||||||
|
proxy_set_header X-Forwarded-Uri $request_uri;
|
||||||
|
proxy_set_header X-Forwarded-For $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-Ssl on;
|
||||||
|
proxy_redirect http:// $scheme://;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Connection "";
|
||||||
|
proxy_cache_bypass $cookie_session;
|
||||||
|
proxy_no_cache $cookie_session;
|
||||||
|
proxy_buffers 4 32k;
|
||||||
|
|
||||||
|
# Advanced Proxy Config
|
||||||
|
send_timeout 5m;
|
||||||
|
proxy_read_timeout 240;
|
||||||
|
proxy_send_timeout 240;
|
||||||
|
proxy_connect_timeout 240;
|
||||||
|
}
|
||||||
4
confs/site/brotli.conf
Normal file
4
confs/site/brotli.conf
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
brotli on;
|
||||||
|
brotli_types {{ BROTLI_TYPES }};
|
||||||
|
brotli_comp_level {{ BROTLI_COMP_LEVEL }};
|
||||||
|
brotli_min_length {{ BROTLI_MIN_LENGTH }};
|
||||||
6
confs/site/client-cache.conf
Normal file
6
confs/site/client-cache.conf
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
etag {{ CLIENT_CACHE_ETAG }};
|
||||||
|
set $cache "";
|
||||||
|
if ($uri ~* \.({{ CLIENT_CACHE_EXTENSIONS }})$) {
|
||||||
|
set $cache "{{ CLIENT_CACHE_CONTROL }}";
|
||||||
|
}
|
||||||
|
add_header Cache-Control $cache;
|
||||||
1
confs/site/content-security-policy.conf
Normal file
1
confs/site/content-security-policy.conf
Normal file
@@ -0,0 +1 @@
|
|||||||
|
more_set_headers "Content-Security-Policy: {{ CONTENT_SECURITY_POLICY }}";
|
||||||
1
confs/site/cookie-flags.conf
Normal file
1
confs/site/cookie-flags.conf
Normal file
@@ -0,0 +1 @@
|
|||||||
|
set_cookie_flag {{ COOKIE_FLAGS }}{% if COOKIE_AUTO_SECURE_FLAG == "yes" and (AUTO_LETS_ENCRYPT == "yes" or USE_CUSTOM_HTTPS == "yes" or GENERATE_SELF_SIGNED_SSL == "yes") %} Secure{% endif %};
|
||||||
5
confs/site/custom-headers.conf
Normal file
5
confs/site/custom-headers.conf
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{% for k, v in all.items() +%}
|
||||||
|
{% if k.startswith("CUSTOM_HEADER") and v != "" +%}
|
||||||
|
more_set_header "{{ v }}";
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
9
confs/site/custom-https.conf
Normal file
9
confs/site/custom-https.conf
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
listen 0.0.0.0:443 ssl {% if HTTP2 == "yes" %}http2{% endif %};
|
||||||
|
ssl_certificate {{ HTTPS_CUSTOM_CERT }};
|
||||||
|
ssl_certificate_key {{ HTTPS_CUSTOM_KEY }};
|
||||||
|
ssl_protocols TLSv1.3;
|
||||||
|
ssl_prefer_server_ciphers off;
|
||||||
|
ssl_session_tickets off;
|
||||||
|
{% if STRICT_TRANSPORT_SECURITY != "" +%}
|
||||||
|
more_set_headers 'Strict-Transport-Security: {{ STRICT_TRANSPORT_SECURITY }}';
|
||||||
|
{% endif %}
|
||||||
3
confs/site/disable-default-server.conf
Normal file
3
confs/site/disable-default-server.conf
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
if ($host !~ ^({{ SERVER_NAME.replace(" ", "|") }})$) {
|
||||||
|
return 444;
|
||||||
|
}
|
||||||
26
confs/site/error.conf
Normal file
26
confs/site/error.conf
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{% if ERRORS != "" %}
|
||||||
|
{% for element in ERRORS.split(" ") %}
|
||||||
|
{% set code = element.split("=")[0] %}
|
||||||
|
{% set page = element.split("=")[1] %}
|
||||||
|
error_page {{ code }} {{ page }};
|
||||||
|
|
||||||
|
location = {{ page }} {
|
||||||
|
root {{ ROOT_FOLDER }};
|
||||||
|
modsecurity off;
|
||||||
|
internal;
|
||||||
|
}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% set default_errors = ["400", "401", "403", "404", "429", "500", "501", "502", "503", "504"] %}
|
||||||
|
{% for default_error in default_errors %}
|
||||||
|
{% if not default_error + "=" in ERRORS +%}
|
||||||
|
error_page {{ default_error }} /errors/{{ default_error }}.html;
|
||||||
|
|
||||||
|
location = /errors/{{ default_error }}.html {
|
||||||
|
root /opt/bunkerized-nginx/defaults;
|
||||||
|
modsecurity off;
|
||||||
|
internal;
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
31
confs/site/fastcgi.conf
Normal file
31
confs/site/fastcgi.conf
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{% if REMOTE_PHP != "" +%}
|
||||||
|
fastcgi_param SCRIPT_FILENAME {{ REMOTE_PHP_PATH }}/$fastcgi_script_name;
|
||||||
|
{% elif LOCAL_PHP != "" +%}
|
||||||
|
fastcgi_param SCRIPT_FILENAME {{ LOCAL_PHP_PATH }}/$fastcgi_script_name;
|
||||||
|
{% else +%}
|
||||||
|
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
|
||||||
|
{% endif %}
|
||||||
|
fastcgi_param QUERY_STRING $query_string;
|
||||||
|
fastcgi_param REQUEST_METHOD $request_method;
|
||||||
|
fastcgi_param CONTENT_TYPE $content_type;
|
||||||
|
fastcgi_param CONTENT_LENGTH $content_length;
|
||||||
|
|
||||||
|
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
|
||||||
|
fastcgi_param REQUEST_URI $request_uri;
|
||||||
|
fastcgi_param DOCUMENT_URI $document_uri;
|
||||||
|
fastcgi_param DOCUMENT_ROOT $document_root;
|
||||||
|
fastcgi_param SERVER_PROTOCOL $server_protocol;
|
||||||
|
fastcgi_param REQUEST_SCHEME $scheme;
|
||||||
|
fastcgi_param HTTPS $https if_not_empty;
|
||||||
|
|
||||||
|
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
|
||||||
|
fastcgi_param SERVER_SOFTWARE nginx;
|
||||||
|
|
||||||
|
fastcgi_param REMOTE_ADDR $remote_addr;
|
||||||
|
fastcgi_param REMOTE_PORT $remote_port;
|
||||||
|
fastcgi_param SERVER_ADDR $server_addr;
|
||||||
|
fastcgi_param SERVER_PORT $server_port;
|
||||||
|
fastcgi_param SERVER_NAME $server_name;
|
||||||
|
|
||||||
|
# PHP only, required if PHP was built with --enable-force-cgi-redirect
|
||||||
|
fastcgi_param REDIRECT_STATUS 200;
|
||||||
1
confs/site/feature-policy.conf
Normal file
1
confs/site/feature-policy.conf
Normal file
@@ -0,0 +1 @@
|
|||||||
|
more_set_headers "Feature-Policy: {{ FEATURE_POLICY }}";
|
||||||
4
confs/site/gzip.conf
Normal file
4
confs/site/gzip.conf
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
gzip on;
|
||||||
|
gzip_comp_level {{ GZIP_COMP_LEVEL }};
|
||||||
|
gzip_min_length {{ GZIP_MIN_LENGTH }};
|
||||||
|
gzip_types {{ GZIP_TYPES }};
|
||||||
3
confs/site/htpasswd
Normal file
3
confs/site/htpasswd
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{% if USE_AUTH_BASIC == "yes" %}
|
||||||
|
{{ AUTH_BASIC_USER }}:{{ sha512_crypt(AUTH_BASIC_PASSWORD) }}
|
||||||
|
{% endif %}
|
||||||
34
confs/site/https.conf
Normal file
34
confs/site/https.conf
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
listen 0.0.0.0:{{ HTTPS_PORT }} ssl {% if HTTP2 == "yes" %}http2{% endif %};
|
||||||
|
{% set paths = {"cert": "", "key": ""} %}
|
||||||
|
{% if AUTO_LETS_ENCRYPT == "yes" %}
|
||||||
|
{% set x = paths.update({"cert": "/etc/letsencrypt/live/" + FIRST_SERVER + "/fullchain.pem"}) %}
|
||||||
|
{% set x = paths.update({"key": "/etc/letsencrypt/live/" + FIRST_SERVER + "/privkey.pem"}) %}
|
||||||
|
{% elif USE_CUSTOM_HTTPS == "yes" %}
|
||||||
|
{% set x = paths.update({"cert": CUSTOM_HTTPS_CERT}) %}
|
||||||
|
{% set x = paths.update({"key": CUSTOM_HTTPS_KEY}) %}
|
||||||
|
{% elif GENERATE_SELF_SIGNED_SSL == "yes" %}
|
||||||
|
{% if MULTISITE == "yes" %}
|
||||||
|
{% set x = paths.update({"cert": "/etc/nginx/" + FIRST_SERVER + "/self-cert.pem"}) %}
|
||||||
|
{% set x = paths.update({"key": "/etc/nginx/" + FIRST_SERVER + "/self-key.pem"}) %}
|
||||||
|
{% else %}
|
||||||
|
{% set x = paths.update({"cert": "/etc/nginx/self-cert.pem"}) %}
|
||||||
|
{% set x = paths.update({"key": "/etc/nginx/self-key.pem"}) %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
ssl_certificate {{ paths["cert"] }};
|
||||||
|
ssl_certificate_key {{ paths["key"] }};
|
||||||
|
ssl_protocols {{ HTTPS_PROTOCOLS }};
|
||||||
|
ssl_prefer_server_ciphers on;
|
||||||
|
ssl_session_tickets off;
|
||||||
|
ssl_session_timeout 1d;
|
||||||
|
ssl_session_cache shared:MozSSL:10m;
|
||||||
|
{% if STRICT_TRANSPORT_SECURITY != "" +%}
|
||||||
|
more_set_headers 'Strict-Transport-Security: {{ STRICT_TRANSPORT_SECURITY }}';
|
||||||
|
{% endif %}
|
||||||
|
{% if "TLSv1.2" in HTTPS_PROTOCOLS +%}
|
||||||
|
ssl_dhparam /etc/nginx/dhparam;
|
||||||
|
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;
|
||||||
|
{% endif %}
|
||||||
|
{% if AUTO_LETS_ENCRYPT +%}
|
||||||
|
include {{ NGINX_PREFIX }}lets-encrypt-webroot.conf;
|
||||||
|
{% endif %}
|
||||||
1
confs/site/inject-body.conf
Normal file
1
confs/site/inject-body.conf
Normal file
@@ -0,0 +1 @@
|
|||||||
|
sub_filter '</body>' '{{ INJECT_BODY }}</body>';
|
||||||
3
confs/site/lets-encrypt-webroot.conf
Normal file
3
confs/site/lets-encrypt-webroot.conf
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
location ~ ^/.well-known/acme-challenge/ {
|
||||||
|
root /opt/bunkerized-nginx/acme-challenge;
|
||||||
|
}
|
||||||
1
confs/site/limit-conn.conf
Normal file
1
confs/site/limit-conn.conf
Normal file
@@ -0,0 +1 @@
|
|||||||
|
limit_conn ddos {{ LIMIT_CONN_MAX }};
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user