Compare commits

...

611 Commits

Author SHA1 Message Date
florian
fd0c7b1e53 ci/cd - add automatic build for Linux images 2022-06-16 17:40:15 +02:00
florian
1e6d62ce79
fix packagecloud yank name 2022-06-16 12:52:44 +02:00
florian
1a4e21481e
docs - edit supported architectures for prebuilt Docker images 2022-06-16 11:38:05 +02:00
florian
bcaca6f034
v1.4.1 release 2022-06-16 11:26:58 +02:00
florian
424214fd56
add changelog and add missing s in authentik url 2022-06-15 14:06:39 +02:00
Florian Pitance
82b42d5b9c
Merge pull request #259 from Brawdunoir/master
Remove USE_ before authbasic plugin settings
2022-06-15 11:06:45 +02:00
florian
db4e2cf266
update linux docs, minor fix in ingress example and update default value for bunkernet job 2022-06-14 13:49:22 +02:00
florian
0ef82619b8
temp disable automatic tests for authentik and test automatic arm build on dedicated hardware 2022-06-14 11:05:26 +02:00
florian
f2655e331d
remove arm build again, fix proxy_*_timeout directives and add authelia example 2022-06-14 09:42:32 +02:00
Yann Lacroix
d51ae1c1b9 Remove USE_ before authbasic plugin settings 2022-06-13 22:50:10 +02:00
florian
cd0438b8ce support REVERSE_PROXY_*_TIMEOUT settings, remove useless push in CI/CD and try to build arm on GH runners 2022-06-13 21:40:38 +02:00
florian
f9a042526e add docs about compiling BW from source on Linux, add docs about packages pinning on Linux and fix regex for REVERSE_PROXY_AUTH_REQUEST and REVERSE_PROXY_AUTH_REQUEST_SIGNIN_URL 2022-06-13 21:04:25 +02:00
florian
15ac64b05f let's encrypt - fix bug when AUTOCONF_MODE=yes 2022-06-13 19:55:15 +02:00
florian
e0f8895e9a
init support for auth_request and add authentik example 2022-06-13 13:06:03 +02:00
florian
e852298352 don't send local IP to BunkerNet on default server, fix certbot new when MULTISITE=no and fix unknown reason in get_reason 2022-06-11 18:36:52 +02:00
florian
972a284efd docker - drop support for prebuilt arm images 2022-06-06 23:35:37 +02:00
florian
5258d8e58f docs - edit linux install procedure 2022-06-06 22:15:24 +02:00
florian
acb4bea97d reflect CI/CD changes for master pushes 2022-06-06 21:22:28 +02:00
florian
42067e864a GHA - temp disable armv7 build until we have a fix for cryptography dependency 2022-06-06 20:14:11 +02:00
florian
217bddabfd GHA - different caches for armv7 and armv8 images 2022-06-06 18:30:28 +02:00
florian
c5fba13674 fix GHA typos 2022-06-06 15:29:09 +02:00
florian
1b21f9eac3 fix UI tag in GHA jobs 2022-06-06 15:19:25 +02:00
florian
389e050943 fix links in docs and change cache location for GHA jobs 2022-06-06 14:51:47 +02:00
florian
05a89c3037 fix registry URL in GHA jobs 2022-06-06 14:07:52 +02:00
florian
a0ed8a27e9 add debug flag to GHA buildx steps 2022-06-06 12:35:30 +02:00
florian
d0ac5e3059 update GHA actions version 2022-06-06 12:17:56 +02:00
florian
b16f8f11ad update GHA actions version 2022-06-06 12:17:11 +02:00
florian
a23ed06e66 fix typo in GHA jobs 2022-06-06 11:53:46 +02:00
florian
6b9be078b8 refactoring of GHA jobs 2022-06-06 11:52:25 +02:00
florian
8e198ed82e linux - fix documentation link in systemd unit files 2022-06-05 17:07:43 +02:00
florian
c3b527afe8 actions - fix RPMs path 2022-06-05 00:35:29 +02:00
florian
972e5471d1 actions - fix linux deb/rpm generation 2022-06-04 22:01:45 +02:00
florian
b246c6d7e2 fix wrong branch name in actions and image name for linux tests 2022-06-04 17:25:46 +02:00
florian
b78fd55427 fix freetype CVE 2022-06-04 16:14:11 +02:00
bunkerity
945241339a actions - rename main branch to master 2022-06-03 18:16:53 +02:00
bunkerity
1af2264fab temp stop push to private repo 2022-06-03 18:14:47 +02:00
bunkerity
6f28708c10 docs - add missing setting 2022-06-03 17:44:17 +02:00
bunkerity
a9f886804a bunkerweb 1.4.0 2022-06-03 17:24:14 +02:00
Florian Pitance
3a078326c5
Merge pull request #199 from Myzel394/patch-1
Fix typo
2021-10-24 18:25:37 +02:00
florian
d43b82b757
remote API - only do action if 403 2021-10-24 18:24:10 +02:00
florian
3850cacb9c
prepare for v1.3.2 2021-10-23 16:56:10 +02:00
florian
c00c7f46a0
lua - verify certs when doing HTTPS requests 2021-10-23 10:10:24 +02:00
bunkerity
163af4a49d
prepare for v1.3.2 2021-10-22 21:16:36 +02:00
bunkerity
98e85eb99f
docs - update security tuning sections : distributed blacklist and request limit 2021-10-21 21:31:15 +02:00
bunkerity
2e63bb0256
docs - reflect kubernetes/swarm changes into the doc 2021-10-21 16:47:08 +02:00
bunkerity
6546a0edb7
disable country ban if IP is local, update default values of PERMISSIONS_POLICY and FEATURE_POLICY, upgrade archlinux packages before testing 2021-10-21 15:40:20 +02:00
bunkerity
ab00381746
ui - fix ROOT_FOLDER bug in serve-files.conf 2021-10-21 11:30:49 +02:00
bunkerity
9f7097de0d
request limit - fix some LUA code 2021-10-19 17:21:30 +02:00
bunkerity
24d6337a57
limit req - multiple url support 2021-10-18 16:48:06 +02:00
bunkerity
bfb5319c16
limit req - add burst and delay parameters 2021-10-13 20:53:10 +02:00
bunkerity
4c77a14825
use annotations as env var in Ingress definition, fix cidr parsing for reserved ips, fix missing empty when job is external, fix ping check for remote api and init work hour/day support for request limit 2021-10-13 17:21:25 +02:00
bunkerity
4e45fa3874
integrations - acme without shared folder when using k8s/swarm 2021-10-12 16:58:13 +02:00
Myzel394
a9a26b82d9
fixed typo 2021-10-12 10:22:25 +00:00
bunkerity
00d91dcaaa
jobs - move certbot hooks to python 2021-10-11 20:57:13 +02:00
bunkerity
650ad7ea49
integrations - fix missing acme folder when using Swarm or Kubernetes 2021-10-11 17:24:19 +02:00
bunkerity
7045c0c2b6
jobs - fix encoding error on CentOS 2021-10-08 17:10:01 +02:00
bunkerity
f0f432487b
remote API - ban IP from distributed DB 2021-10-07 16:57:37 +02:00
bunkerity
fdc02be051
remote API - basic send of bad IPs 2021-10-07 12:00:20 +02:00
bunkerity
fb799765a4
jobs - fix str/bytes hell 2021-10-06 21:09:27 +02:00
bunkerity
d53f02b5b3
api - client side (untested) 2021-10-06 15:41:55 +02:00
bunkerity
7b9722fac4
jobs - add remote API 2021-10-06 12:13:13 +02:00
bunkerity
31ed4ff834
centos - update ca-certificates in install script 2021-10-05 16:06:35 +02:00
bunkerity
bc5f3ee88e
fix CVEs and add init to Debian test image 2021-10-05 15:01:43 +02:00
bunkerity
a6b21aae8c
fix typo in settings.json, bump Debian to bullseyes, init support of Arch Linux 2021-10-05 14:32:19 +02:00
bunkerity
64aa9c2530
init work remote API 2021-10-02 20:29:50 +02:00
bunkerity
5d94cc8f43
docs - init changes about storageless 2021-09-14 16:41:39 +02:00
bunkerity
e7ee21cbb5
antibot - fix path for templates and data 2021-09-14 11:30:33 +02:00
florian
a0f8cbdac1
antibot - fix LUA typo in recaptcha mode 2021-09-13 21:26:09 +02:00
Florian Pitance
178d7a6849
Merge pull request #182 from Nakinox/patch-2
Update docker-compose.yml
2021-09-13 21:20:26 +02:00
florian
ca81535bb3
swarm/k8s - less storage, more API 2021-09-05 00:36:15 +02:00
florian
062fa3e78a
integration - continue work on storageless config for k8s and swarm 2021-09-03 22:40:37 +02:00
Nakinox
95f2d2af9c
Update docker-compose.yml 2021-09-03 17:21:36 +02:00
bunkerity
e55dff8128
api - init work on storageless configuration 2021-09-03 12:04:30 +02:00
bunkerity
f0f1c79d40
v1.3.1 release 2021-09-02 17:18:57 +02:00
bunkerity
3d2f5e2389
conf - add REVERSE_PROXY_KEEPALIVE 2021-09-02 12:03:56 +02:00
bunkerity
b079c99fb9 Merge branch 'patch-15' of github.com:thelittlefireman/bunkerized-nginx into keepalive 2021-09-02 11:52:38 +02:00
bunkerity
2e403c6ebc
config - add CUSTOM_HEADER 2021-09-02 10:34:58 +02:00
bunkerity
f75a05584e
config - add REVERSE_PROXY_BUFFERING 2021-09-02 09:36:28 +02:00
florian
148edf6814
tests - add github token to trivy scanner 2021-08-30 22:34:19 +02:00
Florian Pitance
a19d8aa041
Merge pull request #180 from vepito/vepito-patch-1
Fix typo related to non-HTTP configuration
2021-08-30 21:17:34 +02:00
Florian Pitance
480cff86bc
Merge pull request #179 from thelittlefireman/patch-16
Mismatch in docs with modsec folder
2021-08-30 21:15:15 +02:00
Florian Pitance
35df3423d0
missing blank line 2021-08-30 21:14:04 +02:00
Florian Pitance
29f4069de7
switch the use cases 2021-08-30 21:12:59 +02:00
vepito
72e4384596
Fix typo related to non-HTTP configuration
Fix typo that prevents non-HTTP configuration to be working when MULTISITE is used
2021-08-29 02:59:24 +02:00
bunkerity
a4a2647737
jobs - fix docker reload and only do cron jobs when necessary 2021-08-26 15:48:38 +02:00
thelittlefireman
892e533694
Missmatch in docs with modsec folder 2021-08-25 22:32:47 +02:00
bunkerity
a056141609
deps - use ModSecurity v3.0.4 instead of v3.0.5 to avoid memory leak 2021-08-25 17:12:38 +02:00
florian
0772a9ba8e
docs - edit badge version 2021-08-23 16:50:08 +02:00
florian
33e0ffd5b1 Merge branch 'master' into dev 2021-08-23 16:44:50 +02:00
bunkerity
4cb3e089e3
linux - git SHA1 commit in install.sh 2021-08-20 17:06:58 +02:00
bunkerity
8808f161c5
docs - dev to master links and VERSION upgrade 2021-08-20 16:58:37 +02:00
bunkerity
1c60ec9804
tests - fix volume wait with linux tests 2021-08-20 15:13:16 +02:00
bunkerity
b13ff34569
add REDIRECT_TO_REQUEST_URI variable and edit environment variables docs 2021-08-20 14:59:16 +02:00
bunkerity
58f2926e95
docs - various examples fixes 2021-08-20 09:38:18 +02:00
thelittlefireman
9de628f3eb
Missing proxy_set_header for keep alive 2021-08-18 23:47:01 +02:00
thelittlefireman
6cc1abc893
Allow keep alive connection when ws is off
This help improves performance.
2021-08-18 23:42:18 +02:00
bunkerity
a824e15684
linux - rename cron 2021-08-18 17:46:28 +02:00
bunkerity
fd52bb7c8d
linux - fix cron jobs 2021-08-18 16:15:26 +02:00
bunkerity
0938b20eb8
UI - use sudo for Linux integration 2021-08-18 14:38:31 +02:00
bunkerity
b948e08bd5
UI - use systemctl on Linux 2021-08-18 14:09:42 +02:00
bunkerity
fde14d1621
linux - fix unknown scheme error and do nginx reload as root in UI 2021-08-18 13:38:09 +02:00
bunkerity
8a4eb3f2a3
remove .site files (gen), uninstall remove folder at the end (linux) and run jobs when reloading local instances (UI) 2021-08-18 12:07:11 +02:00
bunkerity
2a0b84074a
ui - fix bug when Docker is used but Swarm is disabled, add jobs from API /reload and fix docker-compose doc 2021-08-18 11:36:19 +02:00
bunkerity
aec22d1a81
ui - edit docs and fix CSRF 2021-08-17 17:34:05 +02:00
bunkerity
028fc61b4f
docs - add dns_resolvers and permissions to Linux 2021-08-17 14:02:15 +02:00
bunkerity
a903960b4c
docs - fix missing subfolder in Linux quickstart guide 2021-08-17 10:55:15 +02:00
bunkerity
a28f06f08f
linux - run temp nginx to solve let's encrypt challenges 2021-08-17 10:24:40 +02:00
bunkerity
6c8bc6b349
tests - fix Linux systemd bug when writing to /tmp folder 2021-08-17 09:35:50 +02:00
bunkerity
2b3b4a5c3f
linux - systemd support 2021-08-16 15:21:44 +02:00
florian
57e4247eab
linux - systemd unit file 2021-08-15 22:48:41 +02:00
florian
f9d4e90894
docs - edit k8s php service port and append suffix to hosts 2021-08-15 00:26:37 +02:00
florian
4f024ec566
docs - add DNS_RESOLVERS for k8s integration 2021-08-15 00:17:42 +02:00
florian
bc46fc3d4c
append suffix to ingress hosts 2021-08-14 23:52:03 +02:00
florian
0be1da18a6
remove old conf before generation, dynamic DNS for PHP and reverse proxy and swarm fixes in quickstart guide 2021-08-14 20:52:17 +02:00
florian
3cedc0ae13
quickstart guide fixes 2021-08-13 21:29:58 +02:00
bunkerity
f1d5c07cc1
autoconf - various kubernetes fixes 2021-08-13 16:42:31 +02:00
bunkerity
c9a6b6c27d
autoconf - fixed infinite lock 2021-08-13 10:02:14 +02:00
florian
b199464a73
various bug fixes related to Swarm integration 2021-08-12 22:53:07 +02:00
bunkerity
4a9d64d9d9
add favicon to web UI and fix some tech docs 2021-08-12 17:28:13 +02:00
bunkerity
31536a3fe2
linux - reload as root 2021-08-12 15:44:10 +02:00
bunkerity
7b47c7304f
examples - minor fixes in architecture images 2021-08-12 14:51:29 +02:00
bunkerity
83e7ce9cde
examples - polishing before next release 2021-08-12 10:19:43 +02:00
bunkerity
0ad5159a33
docs - add changelog for next version 2021-08-11 16:54:23 +02:00
bunkerity
6240d8e28d
ui - read variables.env when Linux is used 2021-08-11 16:37:01 +02:00
bunkerity
2f80f64dd5
docs - last polish 2021-08-11 16:26:35 +02:00
bunkerity
e98da9b637
docs polishing and fix install.sh gpg --verify 2021-08-11 15:13:44 +02:00
bunkerity
d9f7706969
docs - web UI 2021-08-11 11:51:13 +02:00
bunkerity
75f299978c
docs - special folders 2021-08-11 10:16:34 +02:00
bunkerity
ef34b2cec1
docs quickstart / multisite 2021-08-11 09:43:31 +02:00
florian
9b9110214a
docs - quickstart guide / php 2021-08-11 00:34:57 +02:00
florian
9e2a8070e4
docs - quickstart guide / reverse proxy 2021-08-10 23:39:28 +02:00
florian
733136ac1a
docs - init quickstart 2021-08-10 22:41:45 +02:00
florian
fa172ce5a9
docs - linux integration 2021-08-10 21:13:17 +02:00
bunkerity
f6a9184ae9
docs - k8s integration 2021-08-10 17:04:17 +02:00
bunkerity
d37dc2b629
docs - swarm integration 2021-08-10 15:01:03 +02:00
bunkerity
f7c115edff
docs - add autoconf doc to Docker section 2021-08-10 12:03:59 +02:00
bunkerity
dfbb091361
docs - init integrations/Docker 2021-08-10 10:41:34 +02:00
florian
8e4a65feca
fix global.env generation and add web UI gif to README 2021-08-09 20:56:52 +02:00
bunkerity
0573ba7b5a
ui - centering things without breaking sticky navbar and menu 2021-08-09 17:10:26 +02:00
florian
bcd421de09
ui - various bug fixes more or less related to UI 2021-08-09 13:19:10 +02:00
florian
2ec28c79cb
docs - fix README toc 2021-08-08 00:30:54 +02:00
florian
fec60a4b14
ui - minor styling fixes 2021-08-08 00:04:56 +02:00
florian
dd7d1a2c78
ui - fix example, subpath behind reverse proxy and add socket proxy rights for swarm 2021-08-07 21:56:08 +02:00
florian
0c1883472d
docs - edit kubernetes overview image and add configuration section on the readme 2021-08-07 20:02:47 +02:00
florian
4e6eab794d
docs - fix wrong swarm image 2021-08-06 23:19:50 +02:00
florian
b23135b663
docs - add docker and kubernetes images 2021-08-06 23:15:24 +02:00
bunkerity
ace9be3979
docs - add autoconf and swarm images 2021-08-06 16:51:46 +02:00
bunkerity
8958e5107c
docs - add overview image 2021-08-06 11:55:24 +02:00
florian
b2cfc15c2a
security - add security policy 2021-08-05 23:25:50 +02:00
bunkerity
94bef079a8
examples - add architecture images 2021-08-05 17:05:31 +02:00
bunkerity
50266c2285
examples - add the last missing README.md stubs 2021-08-05 09:48:27 +02:00
florian
22e2fe869f
examples improvement - added some README.md stubs 2021-08-05 00:10:21 +02:00
bunkerity
55186bbef5
examples improvement - hardened, joomla, kubernetes, load-balancer and moodle 2021-08-04 16:54:59 +02:00
bunkerity
d8286ced7c
examples improvement - certbot cloudflare and wildcard, clamav, crowdsec, ghost and gogs 2021-08-04 15:02:55 +02:00
bunkerity
44de2253d2
examples improvement - traefik alternative, autoconf reverse proxy and basic website 2021-08-04 12:01:07 +02:00
bunkerity
6d73fbdedb
examples - update authelia and autoconf-php 2021-08-04 10:47:38 +02:00
florian
b6809266af
autoconf - let's encrypt support for ingress controller 2021-08-03 22:38:00 +02:00
bunkerity
4e178b474c
autoconf - basic ingress controller support for kubernetes 2021-08-03 16:39:39 +02:00
bunkerity
021147f9d9
autoconf - fix wait and redis 2021-08-02 16:37:50 +02:00
bunkerity
5a26d06c87
autoconf - fix infinite lock and honor DOCKER_HOST env var 2021-08-02 11:52:00 +02:00
bunkerity
bc01427def
ignore CVE-2021-36159 and redirect job logs as root when using autoconf 2021-08-02 10:41:46 +02:00
florian
652614f41b
autoconf - use DNS for Swarm instances discovery 2021-08-01 23:10:29 +02:00
bunkerity
24d9cce82f
autoconf - various bug fixes in Swarm mode 2021-07-30 17:08:54 +02:00
bunkerity
f866ef6325
autoconf - minor fixes, prepare Swarm testing 2021-07-29 17:32:33 +02:00
bunkerity
1a32e7c02c
autoconf - various bug fixes with DockerController 2021-07-29 15:43:51 +02:00
bunkerity
7180378d0c
autoconf - init Config refactoring 2021-07-29 10:19:34 +02:00
florian
6e66571fb9
various cleaning 2021-07-28 23:25:05 +02:00
florian
f44e41cede
jobs - lock and reload management 2021-07-28 23:04:56 +02:00
bunkerity
26db144df4
autoconf refactoring and fix CVE-2021-36159 2021-07-28 17:27:39 +02:00
bunkerity
a68ad53c3f
autoconf - controller classes 2021-07-28 15:52:35 +02:00
bunkerity
01bba1d3f6
autoconf - init refactoring before k8s integration 2021-07-28 11:56:45 +02:00
bunkerity
0597074438
k8s - init work on parsing ingress rules, helpers to setup on k8s, basic examples 2021-07-27 17:15:39 +02:00
bunkerity
bc3c17a2f0
examples - init k8s example 2021-07-27 12:03:31 +02:00
bunkerity
556836b499
autoconf - init annotations parser for k8s 2021-07-27 09:56:58 +02:00
bunkerity
22612f1757
minor edit on Linux tests and init work on k8s API 2021-07-26 17:15:24 +02:00
bunkerity
50c279617b
jobs - improved log and reload management 2021-07-23 17:28:05 +02:00
bunkerity
ef8969e2cf
certbot - add USE_LETS_ENCRYPT_STAGING=yes/no env var for using staging or production servers of let's encrypt 2021-07-23 11:51:50 +02:00
bunkerity
0dc2a5ec25
edit visibility of Job members and integration of a generic checker for nginx 2021-07-22 23:07:35 +02:00
bunkerity
9a207dfdc5
fix missing import in generator, expand networks to ips in jobs and init work on a generic checker with shared dict and redis support 2021-07-22 17:11:15 +02:00
bunkerity
a60fbbb5b3
hotfix - fix CVE-2021-33560 2021-07-22 14:50:09 +02:00
bunkerity
a1b9010d9e
pull v1.2.8 fixes when applicable 2021-07-22 14:47:37 +02:00
bunkerity
3178545c2f
v1.2.8 release 2021-07-22 14:36:07 +02:00
bunkerity
36b8760d4d
resolve bugs on the stable version 2021-07-22 12:12:55 +02:00
bunkerity
8bb6676f58
settings - fix PHP_* again 2021-07-22 09:58:17 +02:00
bunkerity
4234f82c01
settings - edit EMAIL_LETS_ENCRYPT regex 2021-07-22 09:47:34 +02:00
bunkerity
b99fb27df5
fix missing parameter when calling reload in autoconf and edit REMOTE_PHP_PATH regex 2021-07-22 09:29:15 +02:00
bunkerity
876fcd1814
conf - add WORKER_PROCESSES 2021-07-21 22:18:02 +02:00
bunkerity
26dc796155
jobs - fix line edit 2021-07-21 22:14:05 +02:00
bunkerity
280d189864
jobs - avoid reload when not necessary 2021-07-21 17:09:42 +02:00
bunkerity
5f845680ff
jobs - edit referrers and user-agents data and init work on autoconf integration 2021-07-21 14:42:55 +02:00
bunkerity
d12369c900
jobs - various bugs fixed and old files removed 2021-07-21 11:55:14 +02:00
bunkerity
366e39f591
jobs - SelfSignedCert, runner and reloader 2021-07-20 22:52:01 +02:00
bunkerity
71741b2d34
jobs - cache management 2021-07-20 14:34:39 +02:00
bunkerity
2fca4cd014
jobs - logging and error management 2021-07-20 12:14:50 +02:00
bunkerity
fccf14627f
jobs - python stubs 2021-07-20 11:41:31 +02:00
bunkerity
b3684efaf6
jobs - init work on refactoring 2021-07-20 09:58:09 +02:00
bunkerity
82548378ae
crowdsec - move as external plugin 2021-07-16 10:05:53 +02:00
bunkerity
b926b0db62
examples - use example.com instead of website.com 2021-07-16 09:40:02 +02:00
bunkerity
6713f56ec1
linux - fix centos install 2021-07-15 17:20:15 +02:00
bunkerity
2b923c05c1
compile and install LUA 5.1.5 to /opt/bunkerized-nginx/deps and introduced REDIRECT_TO feature 2021-07-15 16:36:26 +02:00
bunkerity
71cf3cf5c1
use local sources when building Docker image, add LOCAL_PHP and LOCAL_PHP_REMOTE to settings.json and fix pip bug related to removed working directory 2021-07-13 11:00:18 +02:00
bunkerity
8e3dbf1c70
fixed some fedora bugs, support LOCAL_PHP and LOCAL_PHP_PATH and sample variables.env 2021-07-12 22:21:13 +02:00
bunkerity
49ada6a8c5
linux - init work on fedora support 2021-07-12 16:57:57 +02:00
bunkerity
947e86f7c3
linux - uninstall script 2021-07-12 15:56:01 +02:00
bunkerity
a12561a85b
remove useless nginx-keys folder and add lua_package_cpath to http conf 2021-07-12 15:08:37 +02:00
bunkerity
6b19bd0264
deps - add cjson LUA files to deps folder 2021-07-11 23:53:54 +02:00
bunkerity
6738b28b99
deps - move dependencies to dedicated /opt/bunkerized-nginx/deps folder to avoid messing with the system 2021-07-11 23:41:33 +02:00
bunkerity
010c0fd6d4
rename gen/requirements.py to requirements.txt, add git/bash to Docker deps and fix typos in README 2021-07-11 17:58:35 +02:00
bunkerity
ecf30a71f7
deps - init work on single install script 2021-07-11 16:45:15 +02:00
bunkerity
ffc4fc950e
deps - manual compile/install of libmaxmind and upgrade lua-resty-core 2021-07-11 15:33:40 +02:00
Florian Pitance
b9955699b7
Merge pull request #152 from thelittlefireman/patch-11
Upgrade deps
2021-07-11 13:57:39 +02:00
thelittlefireman
860fd1ace5
Upgrade desps
luajit2 to v2.1-20210510
upgrade lua-resty-core to 0.1.22
lua-resty-dns to 0.22
lua-resty-lrucache to 0.11
lua-resty-session to 3.8
lua-resty-string to 0.14
lua-resty-http to 0.16.1
Upgrade from https://github.com/Neopallium/lualogging to https://github.com/lunarmodules/lualogging.git
luasec to 1.0.1
2021-07-10 22:24:16 +02:00
thelittlefireman
eb5d13fb8d
Upgrade lua-nginx module to 0.10.20 2021-07-10 22:05:44 +02:00
thelittlefireman
ca41987cd6
Upgrade corerules to 3.3.0 & modsecurity to 3.0.5 2021-07-10 21:53:54 +02:00
bunkerity
3af1b397fa
UI - digging bugs from services, still some work to do 2021-07-09 16:58:55 +02:00
bunkerity
72a09eac6d
UI - add CSRF protection 2021-07-09 16:01:51 +02:00
bunkerity
0d3f7d3925
UI - admin authentication and bootstrap update 2021-07-09 14:17:50 +02:00
bunkerity
6be082e0a9
UI - init work on admin account 2021-07-09 12:18:42 +02:00
bunkerity
4947796c99
UI - fix instances bugs 2021-07-09 11:26:23 +02:00
bunkerity
ba197dfa43
UI - bind gunicorn to 127.0.0.1/0.0.0.0:5000 2021-07-09 10:55:09 +02:00
bunkerity
4dd1ff8479
UI - copy from helpers, systemd service and instances page update 2021-07-09 10:27:38 +02:00
bunkerity
f771ec43f1
ui - init Instances class to support Linux and API for Docker/Swarm 2021-07-08 23:45:58 +02:00
bunkerity
e241b0c939
logs - move everything from /var/log to /var/log/nginx 2021-07-07 14:36:00 +02:00
bunkerity
d03a1a6e3b
linux - add jobs.log 2021-07-07 13:47:37 +02:00
bunkerity
2c9c9fb62c
linux - run master process as root 2021-07-07 13:38:13 +02:00
bunkerity
deb28c5991
autoconf - fix folders 2021-07-05 17:40:26 +02:00
bunkerity
2ea7331dad
jobs - disable post-jobs when SWARM_MODE=yes on SIGHUP 2021-07-05 16:49:27 +02:00
bunkerity
92ee40819e
whitelist - fix /.well-known/acme-challenge whitelist for let's encrypt 2021-07-05 14:15:25 +02:00
bunkerity
2ccfb26e81
docker - fix CVE-2021-33560 2021-07-02 11:16:19 +02:00
bunkerity
70f9f8417e
templates - add missing new line when necessary 2021-07-02 09:48:57 +02:00
bunkerity
c4aef1d606
authelia - choose portal or auth basic mode 2021-06-29 20:32:15 +02:00
bunkerity
a385183d88
authelia - various fixes 2021-06-29 17:14:57 +02:00
bunkerity
cec47f3a75
body injection feature and add authelia to documentation 2021-06-29 16:36:24 +02:00
bunkerity
c894c8370e
authelia - add variables to settings.json 2021-06-29 16:00:47 +02:00
bunkerity
f73b088f79
authelia - initial work 2021-06-29 15:52:56 +02:00
Florian Pitance
130c6752dd
Merge pull request #148 from aFresquetIntech/dev
zammad example
2021-06-28 17:13:37 +02:00
alexis
f97ea67855 Create .env 2021-06-28 16:22:01 +02:00
alexis
8504299861 Correction
Modification nom fichier

Correction des lignes 126 à 130
2021-06-28 15:22:57 +02:00
alexis
4a8da40cf2 reverse-proxy-zammad 2021-06-28 09:42:52 +02:00
bunkerity
0114c7b09f
examples - edit basic PHP 2021-06-24 21:32:49 +02:00
bunkerity
bebe89afb0
linux - edit path for default errors, ignore comments in variables.env, install/prepare certbot 2021-06-24 15:22:57 +02:00
bunkerity
b2cceb608c
linux - fix centos 2021-06-23 16:58:24 +02:00
bunkerity
37f5e4ed71
linux - fixed debian/ubuntu but still some work needed on centos 2021-06-23 15:46:04 +02:00
bunkerity
98568a57c9
linux - fix /var/log and typo in daemon directive 2021-06-23 14:26:33 +02:00
bunkerity
4991922878
linux - fix daemon directive and rights on /etc/nginx 2021-06-23 14:06:39 +02:00
bunkerity
bcb8acc364
linux - add RX permissions to /opt 2021-06-23 12:16:31 +02:00
bunkerity
a9279053a4
linux - add executable right to gen/main.py 2021-06-22 22:02:42 +02:00
bunkerity
60057a17e3
linux - fix tests docker cp and pass single -c argument to su 2021-06-22 21:56:10 +02:00
bunkerity
d0366fcc0d
linux - started work on bunkerized-nginx command 2021-06-22 21:19:12 +02:00
bunkerity
b448d91ca8
actions - fix centos test and docker image name when pushing 2021-06-22 13:59:42 +02:00
bunkerity
e309ce6fd5
docker - fix permissions on /opt 2021-06-22 10:58:07 +02:00
bunkerity
37090dc66e
actions - fix manifest error with buildx and load 2021-06-22 10:35:29 +02:00
bunkerity
6bb6facd88
add load: true when autobuilding images and move from /bin/sh to /bin/bash 2021-06-22 10:16:20 +02:00
bunkerity
a1fcbd4b83
fix actions and configure 2021-06-21 18:27:12 +02:00
bunkerity
09a2a4f9e5
github actions refactoring 2021-06-21 15:32:13 +02:00
bunkerity
1e02368e8a
linux/docker - common /opt/bunkerized-nginx folder 2021-06-21 14:56:48 +02:00
bunkerity
bbb5134a39
fix configure arguments and CRS include 2021-06-20 21:51:57 +02:00
bunkerity
b0f93fb840
fix Dockerfile again 2021-06-19 22:15:42 +02:00
bunkerity
c892f037db
fix Dockerfile 2021-06-19 22:06:00 +02:00
bunkerity
731c0f61df
linux - init work on installer 2021-06-19 22:03:14 +02:00
bunkerity
93543d3962
Linux - use the same dependencies script for Docker 2021-06-18 17:04:22 +02:00
bunkerity
5ec9e6ab49
linux - CentOS 7 install 2021-06-18 14:58:41 +02:00
bunkerity
cc0d0af8d2
linux - ubuntu installer 2021-06-18 12:22:19 +02:00
bunkerity
43d2097d14
linux - nginx install on Debian 2021-06-17 21:33:16 +02:00
bunkerity
f880e5e2aa
linux - continued work on install helpers for Debian 2021-06-16 21:26:55 +02:00
bunkerity
9636013f5e
linux - started work on installer 2021-06-16 17:46:20 +02:00
bunkerity
15bdb076c8
hotfix - fix docs get_git_branch 2021-06-15 17:10:34 +02:00
bunkerity
d62c4f466d
v1.2.7 release 2021-06-15 16:53:37 +02:00
bunkerity
ad52ef3260
autoconf - prevent race condition by checking health state 2021-06-15 09:52:33 +02:00
Bunkerity
3bd3b6fd7a
Merge pull request #145 from thelittlefireman/patch-10
Upgrade ModSecurity-nginx to v1.0.2 - @thelittlefireman
2021-06-15 08:42:42 +02:00
thelittlefireman
e41acc20c2
Upgrade ModSecurity-nginx to v1.0.2 2021-06-15 00:01:23 +02:00
bunkerity
3c721dc2a0
add HEALTHCHECK to Dockerfile and append 10.0.0.0/8 to DNSBL whitelist 2021-06-14 20:54:36 +02:00
bunkerity
491d879fec
jobs - cleaning the mess when using autoconf without swarm mode 2021-06-14 17:58:38 +02:00
bunkerity
52534510ec
fix bug when AUTO_LETS_ENCRYPT=yes and certbot can't resolve challenges 2021-06-14 14:59:27 +02:00
bunkerity
2c7337576d
jobs - fix syntax error 2021-06-14 13:39:27 +02:00
bunkerity
9e4961ccb5
docs - rename sitemap to bypass rtd rewrite 2021-06-14 10:21:30 +02:00
bunkerity
01857d8ac0
gen - display the reason when ignoring a variable 2021-06-14 09:58:04 +02:00
bunkerity
ab9f9e0a4c
jobs - fix jobs when MULTISITE=yes 2021-06-14 09:02:16 +02:00
bunkerity
29dc64ca30
actions - add Docker cache to speedup auto build on the dev branch 2021-06-11 15:14:10 +02:00
bunkerity
b5cd4e0375
docker - build and push images from GitHub actions because of future DockerHub restrictions on autobuild 2021-06-11 13:39:39 +02:00
bunkerity
16101144c5
self-signed cert - fix bugs 2021-06-11 11:39:36 +02:00
bunkerity
95510e6e1d
settings - add underscore to CUSTOM_HTTPS_CERT/KEY regex 2021-06-11 11:08:35 +02:00
bunkerity
dd5890e760
geoip - fix bug when using GeoIP 2021-06-11 11:01:13 +02:00
bunkerity
c3a437fa82
docs - rename the sitemap to avoid conflicts ? 2021-06-08 09:31:28 +02:00
bunkerity
518ddd3236
docs - custom robots.txt 2021-06-08 09:18:28 +02:00
bunkerity
177a82ee6e
docs - automated sitemap.yml 2021-06-08 09:06:21 +02:00
bunkerity
39db7b368f
v1.2.6 release 2021-06-07 10:30:33 +02:00
bunkerity
9442e59141
jobs - fix jobs in Swarm mode 2021-06-07 09:48:50 +02:00
bunkerity
fcc6b3b5e4
various bug fixes related to Swarm 2021-06-06 23:22:33 +02:00
florian
678ad70b01
docs, various fixes and certbot-cloudflare example 2021-06-06 14:52:30 +02:00
florian
e8f5db0b29
docs - add plugins system 2021-06-05 11:24:35 +02:00
florian
8295f6aeba
plugins - clamav example 2021-06-05 00:29:24 +02:00
bunkerity
388fc1a0e8
plugins - started basic plugin system 2021-06-04 17:42:34 +02:00
bunkerity
62217a3210
add contributing guidelines and license 2021-06-04 10:08:11 +02:00
Bunkerity
53e433b1a4
readme - replace some badges 2021-06-03 23:37:10 +02:00
Bunkerity
f640157b1f
Merge pull request #138 from bunkerity/feature-request-template
Update issue templates
2021-06-03 22:31:33 +02:00
Bunkerity
d646f3e5b7 Update issue templates 2021-06-03 22:30:31 +02:00
bunkerity
4b31d005eb
crowdsec and generator fixes 2021-06-03 17:44:12 +02:00
bunkerity
d2135c19c0
docs - road to v1.2.6 2021-06-02 17:47:00 +02:00
bunkerity
8cda1baf77
fix web ui multiple variables and add default error pages 2021-06-02 15:33:42 +02:00
bunkerity
445032406b
dnsbl - disable checks when IP is local 2021-06-02 13:46:57 +02:00
bunkerity
74fb015366
web UI - init work on using docker-socket-proxy 2021-06-02 12:12:30 +02:00
bunkerity
ee178de6ab
web ui - mostly finished templating integration (needs some testing) 2021-06-01 15:22:03 +02:00
bunkerity
7323525b69
ui - show only multisite vars for settings 2021-06-01 10:54:59 +02:00
bunkerity
82e47f147d
ui - Dockerfile fixes and missing get_config function 2021-05-31 21:06:05 +02:00
bunkerity
2db967ad1d
templating - road to web ui 2021-05-31 17:49:37 +02:00
florian
1d96620ae6
templating - init integration into web ui 2021-05-31 09:48:26 +02:00
bunkerity
99c259bf18
templating - prepare integration into ui 2021-05-28 16:41:41 +02:00
bunkerity
c7b81cfc10
various bug fixes related to HTTPS 2021-05-28 14:57:45 +02:00
bunkerity
dfce0c06dd
autoconf - fixing various bug when SWARM_MODE=yes 2021-05-28 12:16:56 +02:00
bunkerity
0f8e56a668
templating - fixing bugs with autoconf 2021-05-27 14:41:21 +02:00
bunkerity
f950abdc24
templating - started integration into autoconf 2021-05-27 12:34:00 +02:00
bunkerity
4a73ae8197
various bug fixes on templates and nginx update to 1.20.1 2021-05-27 09:53:14 +02:00
bunkerity
e2f02ee91e
templating - prepare integration for autoconf 2021-05-26 20:50:03 +02:00
bunkerity
a991b262ef
remove ClamAV because of GPL and started work on read-only filesystem 2021-05-26 17:18:49 +02:00
bunkerity
a8bc17e836
templating - started integration into docker image 2021-05-26 14:50:50 +02:00
bunkerity
ec19f93081
templating - added missing features in site templates 2021-05-25 17:07:06 +02:00
bunkerity
23aa053003
templating - auth basic support 2021-05-25 12:18:40 +02:00
bunkerity
289ad106cb
templating - multisite support 2021-05-25 11:43:03 +02:00
bunkerity
bbc5bbc9e9
templating - fix some site templates 2021-05-24 20:52:17 +02:00
bunkerity
633a07686f
templating - init work on site templates 2021-05-24 17:39:38 +02:00
bunkerity
996c45df42 templating - init work on global templates 2021-05-21 17:12:13 +02:00
bunkerity
801530baf3
templating - road to full jinja2 templates 2021-05-21 14:55:54 +02:00
bunkerity
c65dda3917
templating - init work on templating with jinja2 2021-05-21 11:54:37 +02:00
bunkerity
ea891969c1
templating - updated settings.json with global settings 2021-05-20 14:48:45 +02:00
bunkerity
698ae17c49
templating - init work on generic settings management 2021-05-20 12:27:35 +02:00
bunkerity
6645632846
antibot - basic pow with javascript 2021-05-19 17:36:29 +02:00
bunkerity
16e5ede130
antibot - custom templates 2021-05-19 16:37:28 +02:00
bunkerity
8260746fe1
logs/lua - add logger tool 2021-05-19 11:11:18 +02:00
florian
de560490d3
fix LUA array variables and add LOG_LEVEL to the troubleshooting section 2021-05-19 09:18:38 +02:00
florian
96db3a450d
log - add LOG_LEVEL variable 2021-05-18 21:51:13 +02:00
florian
73543f4b0e
hardening - add no-new-privileges 2021-05-18 21:35:58 +02:00
bunkerity
d9bb97be50
lua - move global vars from lua to site config (untested) 2021-05-18 17:29:00 +02:00
bunkerity
863283d090
started work on moving variables from .lua to nginx 2021-05-18 15:14:45 +02:00
bunkerity
600484b16e
crowdsec - fix bugs and update example 2021-05-18 14:03:16 +02:00
bunkerity
7c6a13c549
examples - improve nextcloud example so it works with webdav clients 2021-05-17 10:26:35 +02:00
bunkerity
b3bb4ec40f
remove unnecessary dependencies and update doc about certificate bundle 2021-05-15 21:55:57 +02:00
bunkerity
69f4657208
examples - fix typo BAD_BEHAVIOR_STATUS_CODES 2021-05-15 21:29:07 +02:00
bunkerity
d02985d213
check permissions for missing volumes and add comment about permissions on examples 2021-05-15 21:08:35 +02:00
bunkerity
b0ca85ff75
v1.2.5 - performance improvement 2021-05-14 16:42:08 +02:00
Bunkerity
2f115c444d
Merge pull request #131 from bunkerity/issue-templates
Update issue templates
2021-05-14 16:37:37 +02:00
Bunkerity
7f15741ea2 Update issue templates 2021-05-14 16:33:01 +02:00
bunkerity
288b8eb851
docs improvement + road to v1.2.5 2021-05-14 15:41:15 +02:00
bunkerity
61c08fb97b
docs - troubleshooting 2021-05-14 12:12:33 +02:00
bunkerity
01ef47a669
docs - security tuning improvement 2021-05-14 11:15:00 +02:00
florian
71515a9101
doc - volumes list 2021-05-13 20:34:41 +02:00
bunkerity
a33d0658c6
docs - road to a beautiful documentation 2021-05-13 17:46:31 +02:00
bunkerity
0b3ff6a9f4
bad behavior - move from fail2ban to pure lua 2021-05-13 16:21:51 +02:00
bunkerity
eb2d0d330d
performance - rsyslog and fail2ban removing 2021-05-13 11:14:39 +02:00
bunkerity
5bcbb38638
doc - official document started 2021-05-12 17:35:32 +02:00
bunkerity
ca660b2501
init work on official doc 2021-05-12 12:28:01 +02:00
bunkerity
3a34436cd8
add AquaeAtrae example for ROOT_SITE_SUBFOLDER 2021-05-12 12:07:29 +02:00
bunkerity
b1d03cd11c
performance - move bad user-agents and referrers checks from nginx to LUA with caching 2021-05-11 15:30:16 +02:00
bunkerity
42c3fb8740
add sandbox allow-downloads to the default value of CONTENT_SECURITY_POLICY 2021-05-11 08:57:23 +02:00
bunkerity
f1c043604a
add missing backslash in the quickstart guide and update autoconf examples with the depends_on directive 2021-05-11 08:54:34 +02:00
bunkerity
fd61df205f
performance - move external blacklists checks from nginx to LUA 2021-05-10 17:51:07 +02:00
bunkerity
009d6fb5ae
choose connection and nofile numbers, increase error_log level to get modsecurity rules, add MODSECURITY_SEC_AUDIT_ENGINE var 2021-05-05 17:38:22 +02:00
bunkerity
ba4185a42e
jobs - fix automatic reload 2021-05-03 14:18:10 +02:00
bunkerity
70976d0fbc
fix user-agent not blocking and add documentation on bundle when USE_CUSTOM_HTTPS=yes 2021-05-03 13:59:55 +02:00
bunkerity
062a39c63a
integrate AquaeAtrae work - add ROOT_SITE_SUBFOLDER 2021-05-03 10:31:37 +02:00
bunkerity
83841b290a
jobs - edit adren work on external blacklists 2021-05-02 16:14:13 +02:00
Bunkerity
10dc58cb6d
Merge pull request #126 from adren/patch-6
deduplicate list of user-agents
2021-05-02 15:14:10 +02:00
Bunkerity
668754686c
Merge pull request #125 from adren/patch-5
more optimized way to generate map referrer file
2021-05-02 15:13:17 +02:00
Bunkerity
84b1933f63
Merge pull request #124 from adren/patch-4
improve the generation of blocking file (abusers)
2021-05-02 15:12:19 +02:00
Bunkerity
15f6d0a32a
Merge pull request #123 from adren/patch-3
improve generation of block file (Tor exit nodes)
2021-05-02 15:11:27 +02:00
Bunkerity
e628361a89
Merge pull request #122 from adren/patch-1
huge improvement to generate blocking file
2021-05-02 15:10:52 +02:00
Cyril Chaboisseau
f8d71e067e
improved way to generate user-agent file 2021-05-01 19:04:18 +02:00
Cyril Chaboisseau
02ae3b6bd3
change IFS before subshell
There needs to be a change in IFS before the 2 curl commands in order to keep line by line formatting
2021-05-01 15:48:33 +02:00
Cyril Chaboisseau
2fb0e7c473
deduplicate list of user-agents 2021-05-01 15:08:52 +02:00
Cyril Chaboisseau
9adcc2f1a7
more optimized way to generate map referrer file 2021-05-01 14:51:28 +02:00
Cyril Chaboisseau
7b98db4d14
improve the generation of blocking file (abusers) 2021-05-01 12:29:15 +02:00
Cyril Chaboisseau
ddb2b85916
improve generation of block file (Tor exit nodes) 2021-05-01 12:25:43 +02:00
Cyril Chaboisseau
da1a460a64
huge improvement to generate blocking file
process the file in 2 commands (grep + sed) instead of a loop running on each line
the time to generate the file takes 0.235 seconds instead of one hour, making it roughly 15,000 times quicker
the output file is exactly the same as with the former method
2021-05-01 11:42:07 +02:00
bunkerity
07be626842
hotfix - fix API in autoconf swarm mode 2021-04-28 17:40:54 +02:00
bunkerity
3bb164395e
hotfix - move API_WHITELIST_IP edit to lua.sh 2021-04-28 17:00:50 +02:00
bunkerity
bc2568a172
v1.2.4 - nginx 1.20.0 support 2021-04-27 17:43:38 +02:00
Bunkerity
5ec74880d8
update README for v1.2.4 2021-04-27 17:40:33 +02:00
bunkerity
f84fd7c9a2
fix permissions issues for autoconf and fix volume for ghost example 2021-04-27 16:49:45 +02:00
bunkerity
6521d7a27a
fix client cache so it works in combination with reverse proxy and examples update 2021-04-27 15:31:56 +02:00
bunkerity
813607fbc3
improve crowdsec example and disable modsec logging when not necessary 2021-04-27 11:21:30 +02:00
bunkerity
843644f806
log - replace some WARN tags from LUA logs with NOTICE to avoid confusion 2021-04-27 09:57:07 +02:00
bunkerity
19fa0eb25f
log - print modsec_audit.log to make debugging easier 2021-04-27 09:46:40 +02:00
bunkerity
b4df287228
log - send logs to remote syslog server 2021-04-27 09:30:10 +02:00
florian
5ce41edc03
api - whitelist IP/network for API 2021-04-26 22:22:34 +02:00
florian
a3cfb50b4d
example - fix certbot wildcard 2021-04-26 21:34:18 +02:00
bunkerity
25494acace
example - wildcard certificate with certbot 2021-04-26 17:44:48 +02:00
bunkerity
a98dae1fb6
fix CVE-2021-20205 and examples update 2021-04-26 17:00:23 +02:00
bunkerity
1a7abab570
nginx 1.20.0 support 2021-04-26 14:59:12 +02:00
florian
42b7a57f01
fix autoconf bug when removing config with multiple server name and increase default LIMIT_CONN_MAX for average website with HTTP2 2021-04-26 11:39:12 +02:00
bunkerity
02f9fbe5fc autoconf - fix certbot bug when multiple server_name for one service 2021-04-20 11:46:53 +02:00
bunkerity
69fe066777 autoconf - fix bug when multiple server_name for one service 2021-04-20 10:00:25 +02:00
bunkerity
74417abc9c fixing bugs - run as GID 101 instead of 0, different permissions checks in swarm mode and disable including server confs in swarm mode 2021-04-16 16:56:45 +02:00
bunkerity
ba7524a419 fixed LUA bug 2021-04-13 17:27:52 +02:00
bunkerity
b55aafb997 finding the LUA bug 2021-04-13 17:01:27 +02:00
Bunkerity
deeb7a76a2
Merge pull request #117 from thelittlefireman/patch-9
Fix lua mistake
2021-04-13 16:49:45 +02:00
thelittlefireman
ee8aaa4e7e
fix lua crash 2 2021-04-11 15:45:46 +02:00
thelittlefireman
605d59a45c
Fix lua mistake
#116
2021-04-11 15:33:31 +02:00
bunkerity
b85c991b6e bug fixes - /usr/local/lib/lua rights and syntax error in site-config 2021-04-09 17:40:19 +02:00
bunkerity
0d3658adf0 REVERSE_PROXY_HEADERS - use proxy_set_header instead of more_set_headers 2021-04-09 17:27:22 +02:00
bunkerity
0b22209c96 documentation - userns remap feature 2021-04-09 16:22:31 +02:00
bunkerity
e44a1f3e14 added the uri to limit_req_zone key to limit bruteforce attack on a specific resource instead of the whole service 2021-04-09 15:54:26 +02:00
bunkerity
aa614f82f9 print error when permissions are wrong on common volumes 2021-04-09 14:54:15 +02:00
bunkerity
c03d410b0a refactored whitelisting of user-agents 2021-04-09 14:23:52 +02:00
bunkerity
e190167bfc CIDR support with whitelist/blacklist IP 2021-04-09 14:10:17 +02:00
bunkerity
31e72dce1c fix /usr/local/lib/lua rights and multiple server_name support with autoconf 2021-04-09 11:37:13 +02:00
bunkerity
b8105fc558 feature - whitelist URI 2021-04-09 10:31:00 +02:00
bunkerity
e73c10fd80 crowdsec - fix permissions on /usr/local/lib/lua and on /var/log files 2021-04-09 10:01:23 +02:00
bunkerity
a122a259c0 minor fix on AutoConf logs and auto disable etag with reverse proxy 2021-04-09 09:51:17 +02:00
bunkerity
7c4894d3b8 autoconf - fix remove event, generate config from nginx vars, more logs 2021-03-26 15:18:35 +01:00
bunkerity
533c2a1034 fix sed script when writing site env 2021-03-22 09:38:36 +01:00
bunkerity
5611d544d6 remove reference to USE_PHP 2021-03-19 09:38:44 +01:00
bunkerity
397182f18d add link to twitter account 2021-03-18 18:11:52 +01:00
bunkerity
c5c5fb17b5 v1.2.3 - swarm support 2021-03-18 18:08:42 +01:00
bunkerity
017a7780fb README update, default cron update and new parameters to ui 2021-03-18 17:11:58 +01:00
bunkerity
34d9db7a8b web ui - bug fixes 2021-03-18 12:34:46 +01:00
bunkerity
361c66ca61 fixed bugs with MULTISITE variables and swarm example 2021-03-18 10:29:37 +01:00
bunkerity
afc6678855 road to v1.2.3 - fixing bugs 2021-03-17 17:55:56 +01:00
bunkerity
c40fb33175 road to swarm - automatic reload after jobs 2021-03-17 12:16:56 +01:00
bunkerity
93ad3c0b51 road to swarm - let's encrypt fix 2021-03-17 10:37:20 +01:00
bunkerity
ceed904882 road to swarm - still some mess to fix 2021-03-16 17:56:24 +01:00
Bunkerity
b8027d2bac
Merge pull request #102 from thelittlefireman/proxy_custom_headers
[NEED TESTING] Enhancement add custom proxy headers #97
2021-03-16 10:08:05 +01:00
Bunkerity
8d03a14a6a
Merge pull request #103 from thelittlefireman/fix_truncated_3
Fix truncated 3
2021-03-16 10:06:05 +01:00
thelittlefireman
d16f4517a4 Enhancement add custom proxy headers #97 2021-03-15 23:24:58 +01:00
thelittlefireman
89ca91b3ff Fix truncated variables (last commit) 2021-03-15 22:54:30 +01:00
bunkerity
6a714e2ece road to swarm - fix race condition on initial configuration 2021-03-14 16:50:08 +01:00
bunkerity
0d3da03534 prepare /www directory, fix log socket path and whitelist acme challenges path 2021-03-14 12:33:59 +01:00
bunkerity
33163f65b3 init work on disabling root processes 2021-03-13 22:52:23 +01:00
bunkerity
a2543384cd road to swarm - add openssl to autoconf, fix api_uri in LUA, fix file rights 2021-03-13 15:28:15 +01:00
bunkerity
3591715f21 road to swarm - fixing things 2021-03-12 17:31:26 +01:00
bunkerity
95f7ca5b2d road to swarm support - needs a lot of testing 2021-03-12 15:17:45 +01:00
bunkerity
816fa47cbb introducing SWARM_MODE env var 2021-03-12 12:40:52 +01:00
Bunkerity
7756c2df3c
Merge pull request #98 from mromanelli9/fix/readme
Fix README
2021-03-12 10:44:06 +01:00
bunkerity
7509ec2f2c basic API to be used in swarm mode 2021-03-12 10:42:31 +01:00
Marco Romanelli
6e93575e16
remove ALLOWALL from X_FRAME_OPTIONS options 2021-03-11 14:41:23 +01:00
Marco Romanelli
ba4c977550
remove old anchor 2021-03-11 11:49:46 +01:00
bunkerity
781e4c8cbb autoconf little work on swarm support 2021-03-10 17:24:02 +01:00
bunkerity
e04c783d1e autoconf - init work on swarm mode 2021-03-09 17:33:22 +01:00
bunkerity
e12b656bd5 Merge branch 'patch-7' of https://github.com/thelittlefireman/bunkerized-nginx into dev 2021-03-08 14:06:54 +01:00
bunkerity
cae05447d3 custom crontab values 2021-03-08 13:58:14 +01:00
bunkerity
4b58e22657 Merge branch 'patch-5' of https://github.com/thelittlefireman/bunkerized-nginx into dev 2021-03-08 13:52:35 +01:00
bunkerity
6b56e21a09 Merge branch 'whitelist_ua' of https://github.com/thelittlefireman/bunkerized-nginx into dev 2021-03-08 13:46:28 +01:00
bunkerity
544a09e8da Update lua-cs-bouncer 2021-03-08 12:02:56 +01:00
bunkerity
8386dd4a2a custom config outside server block 2021-03-08 11:53:11 +01:00
root
f052a25168 Merge branch 'pre_server_confs' of https://github.com/thelittlefireman/bunkerized-nginx into dev 2021-03-08 11:47:45 +01:00
Bunkerity
43750f5536
Merge pull request #73 from thelittlefireman/patch-4
Add missing reverse proxy header (X-Forwarded-Host)
2021-03-08 10:16:31 +01:00
Bunkerity
9142afdb54
Merge pull request #72 from thelittlefireman/patch-3
Fix #71 - limit connection by IP
2021-03-08 10:15:14 +01:00
thelittlefireman
66c4fed791
Fix env variable with space are truncated 2
Fix #82
2021-03-05 23:59:38 +01:00
thelittlefireman
f41846e9d6
Fix env variable with space are truncated
Fix #82
2021-03-05 23:56:19 +01:00
thelittlefireman
92cc705b92 Reduce memory usage : set cron tasks at different hours. 2021-03-03 13:02:56 +01:00
thelittlefireman
47fb3a05b3
Upgrade crowdsecurity/lua-cs-bouncer
Upgrade crowdsecurity/lua-cs-bouncer to latest version to include commit dcfba46ccd
2021-03-03 10:01:04 +01:00
thelittlefireman
5940f402c7
improve default tls security 2021-02-28 23:59:22 +01:00
thelittlefireman
d9ca275d53 Add before server {} config. 2021-02-03 14:17:20 +01:00
thelittlefireman
8353bd9c85 Allow to add a whitelist by site on user-agent 2021-02-03 13:51:15 +01:00
thelittlefireman
d902e2f297
Add last missing reverse proxy header
X-Forwarded-Host (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host)[https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host]
2021-01-03 16:28:51 +01:00
thelittlefireman
1a8b8043c8
Add LIMIT_CONN var to server.conf 2021-01-02 14:26:52 +01:00
thelittlefireman
65120a7e97
Add USE_CONN_LIMIT info to Readme.md
and fix small typo
2021-01-02 14:25:34 +01:00
thelittlefireman
b093a47554
Add default values for LIMIT_CONN 2021-01-02 14:18:26 +01:00
thelittlefireman
73dbf03c9a
add USE_LIMIT_CONN zone to global config 2021-01-02 14:15:18 +01:00
thelittlefireman
6ee746236a
Add USE_LIMIT_CONN to site-config 2021-01-02 14:11:36 +01:00
thelittlefireman
fa935eb6e3
edit nginx.conf to add limit_conn 2021-01-02 14:04:34 +01:00
thelittlefireman
cf231e13cb
Add limit-conn.conf 2021-01-02 13:35:18 +01:00
bunkerity
d5d699252c
v1.2.2 - web UI (beta) 2020-12-30 21:22:18 +01:00
bunkerity
50f95420b5
README update - road to v1.2.2 2020-12-30 17:57:00 +01:00
bunkerity
dc382c3e04
various fixes - autoconf process order, multisite config and examples 2020-12-30 16:22:10 +01:00
bunkerity
0026328f25
edit default FAIL2BAN_IGNOREIP subnets 2020-12-30 14:31:16 +01:00
Bunkerity
9023ab5aed
Merge pull request #67 from thelittlefireman/patch-2
Fix #66
2020-12-30 14:28:34 +01:00
thelittlefireman
124474ad66
Edit README.md to add FAIL2BAN_IGNOREIP 2020-12-29 03:47:41 +01:00
thelittlefireman
eac9c8f513
Prepare FAIL2BAN_IGNOREIP to avoid self blocking 2020-12-29 03:43:38 +01:00
thelittlefireman
1ee490de6d
Prepare FAIL2BAN_IGNOREIP to avoid self blocking 2020-12-29 03:41:27 +01:00
bunkerity
825e6a747e
crowdsec v1 integrated 2020-12-28 21:41:30 +01:00
bunkerity
09a984c86b
started crowdsec v1 integration 2020-12-28 18:42:20 +01:00
bunkerity
fd7afa17b3
fix missing ';' in include 2020-12-28 11:43:43 +01:00
Bunkerity
b9b7fdfcc4
Merge pull request #63 from thelittlefireman/patch-1
Fix missing proxy headers
2020-12-28 11:38:07 +01:00
bunkerity
58e1d66bc7
UI - minor alert css fix 2020-12-28 11:37:13 +01:00
bunkerity
7026643f8a
UI - fix missing MULTISITE env var when managing services 2020-12-28 10:20:29 +01:00
bunkerity
06f688fe97
fixed stop and reload operations 2020-12-27 22:25:07 +01:00
bunkerity
c65b78b1cc
UI - instances/services backend update (needs testing) 2020-12-27 17:04:59 +01:00
bunkerity
f9b9b9546f
UI - introduced multiple config parameters (like reverse proxy) in frontend 2020-12-27 14:42:52 +01:00
bunkerity
b5fe6335c7
UI - instances backend started 2020-12-24 14:55:11 +01:00
bunkerity
951f3957fd
UI - default service values 2020-12-24 11:36:19 +01:00
bunkerity
0f520b8914
UI - services backend started 2020-12-23 22:29:50 +01:00
bunkerity
569ad75c42
UI - config.json refactoring 2020-12-23 11:31:37 +01:00
bunkerity
bd7b6af668
UI - load config template from json 2020-12-22 22:35:15 +01:00
bunkerity
459bb8ea1c
UI services modals and default CSP update (fix new tab links) 2020-12-22 11:42:49 +01:00
bunkerity
208b5acb30
UI - minor services list improvement 2020-12-21 17:34:45 +01:00
bunkerity
59b2fed416
UI - basic services list 2020-12-21 15:32:15 +01:00
thelittlefireman
a4871a915e
Add missing proxy headers 2020-12-20 16:21:01 +01:00
thelittlefireman
026783f018
Fix missing reverse proxy headers 2020-12-20 16:19:27 +01:00
thelittlefireman
8115853453
Fix missing proxy headers on site-config.sh 2020-12-20 16:16:26 +01:00
bunkerity
c5f283b00e
UI - minor front update 2020-12-18 17:23:23 +01:00
bunkerity
03ce7a6483
fix modsec double inclusion when MULTISITE=yes 2020-12-18 10:40:05 +01:00
bunkerity
3f7e2c54b3
JOBS - fixed some job script and right temp nginx reload 2020-12-16 18:56:11 +01:00
bunkerity
bb0f46d8af
JOBS - fix job_log 2020-12-16 16:06:36 +01:00
bunkerity
c5b32dfc4c
fix CVE-2020-1971 again 2020-12-16 15:47:02 +01:00
bunkerity
9a4f96ad18
fix CVE-2020-1971 2020-12-16 15:40:38 +01:00
bunkerity
f258426f55
JOBS - fallback to old conf in case reload failed 2020-12-16 15:22:49 +01:00
bunkerity
119e963612
JOBS - be more verbose about jobs failure/success 2020-12-16 11:43:41 +01:00
Bunkerity
373988670a
Merge pull request #54 from thelittlefireman/patch-4
Fix #52
2020-12-16 10:04:21 +01:00
thelittlefireman
2a956f2cd3
Fix #52
Fix #52
2020-12-13 12:39:46 +01:00
bunkerity
15a37a8682
UI - minor UI improvement 2020-12-12 17:28:45 +01:00
bunkerity
3a3d527907
UI - basic read fixes 2020-12-11 17:03:43 +01:00
bunkerity
e6b5f460c9
UI - basic read from docker API 2020-12-11 15:17:18 +01:00
bunkerity
002e3ed2ba
security tests for autoconf and ui 2020-12-11 11:49:22 +01:00
bunkerity
7b55acbe8b
web UI example and CVE-2020-8231 fix again 2020-12-11 11:44:45 +01:00
bunkerity
559b7835d4
ui - automated build 2020-12-11 10:52:44 +01:00
bunkerity
4ea01bd93f
print some logs when blocking bots 2020-12-10 22:36:32 +01:00
bunkerity
a73891a3b8
fix CVE-2020-8231 2020-12-10 21:42:24 +01:00
bunkerity
26199f52c8
remove additional / in modsecurity include 2020-12-10 21:32:44 +01:00
bunkerity
5c3f94a84f
edit reverse proxy var name in README 2020-12-10 21:25:39 +01:00
bunkerity
043fcdc136
autoconf - automated build 2020-12-09 18:30:12 +01:00
bunkerity
b86ded3d1c
autoconf - multi arch Dockerfile 2020-12-09 17:36:39 +01:00
bunkerity
92569679b6
dynamic reload of nginx by sending SIGHUP 2020-12-09 17:00:09 +01:00
bunkerity
15e74e4860
more work on standalone autoconf 2020-12-09 12:00:54 +01:00
bunkerity
fd0a6412d0
init work on standalone autoconf 2020-12-08 23:27:23 +01:00
bunkerity
419fdfc86e
fix auth basic when MULTISITE=yes 2020-12-08 11:29:43 +01:00
bunkerity
0bc1f652b4
v1.2.1 - autoconf feature (beta) 2020-12-07 21:20:13 +01:00
bunkerity
6c7461e298
integrate thelittlefireman work 2020-12-07 17:09:31 +01:00
bunkerity
d01bc5e014 Merge branch 'patch-1' of https://github.com/thelittlefireman/bunkerized-nginx into dev 2020-12-07 17:08:12 +01:00
bunkerity
75c69c8105
last fixes before next release ? 2020-12-07 16:53:00 +01:00
thelittlefireman
e26b8482aa
Add missing EMAIL_LETS_ENCRYPT parameter 2020-12-07 11:31:23 +01:00
bunkerity
f618c73e6c
road to v1.2.1 2020-12-06 22:22:58 +01:00
bunkerity
78c1e5c676
examples - same domains for internal tests 2020-12-05 21:39:48 +01:00
bunkerity
481e10d3ef
reverse proxy - websocket example 2020-12-05 16:43:14 +01:00
bunkerity
aae2a71983
autoconf - php example 2020-12-05 16:30:50 +01:00
bunkerity
f3bf04e390
dirty fix to disable default server when MULTISITE=yes 2020-12-05 16:07:40 +01:00
bunkerity
36cbb927c0
autoconf - various fixes 2020-12-05 11:06:38 +01:00
bunkerity
95153dbc5d
moved UA, referrer and country check after whitelist and blacklist check 2020-12-04 22:58:48 +01:00
bunkerity
26947179a4
moved UA and referrer check to LUA 2020-12-04 22:21:38 +01:00
bunkerity
88f27bfeb8
autoconf - reverse proxy example and pass default vars 2020-12-04 22:06:15 +01:00
bunkerity
3cc1615c4d
fix user-agent script 2020-12-04 21:29:04 +01:00
bunkerity
8bacf722a6 Merge branch 'fix/variable-naming' of https://github.com/mromanelli9/bunkerized-nginx into dev 2020-12-04 17:02:23 +01:00
bunkerity
2bfc4b41fa
first work on automatic configuration 2020-12-04 16:55:09 +01:00
Marco Romanelli
587d4a92eb
incorrect variable naming 2020-12-04 16:38:48 +01:00
bunkerity
c311d0c825
add crawler-detecter bad UA 2020-12-04 10:09:05 +01:00
bunkerity
0d03f49ebc
websocket support with reverse proxy 2020-12-04 09:53:40 +01:00
bunkerity
2112c306a8
custom log format 2020-12-02 16:46:54 +01:00
bunkerity
8f9dcc5ab8
last fix ? 2020-12-02 14:47:08 +01:00
bunkerity
2fe05d3fd3
fixing scripts again and again 2020-12-02 14:31:54 +01:00
bunkerity
db04c0345c
fix referrers again 2020-12-02 13:49:48 +01:00
bunkerity
ed8bd902b1
fix referrers script 2020-12-02 11:09:38 +01:00
bunkerity
3a7aa5d9c0
block bad referrers 2020-12-02 10:41:50 +01:00
bunkerity
9ec9de6ca2
multiple lets encrypt certificates when MULTISITE=yes 2020-12-02 10:17:55 +01:00
bunkerity
791342cbe6
fix LUA DNS code when answers is nil 2020-12-02 10:00:16 +01:00
bunkerity
2f23671c3b
fail2ban fix when MULTISITE=yes 2020-12-02 09:36:56 +01:00
bunkerity
e350a717ff
fix default DNS_RESOLVERS 2020-12-02 09:32:32 +01:00
bunkerity
e818acb0d1
prestashop example 2020-11-29 16:50:53 +01:00
bunkerity
b92f74ed98
dirty fix for CVE-2020-28928 2020-11-29 15:30:12 +01:00
bunkerity
9688e66508
check all vulnerabilities with trivy 2020-11-29 15:10:08 +01:00
bunkerity
700dfc0184
v1.2.0 release 2020-11-23 00:05:22 +01:00
bunkerity
42e4298b5c
readme update - v1.2.0 changes 2020-11-22 23:39:01 +01:00
bunkerity
813b42cfa9
php and nextcloud examples fix 2020-11-22 17:38:07 +01:00
bunkerity
58fcf0a725
added Permissions-Policy header 2020-11-21 16:41:27 +01:00
bunkerity
5879183802
custom headers to remove 2020-11-21 16:21:54 +01:00
bunkerity
2032596880
automatic trivy scan 2020-11-21 15:54:52 +01:00
bunkerity
eaf817d57a
php config and examples fixes 2020-11-18 15:21:08 +01:00
bunkerity
dd7768c856
whitelist/blacklist country at LUA level to avoid SEO issues 2020-11-18 11:37:42 +01:00
bunkerity
fe1d724c9f
country whitelist/blacklist 2020-11-18 11:21:25 +01:00
bunkerity
0635eb368b
various bug fixes 2020-11-15 20:49:43 +01:00
bunkerity
fbf81c94be
cached blacklists data 2020-11-15 15:43:41 +01:00
bunkerity
ed451877ae
examples update and multiple REVERSE_PROXY_* on single site 2020-11-15 14:55:48 +01:00
bunkerity
0f18e9c552
reverse proxy support via env vars 2020-11-14 17:30:38 +01:00
bunkerity
8f7cb5318e
proxy caching support 2020-11-14 16:58:52 +01:00
bunkerity
60fbbc1013
move some http directives to server 2020-11-14 14:19:27 +01:00
bunkerity
0f0593456c
various fixes 2020-11-13 17:57:39 +01:00
bunkerity
8cdc155ac0
multisite examples and certbot renew fix 2020-11-13 15:10:29 +01:00
bunkerity
1abe1da89e
brotli support 2020-11-12 15:03:45 +01:00
bunkerity
f18c054b42
gzip support 2020-11-12 14:37:01 +01:00
bunkerity
4dea1975e2
client caching 2020-11-12 14:02:48 +01:00
bunkerity
c2b05c463c
fix BLOCK_COUNTRY bug and add support for ModSecurity custom confs when multisite=yes 2020-11-11 22:36:22 +01:00
bunkerity
2da51d92a6
multisite - bug fixes 2020-11-11 16:54:27 +01:00
bunkerity
bd7997497b
autotest through github actions 2020-11-10 15:25:49 +01:00
bunkerity
e89e34a84f
auto test fix 2020-11-08 22:08:50 +01:00
bunkerity
ff02878dd8
auto test setup 2020-11-08 21:59:19 +01:00
bunkerity
44b016be93
road to multi server block support 2020-11-08 17:37:48 +01:00
bunkerity
36c4f3e065
v1.1.2 - CrowdSec integration and custom ports 2020-11-06 22:49:18 +01:00
bunkerity
798f6c726d
examples - nextcloud fix and tomcat 2020-11-06 22:24:34 +01:00
bunkerity
761c14a0b8
custom HTTP and HTTPS ports 2020-11-06 17:11:27 +01:00
bunkerity
4a07eca696
crowdsec integration 2020-11-06 16:56:16 +01:00
bunkerity
e1274a6082
passbolt example 2020-11-04 11:16:26 +01:00
Luka TK
3ec81cd849 Fix broken line in README 2020-11-01 22:52:55 +01:00
bunkerity
95752ff0c4
v1.1.1 - TLS 1.2 support 2020-10-30 11:39:01 +01:00
bunkerity
8623510f8c
https fix 2020-10-30 10:56:41 +01:00
bunkerity
95a76b11fa
peterkimzz integration and dhparam 2020-10-30 10:34:18 +01:00
peterkimzz
b0e4740a7d [New Features]
- Added "HTTPS_PROTOCOLS" environment value to enable to customize TLS version. default value is "TLSv1.3". (because TLSv1.2 sometimes needed)
- READMD.md
2020-10-29 12:52:20 +09:00
bunkerity
e843608575
README update - v1.1.0 2020-10-27 22:05:49 +01:00
bunkerity
2f68667893
logrotate copytruncate 2020-10-27 21:33:05 +01:00
bunkerity
1d63838ee6
examples - fix port number 2020-10-26 22:46:15 +01:00
bunkerity
e4bdd4af5d
examples - nextcloud fix and moodle 2020-10-26 22:40:33 +01:00
bunkerity
2c33463af7
renamed logrotate script 2020-10-26 20:51:54 +01:00
bunkerity
9ff210bed8
wordpress and nextcloud examples 2020-10-25 18:30:34 +01:00
bunkerity
0b73018865
install CRS by tag in compile.sh 2020-10-25 16:49:30 +01:00
bunkerity
e1356e3eb0
logrotate.conf update and some cleanup 2020-10-25 16:25:54 +01:00
bunkerity
34a0da444f
logging fix again 2020-10-25 11:24:52 +01:00
bunkerity
022a653ebc
display fail2ban.log and logging bug fix 2020-10-24 20:48:04 +02:00
bunkerity
4c11a9125c
automatic docker tags with VERSION 2020-10-24 16:05:12 +02:00
bunkerity
88b52478c3 automatic Secure flag on cookies 2020-10-23 16:18:55 +02:00
bunkerity
ce82e22dbe remove integrated PHP 2020-10-23 15:52:25 +02:00
bunkerity
397415211e antibot - check IP with sessions and recaptcha 2020-10-23 15:12:52 +02:00
bunkerity
68d7988551 tor hidden service example 2020-10-23 14:58:36 +02:00
bunkerity
16eab0f631 README update 2020-10-23 14:11:46 +02:00
bunkerity
6a22f7711c load balancer example 2020-10-23 13:57:32 +02:00
Bunkerity
222426854e
Merge pull request #13 from FacundoAcevedo/patch-1
Fix typo in the link in the TOC
2020-10-23 10:15:38 +02:00
Facundo Acevedo
d63c57985e
Fix typo in the link in the TOC 2020-10-22 18:23:30 -03:00
bunkerity
e19a7c693d run master nginx process as non-root user 2020-10-21 23:28:48 +02:00
bunkerity
7a8795883b dockerfile fix - compile 2020-10-21 15:12:27 +02:00
bunkerity
01095bd72f gpg fix and secure git clone 2020-10-21 14:59:51 +02:00
bunkerity
0e6729c62e check GPG signature of nginx sources 2020-10-21 11:02:56 +02:00
bunkerity
040b6a2234 Merge branch 'patch-1' of https://github.com/fabianmoronzirfas/bunkerized-nginx into dev 2020-10-21 10:47:09 +02:00
Fabian Morón Zirfas
5f62120e4d
fix(typo): add missing »find« 2020-10-21 06:18:45 +02:00
bunkerity
e8503b9cc5 ARM build fix 2020-10-18 17:37:41 +02:00
bunkerity
676571e4a4 use nginx:stable-alpine as base image 2020-10-18 16:26:33 +02:00
4992 changed files with 1420683 additions and 6124 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
.git

17
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View 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, yaml, configs, tests, environment, version, ...).
**Logs**
The logs generated by BunkerWeb. **DON'T FORGET TO REMOVE PRIVATE DATA LIKE IP ADDRESSES !**

View File

@ -0,0 +1,14 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[FEATURE]"
labels: feature
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.

402
.github/workflows/dev.yml vendored Normal file
View File

@ -0,0 +1,402 @@
name: Automatic test, build, push and deploy (DEV)
on:
push:
branches: [dev]
jobs:
# Build for amd64
build-bw-amd64:
runs-on: ubuntu-latest
steps:
# Prepare
- name: Checkout source code
uses: actions/checkout@v3
- name: Setup Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Login to private repository
uses: docker/login-action@v2
with:
registry: ${{ secrets.PRIVATE_REGISTRY }}
username: registry
password: ${{ secrets.PRIVATE_REGISTRY_TOKEN }}
# Build images
- name: Build BW for amd64
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-tests-amd64:latest
cache-from: type=registry,ref=bunkerity/cache:bw-amd64-cache
cache-to: type=registry,ref=bunkerity/cache:bw-amd64-cache,mode=min
- name: Build BW autoconf for amd64
uses: docker/build-push-action@v3
with:
context: .
file: autoconf/Dockerfile
platforms: linux/amd64
push: true
tags: ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-autoconf-tests-amd64:latest
cache-from: type=registry,ref=bunkerity/cache:bw-autoconf-amd64-cache
cache-to: type=registry,ref=bunkerity/cache:bw-autoconf-amd64-cache,mode=min
- name: Build BW UI for amd64
uses: docker/build-push-action@v3
with:
context: .
file: ui/Dockerfile
platforms: linux/amd64
push: true
tags: ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-ui-tests-amd64:latest
cache-from: type=registry,ref=bunkerity/cache:bw-ui-amd64-cache
cache-to: type=registry,ref=bunkerity/cache:bw-ui-amd64-cache,mode=min
# Build bunkerweb/386
build-bw-386:
runs-on: ubuntu-latest
steps:
# Prepare
- name: Checkout source code
uses: actions/checkout@v3
- name: Setup Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
# Build images
- name: Build BW for 386
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/386
tags: bunkerweb-tests-386:latest
cache-from: type=registry,ref=bunkerity/cache:bw-386-cache
cache-to: type=registry,ref=bunkerity/cache:bw-386-cache,mode=min
- name: Build BW autoconf for 386
uses: docker/build-push-action@v3
with:
context: .
file: autoconf/Dockerfile
platforms: linux/386
tags: bunkerweb-autoconf-tests-386:latest
cache-from: type=registry,ref=bunkerity/cache:bw-autoconf-386-cache
cache-to: type=registry,ref=bunkerity/cache:bw-autoconf-386-cache,mode=min
- name: Build BW UI for 386
uses: docker/build-push-action@v3
with:
context: .
file: ui/Dockerfile
platforms: linux/386
tags: bunkerweb-autoconf-tests-386:latest
cache-from: type=registry,ref=bunkerity/cache:bw-ui-386-cache
cache-to: type=registry,ref=bunkerity/cache:bw-ui-386-cache,mode=min
# Build bunkerweb/arm
build-bw-arm:
runs-on: ubuntu-latest
steps:
# Prepare
- name: Checkout source code
uses: actions/checkout@v3
- name: Setup Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Setup SSH for ARM node
run: |
mkdir -p ~/.ssh
echo "$SSH_KEY" > ~/.ssh/id_rsa_arm
chmod 600 ~/.ssh/id_rsa_arm
echo "$SSH_CONFIG" > ~/.ssh/config
env:
SSH_KEY: ${{ secrets.ARM_SSH_KEY }}
SSH_CONFIG: ${{ secrets.ARM_SSH_CONFIG }}
- name: Append ARM node to buildx
run: |
docker buildx create --append --name ${{ steps.buildx.outputs.name }} --node arm --platform linux/arm64,linux/arm/v7,linux/arm/v6 ssh://ubuntu@arm
# Build images
- name: Build BW for ARM
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/arm64,linux/arm/v7
tags: bunkerweb-tests-arm:latest
cache-from: type=registry,ref=bunkerity/cache:bw-arm-cache
cache-to: type=registry,ref=bunkerity/cache:bw-arm-cache,mode=min
- name: Build BW autoconf for ARM
uses: docker/build-push-action@v3
with:
context: .
file: autoconf/Dockerfile
platforms: linux/arm64,linux/arm/v7
tags: bunkerweb-autoconf-tests-arm:latest
cache-from: type=registry,ref=bunkerity/cache:bw-autoconf-arm-cache
cache-to: type=registry,ref=bunkerity/cache:bw-autoconf-arm-cache,mode=min
- name: Build BW UI for ARM
uses: docker/build-push-action@v3
with:
context: .
file: ui/Dockerfile
platforms: linux/arm64,linux/arm/v7
tags: bunkerweb-ui-tests-arm:latest
cache-from: type=registry,ref=bunkerity/cache:bw-ui-arm-cache
cache-to: type=registry,ref=bunkerity/cache:bw-ui-arm-cache,mode=min
# Run tests
tests:
needs: build-bw-amd64
runs-on: [self-hosted, X64]
steps:
# Prepare
- name: Checkout source code
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Login to private repository
uses: docker/login-action@v2
with:
registry: ${{ secrets.PRIVATE_REGISTRY }}
username: registry
password: ${{ secrets.PRIVATE_REGISTRY_TOKEN }}
- name: Set variables
run: |
VER=$(cat VERSION | tr -d '\n')
if [ "$GITHUB_REF" = "refs/heads/master" ] ; then
echo "BUILD_MODE=prod" >> $GITHUB_ENV
else
echo "BUILD_MODE=dev" >> $GITHUB_ENV
fi
# Import images to local registry
- name: Import BW image
run: docker pull ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-tests-amd64:latest && docker tag ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-tests-amd64:latest 10.20.1.1:5000/bw-tests:latest && docker push 10.20.1.1:5000/bw-tests:latest
- name: Import BW autoconf image
run: docker pull ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-autoconf-tests-amd64:latest && docker tag ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-autoconf-tests-amd64:latest 10.20.1.1:5000/bw-autoconf-tests:latest && docker push 10.20.1.1:5000/bw-autoconf-tests:latest
- name: Import BW UI image
run: docker pull ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-ui-tests-amd64:latest && docker tag ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-ui-tests-amd64:latest 10.20.1.1:5000/bw-ui-tests:latest && docker push 10.20.1.1:5000/bw-ui-tests:latest
# CVE check on OS
- name: Check security vulnerabilities for BW
uses: aquasecurity/trivy-action@master
with:
vuln-type: os
image-ref: 10.20.1.1:5000/bw-tests:latest
format: table
exit-code: 1
ignore-unfixed: false
severity: UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL
- name: Check security vulnerabilities for autoconf
uses: aquasecurity/trivy-action@master
with:
vuln-type: os
image-ref: 10.20.1.1:5000/bw-autoconf-tests:latest
format: table
exit-code: 1
ignore-unfixed: false
severity: UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL
- name: Check security vulnerabilities for UI
uses: aquasecurity/trivy-action@master
with:
vuln-type: os
image-ref: 10.20.1.1:5000/bw-ui-tests:latest
format: table
exit-code: 1
ignore-unfixed: false
severity: UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL
# Run tests
- name: Run Docker tests
run: ./tests/docker.sh ${{ env.BUILD_MODE }}
- name: Run autoconf tests
run: ./tests/autoconf.sh ${{ env.BUILD_MODE }}
- name: Run Swarm tests
run: ./tests/swarm.sh ${{ env.BUILD_MODE }}
- name: Run Kubernetes tests
run: ./tests/kubernetes.sh ${{ env.BUILD_MODE }}
- name: Run Linux tests
run: ./tests/linux.sh ${{ env.BUILD_MODE }}
# Push to dev registries
push-docker:
needs: [tests, build-bw-386, build-bw-arm]
runs-on: ubuntu-latest
steps:
# Prepare
- name: Checkout source code
uses: actions/checkout@v3
- name: Setup Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Login to private repository
uses: docker/login-action@v2
with:
registry: ${{ secrets.PRIVATE_REGISTRY }}
username: registry
password: ${{ secrets.PRIVATE_REGISTRY_TOKEN }}
- name: Setup SSH for ARM node
run: |
mkdir -p ~/.ssh
echo "$SSH_KEY" > ~/.ssh/id_rsa_arm
chmod 600 ~/.ssh/id_rsa_arm
echo "$SSH_CONFIG" > ~/.ssh/config
env:
SSH_KEY: ${{ secrets.ARM_SSH_KEY }}
SSH_CONFIG: ${{ secrets.ARM_SSH_CONFIG }}
- name: Append ARM node to buildx
run: |
docker buildx create --append --name ${{ steps.buildx.outputs.name }} --node arm --platform linux/arm64,linux/arm/v7,linux/arm/v6 ssh://ubuntu@arm
# Build and push
- name: Build and push BW
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7
push: true
tags: ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb:staging,bunkerity/bunkerweb:dev
cache-from: |
type=registry,ref=bunkerity/cache:bw-amd64-cache
type=registry,ref=bunkerity/cache:bw-386-cache
type=registry,ref=bunkerity/cache:bw-arm-cache
- name: Build and push BW autoconf
uses: docker/build-push-action@v3
with:
context: .
file: autoconf/Dockerfile
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7
push: true
tags: ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-autoconf:staging,bunkerity/bunkerweb-autoconf:dev
cache-from: |
type=registry,ref=bunkerity/cache:bw-autoconf-amd64-cache
type=registry,ref=bunkerity/cache:bw-autoconf-386-cache
type=registry,ref=bunkerity/cache:bw-autoconf-arm-cache
- name: Build and push BW UI
uses: docker/build-push-action@v3
with:
context: .
file: ui/Dockerfile
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7
push: true
tags: ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-ui:staging,bunkerity/bunkerweb-ui:dev
cache-from: |
type=registry,ref=bunkerity/cache:bw-ui-amd64-cache
type=registry,ref=bunkerity/cache:bw-ui-386-cache
type=registry,ref=bunkerity/cache:bw-ui-arm-cache
# Push to PackageCloud
push-linux:
needs: tests
runs-on: [self-hosted, X64]
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Set variables
run: |
VER=$(cat VERSION | tr -d '\n')
echo "VERSION=$VER" >> $GITHUB_ENV
- name: Remove Ubuntu DEB from packagecloud
run: package_cloud yank bunkerity/bunkerweb-dev/ubuntu/jammy bunkerweb_${{ env.VERSION }}-1_amd64.deb
continue-on-error: true
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- name: Push Ubuntu DEB to packagecloud
uses: danielmundi/upload-packagecloud@v1
with:
PACKAGE-NAME: /opt/packages/dev/ubuntu/bunkerweb_${{ env.VERSION }}-1_amd64.deb
PACKAGECLOUD-USERNAME: bunkerity
PACKAGECLOUD-REPO: bunkerweb-dev
PACKAGECLOUD-DISTRIB: ubuntu/jammy
PACKAGECLOUD-TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- name: Remove Debian DEB from packagecloud
run: package_cloud yank bunkerity/bunkerweb-dev/debian/bullseye bunkerweb_${{ env.VERSION }}-1_amd64.deb
continue-on-error: true
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- name: Push Debian DEB to packagecloud
uses: danielmundi/upload-packagecloud@v1
with:
PACKAGE-NAME: /opt/packages/dev/debian/bunkerweb_${{ env.VERSION }}-1_amd64.deb
PACKAGECLOUD-USERNAME: bunkerity
PACKAGECLOUD-REPO: bunkerweb-dev
PACKAGECLOUD-DISTRIB: debian/bullseye
PACKAGECLOUD-TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- name: Remove CentOS RPM from packagecloud
run: package_cloud yank bunkerity/bunkerweb-dev/el/8 bunkerweb-${{ env.VERSION }}-1.x86_64.rpm
continue-on-error: true
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- name: Push CentOS RPM to packagecloud
uses: danielmundi/upload-packagecloud@v1
with:
PACKAGE-NAME: /opt/packages/dev/centos/bunkerweb-${{ env.VERSION }}-1.x86_64.rpm
PACKAGECLOUD-USERNAME: bunkerity
PACKAGECLOUD-REPO: bunkerweb-dev
PACKAGECLOUD-DISTRIB: el/8
PACKAGECLOUD-TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- name: Remove Fedora RPM from packagecloud
run: package_cloud yank bunkerity/bunkerweb-dev/fedora/36 bunkerweb-${{ env.VERSION }}-1.x86_64.rpm
continue-on-error: true
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- name: Push Fedora RPM to packagecloud
uses: danielmundi/upload-packagecloud@v1
with:
PACKAGE-NAME: /opt/packages/dev/fedora/bunkerweb-${{ env.VERSION }}-1.x86_64.rpm
PACKAGECLOUD-USERNAME: bunkerity
PACKAGECLOUD-REPO: bunkerweb-dev
PACKAGECLOUD-DISTRIB: fedora/36
PACKAGECLOUD-TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
# Deploy to staging infrastructure
deploy:
needs: push-docker
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: k8s login (staging)
uses: azure/k8s-set-context@v2
with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBE_CONFIG_STAGING }}
- name: k8s deploy (staging)
run: kubectl rollout restart deployment bunkerweb-controller && kubectl rollout restart daemonset bunkerweb

529
.github/workflows/prod.yml vendored Normal file
View File

@ -0,0 +1,529 @@
name: Automatic test, build, push and deploy (PROD)
on:
push:
branches: [master]
jobs:
# Build for amd64
build-bw-amd64:
runs-on: ubuntu-latest
steps:
# Prepare
- name: Checkout source code
uses: actions/checkout@v3
- name: Setup Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Login to private repository
uses: docker/login-action@v2
with:
registry: ${{ secrets.PRIVATE_REGISTRY }}
username: registry
password: ${{ secrets.PRIVATE_REGISTRY_TOKEN }}
# Build images
- name: Build BW for amd64
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-tests-amd64:latest
cache-to: type=registry,ref=bunkerity/cache:bw-amd64-cache,mode=min
- name: Build BW autoconf for amd64
uses: docker/build-push-action@v3
with:
context: .
file: autoconf/Dockerfile
platforms: linux/amd64
push: true
tags: ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-autoconf-tests-amd64:latest
cache-to: type=registry,ref=bunkerity/cache:bw-autoconf-amd64-cache,mode=min
- name: Build BW UI for amd64
uses: docker/build-push-action@v3
with:
context: .
file: ui/Dockerfile
platforms: linux/amd64
push: true
tags: ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-ui-tests-amd64:latest
cache-to: type=registry,ref=bunkerity/cache:bw-ui-amd64-cache,mode=min
# Build bunkerweb/386
build-bw-386:
runs-on: ubuntu-latest
steps:
# Prepare
- name: Checkout source code
uses: actions/checkout@v3
- name: Setup Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
# Build images
- name: Build BW for 386
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/386
tags: bunkerweb-tests-386:latest
cache-to: type=registry,ref=bunkerity/cache:bw-386-cache,mode=min
- name: Build BW autoconf for 386
uses: docker/build-push-action@v3
with:
context: .
file: autoconf/Dockerfile
platforms: linux/386
tags: bunkerweb-autoconf-tests-386:latest
cache-to: type=registry,ref=bunkerity/cache:bw-autoconf-386-cache,mode=min
- name: Build BW UI for 386
uses: docker/build-push-action@v3
with:
context: .
file: ui/Dockerfile
platforms: linux/386
tags: bunkerweb-autoconf-tests-386:latest
cache-to: type=registry,ref=bunkerity/cache:bw-ui-386-cache,mode=min
# Build bunkerweb/arm
build-bw-arm:
runs-on: ubuntu-latest
steps:
# Prepare
- name: Checkout source code
uses: actions/checkout@v3
- name: Setup Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Setup SSH for ARM node
run: |
mkdir -p ~/.ssh
echo "$SSH_KEY" > ~/.ssh/id_rsa_arm
chmod 600 ~/.ssh/id_rsa_arm
echo "$SSH_CONFIG" > ~/.ssh/config
env:
SSH_KEY: ${{ secrets.ARM_SSH_KEY }}
SSH_CONFIG: ${{ secrets.ARM_SSH_CONFIG }}
- name: Append ARM node to buildx
run: |
docker buildx create --append --name ${{ steps.buildx.outputs.name }} --node arm --platform linux/arm64,linux/arm/v7,linux/arm/v6 ssh://ubuntu@arm
# Build images
- name: Build BW for ARM
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/arm64,linux/arm/v7
tags: bunkerweb-tests-arm:latest
cache-to: type=registry,ref=bunkerity/cache:bw-arm-cache,mode=min
- name: Build BW autoconf for ARM
uses: docker/build-push-action@v3
with:
context: .
file: autoconf/Dockerfile
platforms: linux/arm64,linux/arm/v7
tags: bunkerweb-autoconf-tests-arm:latest
cache-to: type=registry,ref=bunkerity/cache:bw-autoconf-arm-cache,mode=min
- name: Build BW UI for ARM
uses: docker/build-push-action@v3
with:
context: .
file: ui/Dockerfile
platforms: linux/arm64,linux/arm/v7
tags: bunkerweb-ui-tests-arm:latest
cache-to: type=registry,ref=bunkerity/cache:bw-ui-arm-cache,mode=min
# Build linux ubuntu
build-bw-ubuntu:
runs-on: ubuntu-latest
steps:
# Prepare
- name: Checkout source code
uses: actions/checkout@v3
- name: Setup Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Login to private repository
uses: docker/login-action@v2
with:
registry: ${{ secrets.PRIVATE_REGISTRY }}
username: registry
password: ${{ secrets.PRIVATE_REGISTRY_TOKEN }}
# Build image
- name: Build BW ubuntu
uses: docker/build-push-action@v3
with:
context: .
file: linux/Dockerfile-ubuntu
platforms: linux/amd64
push: true
tags: ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-ubuntu:latest
# Build linux debian
build-bw-debian:
runs-on: ubuntu-latest
steps:
# Prepare
- name: Checkout source code
uses: actions/checkout@v3
- name: Setup Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Login to private repository
uses: docker/login-action@v2
with:
registry: ${{ secrets.PRIVATE_REGISTRY }}
username: registry
password: ${{ secrets.PRIVATE_REGISTRY_TOKEN }}
# Build image
- name: Build BW debian
uses: docker/build-push-action@v3
with:
context: .
file: linux/Dockerfile-debian
platforms: linux/amd64
push: true
tags: ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-debian:latest
# Build linux centos
build-bw-centos:
runs-on: ubuntu-latest
steps:
# Prepare
- name: Checkout source code
uses: actions/checkout@v3
- name: Setup Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Login to private repository
uses: docker/login-action@v2
with:
registry: ${{ secrets.PRIVATE_REGISTRY }}
username: registry
password: ${{ secrets.PRIVATE_REGISTRY_TOKEN }}
# Build image
- name: Build BW centos
uses: docker/build-push-action@v3
with:
context: .
file: linux/Dockerfile-centos
platforms: linux/amd64
push: true
tags: ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-centos:latest
# Build linux fedora
build-bw-fedora:
runs-on: ubuntu-latest
steps:
# Prepare
- name: Checkout source code
uses: actions/checkout@v3
- name: Setup Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Login to private repository
uses: docker/login-action@v2
with:
registry: ${{ secrets.PRIVATE_REGISTRY }}
username: registry
password: ${{ secrets.PRIVATE_REGISTRY_TOKEN }}
# Build image
- name: Build BW fedora
uses: docker/build-push-action@v3
with:
context: .
file: linux/Dockerfile-fedora
platforms: linux/amd64
push: true
tags: ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-fedora:latest
# Run tests
tests:
needs: [build-bw-amd64, build-bw-ubuntu, build-bw-debian, build-bw-centos, build-bw-fedora]
runs-on: [self-hosted, X64]
steps:
# Prepare
- name: Checkout source code
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Login to private repository
uses: docker/login-action@v2
with:
registry: ${{ secrets.PRIVATE_REGISTRY }}
username: registry
password: ${{ secrets.PRIVATE_REGISTRY_TOKEN }}
- name: Set variables
run: |
VER=$(cat VERSION | tr -d '\n')
if [ "$GITHUB_REF" = "refs/heads/master" ] ; then
echo "BUILD_MODE=prod" >> $GITHUB_ENV
else
echo "BUILD_MODE=dev" >> $GITHUB_ENV
fi
# Import images to local registry
- name: Import BW image
run: docker pull ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-tests-amd64:latest && docker tag ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-tests-amd64:latest 10.20.1.1:5000/bw-tests:latest && docker push 10.20.1.1:5000/bw-tests:latest
- name: Import BW autoconf image
run: docker pull ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-autoconf-tests-amd64:latest && docker tag ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-autoconf-tests-amd64:latest 10.20.1.1:5000/bw-autoconf-tests:latest && docker push 10.20.1.1:5000/bw-autoconf-tests:latest
- name: Import BW UI image
run: docker pull ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-ui-tests-amd64:latest && docker tag ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-ui-tests-amd64:latest 10.20.1.1:5000/bw-ui-tests:latest && docker push 10.20.1.1:5000/bw-ui-tests:latest
- name: Import Ubuntu image
run: docker pull ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-ubuntu:latest && docker tag ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-ubuntu:latest bw-ubuntu-tests:latest
- name: Import Debian image
run: docker pull ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-debian:latest && docker tag ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-debian:latest bw-debian-tests:latest
- name: Import Centos image
run: docker pull ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-centos:latest && docker tag ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-centos:latest bw-centos-tests:latest
- name: Import Fedora image
run: docker pull ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-fedora:latest && docker tag ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-fedora:latest bw-fedora-tests:latest
# CVE check on OS
- name: Check security vulnerabilities for BW
uses: aquasecurity/trivy-action@master
with:
vuln-type: os
image-ref: 10.20.1.1:5000/bw-tests:latest
format: table
exit-code: 1
ignore-unfixed: false
severity: UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL
- name: Check security vulnerabilities for autoconf
uses: aquasecurity/trivy-action@master
with:
vuln-type: os
image-ref: 10.20.1.1:5000/bw-autoconf-tests:latest
format: table
exit-code: 1
ignore-unfixed: false
severity: UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL
- name: Check security vulnerabilities for UI
uses: aquasecurity/trivy-action@master
with:
vuln-type: os
image-ref: 10.20.1.1:5000/bw-ui-tests:latest
format: table
exit-code: 1
ignore-unfixed: false
severity: UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL
# Run tests
- name: Run Docker tests
run: ./tests/docker.sh ${{ env.BUILD_MODE }}
- name: Run autoconf tests
run: ./tests/autoconf.sh ${{ env.BUILD_MODE }}
- name: Run Swarm tests
run: ./tests/swarm.sh ${{ env.BUILD_MODE }}
- name: Run Kubernetes tests
run: ./tests/kubernetes.sh ${{ env.BUILD_MODE }}
- name: Run Linux tests
run: ./tests/linux.sh ${{ env.BUILD_MODE }}
# Push to dev registries
push-docker:
needs: [tests, build-bw-386, build-bw-arm]
runs-on: ubuntu-latest
steps:
# Prepare
- name: Checkout source code
uses: actions/checkout@v3
- name: Set variables
run: |
VER=$(cat VERSION | tr -d '\n')
echo "VERSION=$VER" >> $GITHUB_ENV
- name: Setup Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Login to private repository
uses: docker/login-action@v2
with:
registry: ${{ secrets.PRIVATE_REGISTRY }}
username: registry
password: ${{ secrets.PRIVATE_REGISTRY_TOKEN }}
- name: Setup SSH for ARM node
run: |
mkdir -p ~/.ssh
echo "$SSH_KEY" > ~/.ssh/id_rsa_arm
chmod 600 ~/.ssh/id_rsa_arm
echo "$SSH_CONFIG" > ~/.ssh/config
env:
SSH_KEY: ${{ secrets.ARM_SSH_KEY }}
SSH_CONFIG: ${{ secrets.ARM_SSH_CONFIG }}
- name: Append ARM node to buildx
run: |
docker buildx create --append --name ${{ steps.buildx.outputs.name }} --node arm --platform linux/arm64,linux/arm/v7,linux/arm/v6 ssh://ubuntu@arm
# Build and push
- name: Build and push BW
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7
push: true
tags: ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb:latest,bunkerity/bunkerweb:latest,bunkerity/bunkerweb:${{ env.VERSION }}
cache-from: |
type=registry,ref=bunkerity/cache:bw-amd64-cache
type=registry,ref=bunkerity/cache:bw-386-cache
type=registry,ref=bunkerity/cache:bw-arm-cache
- name: Build and push BW autoconf
uses: docker/build-push-action@v3
with:
context: .
file: autoconf/Dockerfile
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7
push: true
tags: ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-autoconf:latest,bunkerity/bunkerweb-autoconf:latest,bunkerity/bunkerweb-autoconf:${{ env.VERSION }}
cache-from: |
type=registry,ref=bunkerity/cache:bw-autoconf-amd64-cache
type=registry,ref=bunkerity/cache:bw-autoconf-386-cache
type=registry,ref=bunkerity/cache:bw-autoconf-arm-cache
- name: Build and push BW UI
uses: docker/build-push-action@v3
with:
context: .
file: ui/Dockerfile
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7
push: true
tags: ${{ secrets.PRIVATE_REGISTRY }}/infra/bunkerweb-ui:latest,bunkerity/bunkerweb-ui:latest,bunkerity/bunkerweb-ui:${{ env.VERSION }}
cache-from: |
type=registry,ref=bunkerity/cache:bw-ui-amd64-cache
type=registry,ref=bunkerity/cache:bw-ui-386-cache
type=registry,ref=bunkerity/cache:bw-ui-arm-cache
# Push to PackageCloud
push-linux:
needs: tests
runs-on: [self-hosted, X64]
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Set variables
run: |
VER=$(cat VERSION | tr -d '\n')
echo "VERSION=$VER" >> $GITHUB_ENV
- name: Remove Ubuntu DEB from packagecloud
run: package_cloud yank bunkerity/bunkerweb/ubuntu/jammy bunkerweb_${{ env.VERSION }}-1_amd64.deb
continue-on-error: true
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- name: Push Ubuntu DEB to packagecloud
uses: danielmundi/upload-packagecloud@v1
with:
PACKAGE-NAME: /opt/packages/prod/ubuntu/bunkerweb_${{ env.VERSION }}-1_amd64.deb
PACKAGECLOUD-USERNAME: bunkerity
PACKAGECLOUD-REPO: bunkerweb
PACKAGECLOUD-DISTRIB: ubuntu/jammy
PACKAGECLOUD-TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- name: Remove Debian DEB from packagecloud
run: package_cloud yank bunkerity/bunkerweb/debian/bullseye bunkerweb_${{ env.VERSION }}-1_amd64.deb
continue-on-error: true
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- name: Push Debian DEB to packagecloud
uses: danielmundi/upload-packagecloud@v1
with:
PACKAGE-NAME: /opt/packages/prod/debian/bunkerweb_${{ env.VERSION }}-1_amd64.deb
PACKAGECLOUD-USERNAME: bunkerity
PACKAGECLOUD-REPO: bunkerweb
PACKAGECLOUD-DISTRIB: debian/bullseye
PACKAGECLOUD-TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- name: Remove CentOS RPM from packagecloud
run: package_cloud yank bunkerity/bunkerweb/el/8 bunkerweb-${{ env.VERSION }}-1.x86_64.rpm
continue-on-error: true
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- name: Push CentOS RPM to packagecloud
uses: danielmundi/upload-packagecloud@v1
with:
PACKAGE-NAME: /opt/packages/prod/centos/bunkerweb-${{ env.VERSION }}-1.x86_64.rpm
PACKAGECLOUD-USERNAME: bunkerity
PACKAGECLOUD-REPO: bunkerweb
PACKAGECLOUD-DISTRIB: el/8
PACKAGECLOUD-TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- name: Remove Fedora RPM from packagecloud
run: package_cloud yank bunkerity/bunkerweb/fedora/36 bunkerweb-${{ env.VERSION }}-1.x86_64.rpm
continue-on-error: true
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- name: Push Fedora RPM to packagecloud
uses: danielmundi/upload-packagecloud@v1
with:
PACKAGE-NAME: /opt/packages/prod/fedora/bunkerweb-${{ env.VERSION }}-1.x86_64.rpm
PACKAGECLOUD-USERNAME: bunkerity
PACKAGECLOUD-REPO: bunkerweb
PACKAGECLOUD-DISTRIB: fedora/36
PACKAGECLOUD-TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
# Deploy to staging infrastructure
# deploy:
# needs: push-docker
# runs-on: ubuntu-latest
# steps:
# - name: Checkout source code
# uses: actions/checkout@v3
# - name: k8s login (staging)
# uses: azure/k8s-set-context@v2
# with:
# method: kubeconfig
# kubeconfig: ${{ secrets.KUBE_CONFIG_STAGING }}
# - name: k8s deploy (staging)
# run: kubectl rollout restart deployment bunkerweb-controller && kubectl rollout restart daemonset bunkerweb

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
site/
.idea/
.vscode/
**/__pycache__/
ui/env/

114
CHANGELOG.md Normal file
View File

@ -0,0 +1,114 @@
# Changelog
## v1.4.1 - 2022/16/06
- Fix sending local IPs to BunkerNet when DISABLE_DEFAULT_SERVER=yes
- Fix certbot bug when AUTOCONF_MODE=yes
- Fix certbot bug when MULTISITE=no
- Add reverse proxy timeouts settings
- Add auth_request settings
- Add authentik and authelia examples
- Prebuilt Docker images for arm64 and armv7
- Improve documentation for Linux integration
- Various fixes in the documentation
## v1.4.0 - 2022/06/06
- Project renamed to BunkerWeb
- Internal architecture fully revised with a modular approach
- Improved CI/CD with automatic tests for multiple integrations
- Plugin improvement
- Volume improvement for container-based integrations
- Web UI improvement with various new features
- Web tool to generate settings from a user-friendly UI
- Linux packages
- Various bug fixes
## v1.3.2 - 2021/10/24
- Use API instead of a shared folder for Swarm and Kubernetes integrations
- Beta integration of distributed bad IPs database through a remote API
- Improvement of the request limiting feature : hour/day rate and multiple URL support
- Various bug fixes related to antibot feature
- Init support of Arch Linux
- Fix Moodle example
- Fix ROOT_FOLDER bug in serve-files.conf when using the UI
- Update default values for PERMISSIONS_POLICY and FEATURE_POLICY
- Disable COUNTRY ban if IP is local
## 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
- Add REVERSE_PROXY_KEEPALIVE 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

21
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,21 @@
# Contributing to bunkerweb
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 (by the way, you can can also follow us on [LinkedIn](https://www.linkedin.com/company/bunkerity/), [Twitter](https://twitter.com/bunkerity) and [GitHub](https://github.com/bunkerity)), make a blog post about it or simply tell your friends/colleagues that's an awesome project..
## Join the community
You can join the [Discord server](https://discord.com/invite/fTf46FmtyD), the [GitHub discussions](https://github.com/bunkerity/bunkerweb/discussions) and the [/r/BunkerWeb](https://www.reddit.com/r/BunkerWeb) subreddit to talk about the project and help others.
## Reporting bugs / ask for features
The preferred way to report bugs and asking for features is using [issues](https://github.com/bunkerity/bunkerweb/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/bunkerweb/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 !**

View File

@ -1,24 +1,86 @@
FROM alpine FROM nginx:1.20.2-alpine AS builder
COPY compile.sh /tmp/compile.sh # Copy dependencies sources folder
RUN chmod +x /tmp/compile.sh && \ COPY deps /tmp/bunkerweb/deps
/tmp/compile.sh && \
rm -rf /tmp/*
COPY entrypoint.sh /opt/entrypoint.sh # Compile and install dependencies
COPY confs/ /opt/confs RUN apk add --no-cache --virtual build bash build autoconf libtool automake geoip-dev g++ gcc curl-dev libxml2-dev pcre-dev make linux-headers musl-dev gd-dev gnupg brotli-dev openssl-dev patch readline-dev && \
COPY scripts/ /opt/scripts mkdir -p /opt/bunkerweb/deps && \
COPY fail2ban/ /opt/fail2ban chmod +x /tmp/bunkerweb/deps/install.sh && \
COPY logs/ /opt/logs bash /tmp/bunkerweb/deps/install.sh && \
COPY lua/ /opt/lua apk del build
RUN apk --no-cache add php7-fpm certbot libstdc++ libmaxminddb geoip pcre yajl fail2ban clamav apache2-utils rsyslog openssl lua libgd && \ # Copy python requirements
chmod +x /opt/entrypoint.sh /opt/scripts/* && \ COPY deps/requirements.txt /opt/bunkerweb/deps/requirements.txt
mkdir /opt/entrypoint.d && \
adduser -h /dev/null -g '' -s /sbin/nologin -D -H nginx
VOLUME /www /http-confs /server-confs /modsec-confs /modsec-crs-confs # Install python requirements
RUN apk add --no-cache --virtual build py3-pip gcc python3-dev musl-dev libffi-dev openssl-dev cargo && \
pip install wheel && \
mkdir /opt/bunkerweb/deps/python && \
pip install --no-cache-dir --require-hashes --target /opt/bunkerweb/deps/python -r /opt/bunkerweb/deps/requirements.txt && \
apk del build
EXPOSE 80/tcp 443/tcp FROM nginx:1.20.2-alpine
ENTRYPOINT ["/opt/entrypoint.sh"] # Copy dependencies
COPY --from=builder /opt/bunkerweb /opt/bunkerweb
# Copy files
# can't exclude deps from . so we are copying everything by hand
COPY api /opt/bunkerweb/api
COPY cli /opt/bunkerweb/cli
COPY confs /opt/bunkerweb/confs
COPY core /opt/bunkerweb/core
COPY gen /opt/bunkerweb/gen
COPY helpers /opt/bunkerweb/helpers
COPY job /opt/bunkerweb/job
COPY lua /opt/bunkerweb/lua
COPY misc /opt/bunkerweb/misc
COPY utils /opt/bunkerweb/utils
COPY settings.json /opt/bunkerweb/settings.json
COPY VERSION /opt/bunkerweb/VERSION
# Install runtime dependencies, pypi packages, move bwcli, create data folders and set permissions
RUN apk add --no-cache bash python3 libgcc libstdc++ openssl git && \
chown root:nginx /opt/bunkerweb/modules && \
chmod 750 /opt/bunkerweb/modules && \
chmod 740 /opt/bunkerweb/modules/*.so && \
cp /opt/bunkerweb/helpers/bwcli /usr/local/bin && \
mkdir /opt/bunkerweb/configs && \
for dir in $(echo "cache configs configs/http configs/stream configs/server-http configs/server-stream configs/default-server-http configs/default-server-stream configs/modsec configs/modsec-crs letsencrypt plugins www") ; do mkdir -p "/data/${dir}" && ln -s "/data/${dir}" "/opt/bunkerweb/${dir}" ; done && \
chown -R root:nginx /data && \
chmod -R 770 /data && \
mkdir /opt/bunkerweb/tmp && \
chown -R root:nginx /opt/bunkerweb && \
find /opt/bunkerweb -type f -exec chmod 0740 {} \; && \
find /opt/bunkerweb -type d -exec chmod 0750 {} \; && \
chmod 770 /opt/bunkerweb/cache /opt/bunkerweb/tmp && \
chmod 750 /opt/bunkerweb/gen/main.py /opt/bunkerweb/job/main.py /opt/bunkerweb/cli/main.py /opt/bunkerweb/helpers/*.sh /usr/local/bin/bwcli /opt/bunkerweb/deps/python/bin/* && \
find /opt/bunkerweb/core/*/jobs/* -type f -exec chmod 750 {} \; && \
chown root:nginx /usr/local/bin/bwcli && \
chown -R nginx:nginx /etc/nginx && \
ln -s /data/letsencrypt /etc/letsencrypt && \
mkdir /var/log/letsencrypt /var/lib/letsencrypt && \
chown root:nginx /var/log/letsencrypt /var/lib/letsencrypt && \
chmod 770 /var/log/letsencrypt /var/lib/letsencrypt && \
chown -R root:nginx /etc/nginx && \
chmod -R 770 /etc/nginx && \
rm -f /var/log/nginx/* && \
ln -s /proc/1/fd/2 /var/log/nginx/error.log && \
ln -s /proc/1/fd/2 /var/log/nginx/modsec_audit.log && \
ln -s /proc/1/fd/1 /var/log/nginx/access.log && \
ln -s /proc/1/fd/1 /var/log/nginx/jobs.log && \
ln -s /proc/1/fd/1 /var/log/letsencrypt/letsencrypt.log
# Fix CVE-2022-27405 and CVE-2022-27406
RUN apk add "freetype>=2.10.4-r3"
VOLUME /data
EXPOSE 8080/tcp 8443/tcp
USER nginx:nginx
HEALTHCHECK --interval=10s --timeout=10s --start-period=30s --retries=6 CMD /opt/bunkerweb/helpers/healthcheck.sh
ENTRYPOINT ["/opt/bunkerweb/helpers/entrypoint.sh"]

View File

@ -1,24 +0,0 @@
FROM amd64/alpine
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 php7-fpm 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 && \
adduser -h /dev/null -g '' -s /sbin/nologin -D -H nginx
VOLUME /www /http-confs /server-confs /modsec-confs /modsec-crs-confs
EXPOSE 80/tcp 443/tcp
ENTRYPOINT ["/opt/entrypoint.sh"]

View File

@ -1,31 +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/alpine
COPY --from=builder qemu-arm-static /usr/bin
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 php7-fpm 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 && \
adduser -h /dev/null -g '' -s /sbin/nologin -D -H nginx
VOLUME /www /http-confs /server-confs /modsec-confs /modsec-crs-confs
EXPOSE 80/tcp 443/tcp
ENTRYPOINT ["/opt/entrypoint.sh"]

View File

@ -1,31 +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/alpine
COPY --from=builder qemu-aarch64-static /usr/bin
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 php7-fpm 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 && \
adduser -h /dev/null -g '' -s /sbin/nologin -D -H nginx
VOLUME /www /http-confs /server-confs /modsec-confs /modsec-crs-confs
EXPOSE 80/tcp 443/tcp
ENTRYPOINT ["/opt/entrypoint.sh"]

View File

@ -1,24 +0,0 @@
FROM i386/alpine
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 php7-fpm 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 && \
adduser -h /dev/null -g '' -s /sbin/nologin -D -H nginx
VOLUME /www /http-confs /server-confs /modsec-confs /modsec-crs-confs
EXPOSE 80/tcp 443/tcp
ENTRYPOINT ["/opt/entrypoint.sh"]

660
LICENSE.md Normal file
View 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/>.

1001
README.md

File diff suppressed because it is too large Load Diff

17
SECURITY.md Normal file
View 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 code
- 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.

1
VERSION Normal file
View File

@ -0,0 +1 @@
1.4.1

32
api/API.py Normal file
View File

@ -0,0 +1,32 @@
from requests import request
class API :
def __init__(self, endpoint, host="bwapi") :
self.__endpoint = endpoint
self.__host = host
def get_endpoint(self) :
return self.__endpoint
def get_host(self) :
return self.__host
def request(self, method, url, data=None, files=None, timeout=(10, 30)) :
try :
headers = {}
headers["User-Agent"] = "bwapi"
headers["Host"] = self.__host
if type(data) is dict :
resp = request(method, self.__endpoint + url, json=data, timeout=timeout, headers=headers)
elif type(data) is bytes :
resp = request(method, self.__endpoint + url, data=data, timeout=timeout, headers=headers)
elif files is not None :
resp = request(method, self.__endpoint + url, files=files, timeout=timeout, headers=headers)
elif data is None :
resp = request(method, self.__endpoint + url, timeout=timeout, headers=headers)
else :
return False, "unsupported data type", None, None
except Exception as e :
return False, str(e), None, None
return True, "ok", resp.status_code, resp.json()

217
autoconf/Config.py Normal file
View File

@ -0,0 +1,217 @@
from traceback import format_exc
from threading import Thread, Lock
from time import sleep
from subprocess import run, DEVNULL, STDOUT
from glob import glob
from shutil import rmtree
from os import makedirs
from os.path import dirname
from json import loads
from API import API
from JobScheduler import JobScheduler
from ApiCaller import ApiCaller
from ConfigCaller import ConfigCaller
from logger import log
class Config(ApiCaller, ConfigCaller) :
def __init__(self, ctrl_type, lock=None) :
ApiCaller.__init__(self)
ConfigCaller.__init__(self)
self.__ctrl_type = ctrl_type
self.__lock = lock
self.__instances = []
self.__services = []
self.__configs = []
self.__config = {}
self.__scheduler = None
self.__scheduler_thread = None
self.__schedule = False
self.__schedule_lock = Lock()
def __get_full_env(self) :
env_instances = {}
for instance in self.__instances :
for variable, value in instance["env"].items() :
env_instances[variable] = value
env_services = {}
if not "SERVER_NAME" in env_instances :
env_instances["SERVER_NAME"] = ""
for service in self.__services :
for variable, value in service.items() :
env_services[service["SERVER_NAME"].split(" ")[0] + "_" + variable] = value
if env_instances["SERVER_NAME"] != "" :
env_instances["SERVER_NAME"] += " "
env_instances["SERVER_NAME"] += service["SERVER_NAME"].split(" ")[0]
return self._full_env(env_instances, env_services)
def __scheduler_run_pending(self) :
schedule = True
while schedule :
self.__scheduler.run_pending()
sleep(1)
self.__schedule_lock.acquire()
schedule = self.__schedule
self.__schedule_lock.release()
def update_needed(self, instances, services, configs=None) :
if instances != self.__instances :
return True
if services != self.__services :
return True
if configs is not None and configs != self.__configs :
return True
return False
def __get_config(self) :
config = {}
# extract instances variables
for instance in self.__instances :
for variable, value in instance["env"].items() :
config[variable] = value
# extract services variables
server_names = []
for service in self.__services :
first_server = service["SERVER_NAME"].split(" ")[0]
server_names.append(first_server)
for variable, value in service.items() :
config[first_server + "_" + variable] = value
config["SERVER_NAME"] = " ".join(server_names)
return config
def __get_apis(self) :
apis = []
for instance in self.__instances :
endpoint = "http://" + instance["hostname"] + ":5000"
host = "bwapi"
if "API_SERVER_NAME" in instance["env"] :
host = instance["env"]["API_SERVER_NAME"]
apis.append(API(endpoint, host=host))
return apis
def __write_configs(self) :
ret = True
for config_type in self.__configs :
rmtree("/data/configs/" + config_type)
makedirs("/data/configs/" + config_type, exist_ok=True)
for file, data in self.__configs[config_type].items() :
path = "/data/configs/" + config_type + "/" + file
if not path.endswith(".conf") :
path += ".conf"
makedirs(dirname(path), exist_ok=True)
try :
mode = "w"
if type(data) is bytes :
mode = "wb"
with open(path, mode) as f :
f.write(data)
except :
print(format_exc())
log("CONFIG", "", "Can't save file " + path)
ret = False
return ret
def apply(self, instances, services, configs=None) :
success = True
# stop scheduler just in case caller didn't do it
self.stop_scheduler()
# update values
# order here is important :
# __get_scheduler needs apis
# __get_apis needs __config
# __get_full_env needs __instances and __services
self.__instances = instances
self.__services = services
self.__configs = configs
self.__config = self.__get_full_env()
self._set_apis(self.__get_apis())
# write configs
ret = self.__write_configs()
if not ret :
success = False
log("CONFIG", "", "saving custom configs failed, configuration will not work as expected...")
# get env
env = self.__get_full_env()
# run jobs once
i = 1
for instance in self.__instances :
endpoint = "http://" + instance["hostname"] + ":5000"
host = "bwapi"
if "API_SERVER_NAME" in instance["env"] :
host = instance["env"]["API_SERVER_NAME"]
env["CLUSTER_INSTANCE_" + str(i)] = endpoint + " " + host
i += 1
if self.__scheduler is None :
self.__scheduler = JobScheduler(env=env, lock=self.__lock, apis=self._get_apis())
ret = self.__scheduler.reload(env)
if not ret :
success = False
log("CONFIG", "", "scheduler.reload() failed, configuration will not work as expected...")
# write config to /tmp/variables.env
with open("/tmp/variables.env", "w") as f :
for variable, value in self.__config.items() :
f.write(variable + "=" + value + "\n")
# run the generator
cmd = "python /opt/bunkerweb/gen/main.py --settings /opt/bunkerweb/settings.json --templates /opt/bunkerweb/confs --output /etc/nginx --variables /tmp/variables.env"
proc = run(cmd.split(" "), stdin=DEVNULL, stderr=STDOUT)
if proc.returncode != 0 :
success = False
log("CONFIG", "", "config generator failed, configuration will not work as expected...")
cmd = "chown -R root:101 /etc/nginx"
run(cmd.split(" "), stdin=DEVNULL, stdout=DEVNULL, stderr=STDOUT)
cmd = "chmod -R 770 /etc/nginx"
run(cmd.split(" "), stdin=DEVNULL, stdout=DEVNULL, stderr=STDOUT)
# send nginx configs
# send data folder
# reload nginx
ret = self._send_files("/etc/nginx", "/confs")
if not ret :
success = False
log("CONFIG", "", "sending nginx configs failed, configuration will not work as expected...")
ret = self._send_files("/data", "/data")
if not ret :
success = False
log("CONFIG", "", "sending custom configs failed, configuration will not work as expected...")
ret = self._send_to_apis("POST", "/reload")
if not ret :
success = False
log("CONFIG", "", "reload failed, configuration will not work as expected...")
return success
def start_scheduler(self) :
if self.__scheduler_thread is not None and self.__scheduler_thread.is_alive() :
raise Exception("scheduler is already running, can't run it twice")
self.__schedule = True
self.__scheduler_thread = Thread(target=self.__scheduler_run_pending)
self.__scheduler_thread.start()
def stop_scheduler(self) :
if self.__scheduler_thread is not None and self.__scheduler_thread.is_alive() :
self.__schedule_lock.acquire()
self.__schedule = False
self.__schedule_lock.release()
self.__scheduler_thread.join()
self.__scheduler_thread = None
def reload_scheduler(self, env) :
if self.__scheduler_thread is None :
return self.__scheduler.reload(env=env, apis=self._get_apis())
def __get_scheduler(self, env) :
self.__schedule_lock.acquire()
if self.__schedule :
self.__schedule_lock.release()
raise Exception("can't create new scheduler, old one is still running...")
self.__schedule_lock.release()
return JobScheduler(env=env, lock=self.__lock, apis=self._get_apis())

79
autoconf/Controller.py Normal file
View File

@ -0,0 +1,79 @@
from abc import ABC, abstractmethod
from time import sleep
from Config import Config
from logger import log
class Controller(ABC) :
def __init__(self, ctrl_type, lock=None) :
self._type = ctrl_type
self._instances = []
self._services = []
self._supported_config_types = ["http", "stream", "server-http", "server-stream", "default-server-http", "modsec", "modsec-crs"]
self._configs = {}
for config_type in self._supported_config_types :
self._configs[config_type] = {}
self._config = Config(ctrl_type, lock)
def wait(self, wait_time) :
while True :
self._instances = self.get_instances()
if len(self._instances) == 0 :
log("CONTROLLER", "⚠️", "No instance found, waiting " + str(wait_time) + "s ...")
sleep(wait_time)
continue
all_ready = True
for instance in self._instances :
if not instance["health"] :
log("CONTROLLER", "⚠️", "Instance " + instance["name"] + " is not ready, waiting " + str(wait_time) + "s ...")
sleep(wait_time)
all_ready = False
break
if all_ready :
break
return self._instances
@abstractmethod
def _get_controller_instances(self) :
pass
@abstractmethod
def _to_instances(self, controller_instance) :
pass
def get_instances(self) :
instances = []
for controller_instance in self._get_controller_instances() :
for instance in self._to_instances(controller_instance) :
instances.append(instance)
return instances
@abstractmethod
def _get_controller_services(self) :
pass
@abstractmethod
def _to_services(self, controller_service) :
pass
def get_services(self) :
services = []
for controller_service in self._get_controller_services() :
for service in self._to_services(controller_service) :
services.append(service)
return services
@abstractmethod
def get_configs(self) :
pass
@abstractmethod
def apply_config(self) :
pass
@abstractmethod
def process_events(self) :
pass

View File

@ -0,0 +1,63 @@
import traceback
from docker import DockerClient
from Controller import Controller
from logger import log
class DockerController(Controller) :
def __init__(self, docker_host) :
super().__init__("docker")
self.__client = DockerClient(base_url=docker_host)
def _get_controller_instances(self) :
return self.__client.containers.list(filters={"label" : "bunkerweb.AUTOCONF"})
def _to_instances(self, controller_instance) :
instance = {}
instance["name"] = controller_instance.name
instance["hostname"] = controller_instance.name
instance["health"] = controller_instance.status == "running" and controller_instance.attrs["State"]["Health"]["Status"] == "healthy"
instance["env"] = {}
for env in controller_instance.attrs["Config"]["Env"] :
variable = env.split("=")[0]
if variable in ["PATH", "NGINX_VERSION", "NJS_VERSION", "PKG_RELEASE"] :
continue
value = env.replace(variable + "=", "", 1)
instance["env"][variable] = value
return [instance]
def _get_controller_services(self) :
return self.__client.containers.list(filters={"label" : "bunkerweb.SERVER_NAME"})
def _to_services(self, controller_service) :
service = {}
for variable, value in controller_service.labels.items() :
if not variable.startswith("bunkerweb.") :
continue
service[variable.replace("bunkerweb.", "", 1)] = value
return [service]
def get_configs(self) :
raise("get_configs is not supported with DockerController")
def apply_config(self) :
return self._config.apply(self._instances, self._services, configs=self._configs)
def process_events(self) :
for event in self.__client.events(decode=True, filters={"type": "container"}) :
self._instances = self.get_instances()
self._services = self.get_services()
if not self._config.update_needed(self._instances, self._services) :
continue
log("DOCKER-CONTROLLER", "", "Catched docker event, deploying new configuration ...")
try :
ret = self.apply_config()
if not ret :
log("DOCKER-CONTROLLER", "", "Error while deploying new configuration")
else :
log("DOCKER-CONTROLLER", "", "Successfully deployed new configuration 🚀")
except :
log("DOCKER-CONTROLLER", "", "Exception while deploying new configuration :")
print(traceback.format_exc())

54
autoconf/Dockerfile Normal file
View File

@ -0,0 +1,54 @@
FROM python:3-alpine
# Install dependencies
COPY deps/requirements.txt /opt/bunkerweb/deps/requirements.txt
RUN apk add --no-cache --virtual build gcc python3-dev musl-dev libffi-dev openssl-dev cargo && \
mkdir /opt/bunkerweb/deps/python && \
pip install --no-cache-dir --require-hashes --target /opt/bunkerweb/deps/python -r /opt/bunkerweb/deps/requirements.txt && \
apk del build
# Copy files
# can't exclude specific files/dir from . so we are copying everything by hand
COPY api /opt/bunkerweb/api
COPY cli /opt/bunkerweb/cli
COPY confs /opt/bunkerweb/confs
COPY core /opt/bunkerweb/core
COPY gen /opt/bunkerweb/gen
COPY helpers /opt/bunkerweb/helpers
COPY job /opt/bunkerweb/job
COPY utils /opt/bunkerweb/utils
COPY settings.json /opt/bunkerweb/settings.json
COPY VERSION /opt/bunkerweb/VERSION
COPY autoconf /opt/bunkerweb/autoconf
# Add nginx user, drop bwcli, setup data folders, permissions and logging
RUN apk add --no-cache git && \
ln -s /usr/local/bin/python3 /usr/bin/python3 && \
addgroup -g 101 nginx && \
adduser -h /var/cache/nginx -g nginx -s /bin/sh -G nginx -D -H -u 101 nginx && \
apk add --no-cache bash && \
cp /opt/bunkerweb/helpers/bwcli /usr/local/bin && \
mkdir /opt/bunkerweb/configs && \
for dir in $(echo "cache configs configs/http configs/stream configs/server-http configs/server-stream configs/default-server-http configs/default-server-stream configs/modsec configs/modsec-crs letsencrypt plugins www") ; do ln -s "/data/${dir}" "/opt/bunkerweb/${dir}" ; done && \
mkdir /opt/bunkerweb/tmp && \
chown -R root:nginx /opt/bunkerweb && \
find /opt/bunkerweb -type f -exec chmod 0740 {} \; && \
find /opt/bunkerweb -type d -exec chmod 0750 {} \; && \
chmod 770 /opt/bunkerweb/tmp && \
chmod 750 /opt/bunkerweb/gen/main.py /opt/bunkerweb/job/main.py /opt/bunkerweb/cli/main.py /usr/local/bin/bwcli /opt/bunkerweb/helpers/*.sh /opt/bunkerweb/autoconf/main.py /opt/bunkerweb/deps/python/bin/* && \
find /opt/bunkerweb/core/*/jobs/* -type f -exec chmod 750 {} \; && \
chown root:nginx /usr/local/bin/bwcli && \
mkdir /etc/nginx && \
chown -R nginx:nginx /etc/nginx && \
chmod -R 770 /etc/nginx && \
ln -s /data/letsencrypt /etc/letsencrypt && \
mkdir /var/log/letsencrypt /var/lib/letsencrypt && \
chown root:nginx /var/log/letsencrypt /var/lib/letsencrypt && \
chmod 770 /var/log/letsencrypt /var/lib/letsencrypt && \
ln -s /proc/1/fd/1 /var/log/letsencrypt/letsencrypt.log
VOLUME /data /etc/nginx
WORKDIR /opt/bunkerweb/autoconf
CMD ["python", "/opt/bunkerweb/autoconf/main.py"]

View File

@ -0,0 +1,191 @@
from traceback import format_exc
from kubernetes import client, config, watch
from threading import Thread, Lock
from logger import log
from Controller import Controller
from ConfigCaller import ConfigCaller
class IngressController(Controller, ConfigCaller) :
def __init__(self) :
Controller.__init__(self, "kubernetes")
ConfigCaller.__init__(self)
config.load_incluster_config()
self.__corev1 = client.CoreV1Api()
self.__networkingv1 = client.NetworkingV1Api()
self.__internal_lock = Lock()
def _get_controller_instances(self) :
controller_instances = []
for pod in self.__corev1.list_pod_for_all_namespaces(watch=False).items :
if pod.metadata.annotations != None and "bunkerweb.io/AUTOCONF" in pod.metadata.annotations :
controller_instances.append(pod)
return controller_instances
def _to_instances(self, controller_instance) :
instance = {}
instance["name"] = controller_instance.metadata.name
instance["hostname"] = controller_instance.status.pod_ip
health = False
if controller_instance.status.conditions is not None :
for condition in controller_instance.status.conditions :
if condition.type == "Ready" and condition.status == "True" :
health = True
break
instance["health"] = health
instance["env"] = {}
for env in controller_instance.spec.containers[0].env :
if env.value is not None :
instance["env"][env.name] = env.value
else :
instance["env"][env.name] = ""
for controller_service in self._get_controller_services() :
if controller_service.metadata.annotations is not None :
for annotation, value in controller_service.metadata.annotations.items() :
if not annotation.startswith("bunkerweb.io/") :
continue
variable = annotation.replace("bunkerweb.io/", "", 1)
if self._is_setting(variable) :
instance["env"][variable] = value
return [instance]
def _get_controller_services(self) :
return self.__networkingv1.list_ingress_for_all_namespaces(watch=False).items
def _to_services(self, controller_service) :
if controller_service.spec is None or controller_service.spec.rules is None :
return []
services = []
# parse rules
for rule in controller_service.spec.rules :
if rule.host is None :
log("INGRESS-CONTROLLER", "⚠️", "Ignoring unsupported ingress rule without host.")
continue
service = {}
service["SERVER_NAME"] = rule.host
if rule.http is None :
services.append(service)
continue
location = 1
for path in rule.http.paths :
if path.path is None :
log("INGRESS-CONTROLLER", "⚠️", "Ignoring unsupported ingress rule without path.")
continue
if path.backend.service is None :
log("INGRESS-CONTROLLER", "⚠️", "Ignoring unsupported ingress rule without backend service.")
continue
if path.backend.service.port is None :
log("INGRESS-CONTROLLER", "⚠️", "Ignoring unsupported ingress rule without backend service port.")
continue
if path.backend.service.port.number is None :
log("INGRESS-CONTROLLER", "⚠️", "Ignoring unsupported ingress rule without backend service port number.")
continue
service_list = self.__corev1.list_service_for_all_namespaces(watch=False, field_selector="metadata.name=" + path.backend.service.name).items
if len(service_list) == 0 :
log("INGRESS-CONTROLLER", "⚠️", "Ignoring ingress rule with service " + path.backend.service.name + " : service not found.")
continue
reverse_proxy_host = "http://" + path.backend.service.name + "." + service_list[0].metadata.namespace + ".svc.cluster.local:" + str(path.backend.service.port.number)
service["USE_REVERSE_PROXY"] = "yes"
service["REVERSE_PROXY_HOST_" + str(location)] = reverse_proxy_host
service["REVERSE_PROXY_URL_" + str(location)] = path.path
location += 1
services.append(service)
# parse tls
if controller_service.spec.tls is not None :
log("INGRESS-CONTROLLER", "⚠️", "Ignoring unsupported tls.")
# parse annotations
if controller_service.metadata.annotations is not None :
for service in services :
for annotation, value in controller_service.metadata.annotations.items() :
if not annotation.startswith("bunkerweb.io/") :
continue
variable = annotation.replace("bunkerweb.io/", "", 1)
if not variable.startswith(service["SERVER_NAME"].split(" ")[0] + "_") :
continue
variable = variable.replace(service["SERVER_NAME"].split(" ")[0] + "_", "", 1)
if self._is_multisite_setting(variable) :
service[variable] = value
return services
def get_configs(self) :
configs = {}
supported_config_types = ["http", "stream", "server-http", "server-stream", "default-server-http", "modsec", "modsec-crs"]
for config_type in supported_config_types :
configs[config_type] = {}
for configmap in self.__corev1.list_config_map_for_all_namespaces(watch=False).items :
if configmap.metadata.annotations is None or "bunkerweb.io/CONFIG_TYPE" not in configmap.metadata.annotations :
continue
config_type = configmap.metadata.annotations["bunkerweb.io/CONFIG_TYPE"]
if config_type not in supported_config_types :
log("INGRESS-CONTROLLER", "⚠️", "Ignoring unsupported CONFIG_TYPE " + config_type + " for ConfigMap " + configmap.metadata.name)
continue
if not configmap.data :
log("INGRESS-CONTROLLER", "⚠️", "Ignoring blank ConfigMap " + configmap.metadata.name)
continue
config_site = ""
if "bunkerweb.io/CONFIG_SITE" in configmap.metadata.annotations :
config_site = configmap.metadata.annotations["bunkerweb.io/CONFIG_SITE"] + "/"
for config_name, config_data in configmap.data.items() :
configs[config_type][config_site + config_name] = config_data
return configs
def __watch(self, watch_type) :
w = watch.Watch()
what = None
if watch_type == "pod" :
what = self.__corev1.list_pod_for_all_namespaces
elif watch_type == "ingress" :
what = self.__networkingv1.list_ingress_for_all_namespaces
elif watch_type == "configmap" :
what = self.__corev1.list_config_map_for_all_namespaces
else :
raise Exception("unsupported watch_type " + watch_type)
while True :
locked = False
try :
for event in w.stream(what) :
self.__internal_lock.acquire()
locked = True
self._instances = self.get_instances()
self._services = self.get_services()
self._configs = self.get_configs()
if not self._config.update_needed(self._instances, self._services, configs=self._configs) :
self.__internal_lock.release()
locked = False
continue
log("INGRESS-CONTROLLER", "", "Catched kubernetes event, deploying new configuration ...")
try :
ret = self.apply_config()
if not ret :
log("INGRESS-CONTROLLER", "", "Error while deploying new configuration ...")
else :
log("INGRESS-CONTROLLER", "", "Successfully deployed new configuration 🚀")
except :
log("INGRESS-CONTROLLER", "", "Exception while deploying new configuration :")
print(format_exc())
self.__internal_lock.release()
locked = False
except Exception as e :
log("INGRESS-CONTROLLER", "", "Exception while reading k8s event (type = " + watch_type + ") : ")
print(format_exc())
if locked :
self.__internal_lock.release()
def apply_config(self) :
self._config.stop_scheduler()
ret = self._config.apply(self._instances, self._services, configs=self._configs)
self._config.start_scheduler()
return ret
def process_events(self) :
watch_types = ["pod", "ingress", "configmap"]
threads = []
for watch_type in watch_types :
threads.append(Thread(target=self.__watch, args=(watch_type,)))
for thread in threads :
thread.start()
for thread in threads :
thread.join()

View File

@ -0,0 +1,97 @@
from traceback import format_exc
from threading import Thread, Lock
from docker import DockerClient
from logger import log
from base64 import b64decode
from Controller import Controller
class SwarmController(Controller) :
def __init__(self, docker_host) :
super().__init__("swarm")
self.__client = DockerClient(base_url=docker_host)
self.__internal_lock = Lock()
def _get_controller_instances(self) :
return self.__client.services.list(filters={"label" : "bunkerweb.AUTOCONF"})
def _to_instances(self, controller_instance) :
instances = []
instance_env = {}
for env in controller_instance.attrs["Spec"]["TaskTemplate"]["ContainerSpec"]["Env"] :
variable = env.split("=")[0]
value = env.replace(variable + "=", "", 1)
instance_env[variable] = value
for task in controller_instance.tasks() :
instance = {}
instance["name"] = task["ID"]
instance["hostname"] = controller_instance.name + "." + task["NodeID"] + "." + task["ID"]
instance["health"] = task["Status"]["State"] == "running"
instance["env"] = instance_env
instances.append(instance)
return instances
def _get_controller_services(self) :
return self.__client.services.list(filters={"label" : "bunkerweb.SERVER_NAME"})
def _to_services(self, controller_service) :
service = {}
for variable, value in controller_service.attrs["Spec"]["Labels"].items() :
if not variable.startswith("bunkerweb.") :
continue
service[variable.replace("bunkerweb.", "", 1)] = value
return [service]
def get_configs(self) :
configs = {}
for config_type in self._supported_config_types :
configs[config_type] = {}
for config in self.__client.configs.list(filters={"label" : "bunkerweb.CONFIG_TYPE"}) :
config_type = config.attrs["Spec"]["Labels"]["bunkerweb.CONFIG_TYPE"]
config_name = config.name
if config_type not in self._supported_config_types :
log("SWARM-CONTROLLER", "⚠️", "Ignoring unsupported CONFIG_TYPE " + config_type + " for Config " + config_name)
continue
config_site = ""
if "bunkerweb.CONFIG_SITE" in config.attrs["Spec"]["Labels"] :
config_site = config.attrs["Spec"]["Labels"]["bunkerweb.CONFIG_SITE"] + "/"
configs[config_type][config_site + config_name] = b64decode(config.attrs["Spec"]["Data"])
return configs
def apply_config(self) :
self._config.stop_scheduler()
ret = self._config.apply(self._instances, self._services, configs=self._configs)
self._config.start_scheduler()
return ret
def __event(self, event_type) :
for event in self.__client.events(decode=True, filters={"type": event_type}) :
self.__internal_lock.acquire()
self._instances = self.get_instances()
self._services = self.get_services()
self._configs = self.get_configs()
if not self._config.update_needed(self._instances, self._services, configs=self._configs) :
self.__internal_lock.release()
continue
log("SWARM-CONTROLLER", "", "Catched Swarm event, deploying new configuration ...")
try :
ret = self.apply_config()
if not ret :
log("SWARM-CONTROLLER", "", "Error while deploying new configuration ...")
else :
log("SWARM-CONTROLLER", "", "Successfully deployed new configuration 🚀")
except :
log("SWARM-CONTROLLER", "", "Exception while deploying new configuration :")
print(format_exc())
self.__internal_lock.release()
def process_events(self) :
event_types = ["service", "config"]
threads = []
for event_type in event_types :
threads.append(Thread(target=self.__event, args=(event_type,)))
for thread in threads :
thread.start()
for thread in threads :
thread.join()

69
autoconf/main.py Normal file
View File

@ -0,0 +1,69 @@
#!/usr/bin/python3
import signal, os, traceback, time, subprocess
import sys
sys.path.append("/opt/bunkerweb/deps/python")
sys.path.append("/opt/bunkerweb/utils")
sys.path.append("/opt/bunkerweb/api")
sys.path.append("/opt/bunkerweb/job")
from SwarmController import SwarmController
from IngressController import IngressController
from DockerController import DockerController
from logger import log
# Get variables
swarm = os.getenv("SWARM_MODE", "no") == "yes"
kubernetes = os.getenv("KUBERNETES_MODE", "no") == "yes"
docker_host = os.getenv("DOCKER_HOST", "unix:///var/run/docker.sock")
wait_retry_interval = int(os.getenv("WAIT_RETRY_INTERVAL", "5"))
def exit_handler(signum, frame) :
log("AUTOCONF", "", "Stop signal received, exiting...")
os._exit(0)
signal.signal(signal.SIGINT, exit_handler)
signal.signal(signal.SIGTERM, exit_handler)
try :
# Setup /data folder if needed
#if swarm or kubernetes :
proc = subprocess.run(["/opt/bunkerweb/helpers/data.sh", "AUTOCONF"], stdin=subprocess.DEVNULL, stderr=subprocess.STDOUT)
if proc.returncode != 0 :
os._exit(1)
# Instantiate the controller
if swarm :
log("AUTOCONF", "", "Swarm mode detected")
controller = SwarmController(docker_host)
elif kubernetes :
log("AUTOCONF", "", "Kubernetes mode detected")
controller = IngressController()
else :
log("AUTOCONF", "", "Docker mode detected")
controller = DockerController(docker_host)
# Wait for instances
log("AUTOCONF", "", "Waiting for BunkerWeb instances ...")
instances = controller.wait(wait_retry_interval)
log("AUTOCONF", "", "BunkerWeb instances are ready 🚀")
i = 1
for instance in instances :
log("AUTOCONF", "", "Instance #" + str(i) + " : " + instance["name"])
i += 1
# Run first configuration
ret = controller.apply_config()
if not ret :
log("AUTOCONF", "", "Error while applying initial configuration")
os._exit(1)
# Process events
log("AUTOCONF", "", "Processing events ...")
controller.process_events()
except :
log("AUTOCONF", "", "Exception while running autoconf :")
print(traceback.format_exc())
sys.exit(1)

99
cli/CLI.py Normal file
View File

@ -0,0 +1,99 @@
from os.path import isfile
from dotenv import dotenv_values
from docker import DockerClient
from kubernetes import client, config
from ApiCaller import ApiCaller
from API import API
class CLI(ApiCaller) :
def __init__(self) :
self.__variables = dotenv_values("/etc/nginx/variables.env")
self.__integration = self.__detect_integration()
super().__init__(self.__get_apis())
def __detect_integration(self) :
ret = "unknown"
distrib = ""
if isfile("/etc/os-release") :
with open("/etc/os-release", "r") as f :
if "Alpine" in f.read() :
distrib = "alpine"
else :
distrib = "other"
# Docker case
if distrib == "alpine" and isfile("/usr/sbin/nginx") :
return "docker"
# Linux case
if distrib == "other" :
return "linux"
# Swarm case
if self.__variables["SWARM_MODE"] == "yes" :
return "swarm"
# Kubernetes case
if self.__variables["KUBERNETES_MODE"] == "yes" :
return "kubernetes"
# Autoconf case
if distrib == "alpine" :
return "autoconf"
raise Exception("can't detect integration")
def __get_apis(self) :
# Docker case
if self.__integration == "docker" :
return [API("http://127.0.0.1:" + self.__variables["API_HTTP_PORT"], host=self.__variables["API_SERVER_NAME"])]
# Autoconf case
if self.__integration == "autoconf" :
docker_client = DockerClient()
apis = []
for container in self.__client.containers.list(filters={"label" : "bunkerweb.AUTOCONF"}) :
port = "5000"
host = "bwapi"
for env in container.attrs["Config"]["Env"] :
if env.startswith("API_HTTP_PORT=") :
port = env.split("=")[1]
elif env.startswith("API_SERVER_NAME=") :
host = env.split("=")[1]
apis.append(API("http://" + container.name + ":" + port, host=host))
return apis
# Swarm case
if self.__integration == "swarm" :
docker_client = DockerClient()
apis = []
for service in self.__client.services.list(filters={"label" : "bunkerweb.AUTOCONF"}) :
port = "5000"
host = "bwapi"
for env in service.attrs["Spec"]["TaskTemplate"]["ContainerSpec"]["Env"] :
if env.startswith("API_HTTP_PORT=") :
port = env.split("=")[1]
elif env.startswith("API_SERVER_NAME=") :
host = env.split("=")[1]
for task in service.tasks() :
apis.append(API("http://" + service.name + "." + task["NodeID"] + "." + task["ID"] + ":" + port, host=host))
return apis
# Kubernetes case
if self.__integration == "kubernetes" :
config.load_incluster_config()
corev1 = client.CoreV1Api()
apis = []
for pod in corev1.list_pod_for_all_namespaces(watch=False).items :
if pod.metadata.annotations != None and "bunkerweb.io/AUTOCONF" in pod.metadata.annotations and pod.status.pod_ip :
port = "5000"
host = "bwapi"
for env in pod.spec.containers[0].env :
if env.name == "API_HTTP_PORT" :
port = env.value
elif env.name == "API_SERVER_NAME" :
host = env.value
apis.append(API("http://" + pod.status.pod_ip + ":" + port, host=host))
return apis
def unban(self, ip) :
if self._send_to_apis("POST", "/unban", data={"ip": ip}) :
return True, "IP " + ip + " has been unbanned"
return False, "error"

52
cli/main.py Normal file
View File

@ -0,0 +1,52 @@
#!/usr/bin/env python3
import argparse, traceback, os
import sys
sys.path.append("/opt/bunkerweb/deps/python")
sys.path.append("/opt/bunkerweb/cli")
sys.path.append("/opt/bunkerweb/utils")
sys.path.append("/opt/bunkerweb/api")
from logger import log
from CLI import CLI
if __name__ == "__main__" :
try :
# Global parser
parser = argparse.ArgumentParser(description="BunkerWeb Command Line Interface")
subparsers = parser.add_subparsers(help="command", dest="command")
# Unban subparser
parser_unban = subparsers.add_parser("unban", help="remove a ban from the cache")
parser_unban.add_argument("ip", type=str, help="IP address to unban")
# Parse args
args = parser.parse_args()
# Instantiate CLI
cli = CLI()
# Execute command
ret, err = False, "unknown command"
if args.command == "unban" :
ret, err = cli.unban(args.ip)
if not ret :
print("CLI command status : ❌ (fail)")
print(err)
os._exit(1)
else :
print("CLI command status : ✔️ (success)")
print(err)
os._exit(0)
except SystemExit as se :
sys.exit(se.code)
except :
print("❌ Error while executing bwcli : ")
print(traceback.format_exc())
sys.exit(1)
sys.exit(0)

View File

@ -1,91 +0,0 @@
#!/bin/sh
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
# compile and install ModSecurity library
cd /tmp
git clone https://github.com/SpiderLabs/ModSecurity.git
cd ModSecurity
./build.sh
git submodule init
git submodule update
./configure --enable-static=no --disable-doxygen-doc --disable-dependency-tracking
make -j $NTASK
make install-strip
# get nginx modules
cd /tmp
# ModSecurity connector for nginx
git clone https://github.com/SpiderLabs/ModSecurity-nginx.git
# headers more
git clone https://github.com/openresty/headers-more-nginx-module.git
# geoip
git clone https://github.com/leev/ngx_http_geoip2_module.git
# cookie
git clone https://github.com/AirisX/nginx_cookie_flag_module.git
# LUA requirements
git clone https://github.com/openresty/luajit2.git
cd luajit2
make -j $NTASK
make install
cd /tmp
git clone https://github.com/openresty/lua-resty-core.git
cd lua-resty-core
make install
cd /tmp
git clone https://github.com/openresty/lua-resty-lrucache.git
cd lua-resty-lrucache
make install
cd /tmp
git clone https://github.com/openresty/lua-resty-dns.git
cd lua-resty-dns
make install
cd /tmp
git clone https://github.com/bungle/lua-resty-session.git
cd lua-resty-session
cp -r lib/resty/* /usr/local/lib/lua/resty
cd /tmp
git clone https://github.com/bungle/lua-resty-random.git
cd lua-resty-random
make install
cd /tmp
git clone https://github.com/openresty/lua-resty-string.git
cd lua-resty-string
make install
cd /tmp
git clone https://github.com/openresty/lua-cjson.git
cd lua-cjson
make -j $NTASK
make install
make install-extra
cd /tmp
git clone https://github.com/ittner/lua-gd.git
cd lua-gd
make -j $NTASK
make INSTALL_PATH=/usr/local/lib/lua/5.1 install
cd /tmp
git clone https://github.com/ledgetech/lua-resty-http.git
cd lua-resty-http
make install
cd /tmp
git clone https://github.com/openresty/lua-nginx-module.git
export LUAJIT_LIB=/usr/local/lib
export LUAJIT_INC=/usr/local/include/luajit-2.1
# compile and install nginx
cd /tmp
VERSION="1.18.0"
wget https://nginx.org/download/nginx-${VERSION}.tar.gz
tar -xvzf nginx-${VERSION}.tar.gz
cd nginx-${VERSION}
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/run/nginx/nginx.pid --modules-path=/usr/lib/nginx/modules --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_realip_module --add-module=/tmp/ModSecurity-nginx --add-module=/tmp/headers-more-nginx-module --add-module=/tmp/ngx_http_geoip2_module --add-module=/tmp/nginx_cookie_flag_module --add-module=/tmp/lua-nginx-module
make -j $NTASK
make install
strip /usr/sbin/nginx
# remove build dependencies
apk del build

View File

@ -1,40 +0,0 @@
location = %ANTIBOT_URI% {
default_type 'text/html';
if ($request_method = GET) {
content_by_lua_block {
local cookie = require "cookie"
local captcha = require "captcha"
if not cookie.is_set("uri") then
return ngx.exit(ngx.HTTP_FORBIDDEN)
end
local img, res = captcha.get_challenge()
cookie.set({captchares = res})
local code = captcha.get_code(img, "%ANTIBOT_URI%")
ngx.say(code)
}
}
if ($request_method = POST) {
access_by_lua_block {
local cookie = require "cookie"
local captcha = require "captcha"
if not cookie.is_set("captchares") then
return ngx.exit(ngx.HTTP_FORBIDDEN)
end
ngx.req.read_body()
local args, err = ngx.req.get_post_args(1)
if err == "truncated" or not args or not args["captcha"] then
return ngx.exit(ngx.HTTP_FORBIDDEN)
end
local captcha_user = args["captcha"]
local check = captcha.check(captcha_user, cookie.get("captchares"))
if not check then
return ngx.redirect("%ANTIBOT_URI%")
end
cookie.set({captcha = "ok"})
return ngx.redirect(cookie.get("uri"))
}
}
}

View File

@ -1,39 +0,0 @@
location = %ANTIBOT_URI% {
default_type 'text/html';
if ($request_method = GET) {
content_by_lua_block {
local cookie = require "cookie"
local javascript = require "javascript"
if not cookie.is_set("challenge") then
return ngx.exit(ngx.HTTP_FORBIDDEN)
end
local challenge = cookie.get("challenge")
local code = javascript.get_code(challenge, "%ANTIBOT_URI%", cookie.get("uri"))
ngx.say(code)
}
}
if ($request_method = POST) {
content_by_lua_block {
local cookie = require "cookie"
local javascript = require "javascript"
if not cookie.is_set("challenge") then
return ngx.exit(ngx.HTTP_FORBIDDEN)
end
ngx.req.read_body()
local args, err = ngx.req.get_post_args(1)
if err == "truncated" or not args or not args["challenge"] then
return ngx.exit(ngx.HTTP_FORBIDDEN)
end
local challenge = args["challenge"]
local check = javascript.check(cookie.get("challenge"), challenge)
if not check then
return ngx.exit(ngx.HTTP_FORBIDDEN)
end
cookie.set({javascript = "ok"})
return ngx.exit(ngx.OK)
}
}
}

View File

@ -1,39 +0,0 @@
location = %ANTIBOT_URI% {
default_type 'text/html';
if ($request_method = GET) {
content_by_lua_block {
local cookie = require "cookie"
local recaptcha = require "recaptcha"
if not cookie.is_set("uri") then
return ngx.exit(ngx.HTTP_FORBIDDEN)
end
local code = recaptcha.get_code("%ANTIBOT_URI%", "%ANTIBOT_RECAPTCHA_SITEKEY%")
ngx.say(code)
}
}
if ($request_method = POST) {
access_by_lua_block {
local cookie = require "cookie"
local recaptcha = require "recaptcha"
if not cookie.is_set("uri") then
return ngx.exit(ngx.HTTP_FORBIDDEN)
end
ngx.req.read_body()
local args, err = ngx.req.get_post_args(1)
if err == "truncated" or not args or not args["token"] then
return ngx.exit(ngx.HTTP_FORBIDDEN)
end
local token = args["token"]
local check = recaptcha.check(token, "%ANTIBOT_RECAPTCHA_SECRET%")
if check < %ANTIBOT_RECAPTCHA_SCORE% then
ngx.log(ngx.WARN, "client has recaptcha score of " .. tostring(check))
return ngx.exit(ngx.HTTP_FORBIDDEN)
end
cookie.set({recaptcha = "ok"})
return ngx.redirect(cookie.get("uri"))
}
}
}

38
confs/api.conf Normal file
View File

@ -0,0 +1,38 @@
server {
server_name {{ API_SERVER_NAME }};
# HTTP listen
listen 0.0.0.0:{{ API_HTTP_PORT }};
listen 127.0.0.1:{{ API_HTTP_PORT }};
# maximum body size for API
client_max_body_size 1G;
# default mime type is JSON
default_type 'application/json';
# check IP and do the API call
access_by_lua_block {
local api = require "api"
local logger = require "logger"
if not ngx.var.http_host or ngx.var.http_host ~= "{{ API_SERVER_NAME }}" then
logger.log(ngx.WARN, "API", "Wrong Host header from IP " .. ngx.var.remote_addr)
return ngx.exit(ngx.HTTP_CLOSE)
end
local ok, err = api:is_allowed_ip()
if not ok then
logger.log(ngx.WARN, "API", "Can't validate access from IP " .. ngx.var.remote_addr .. " : " .. err)
return ngx.exit(ngx.HTTP_CLOSE)
end
logger.log(ngx.NOTICE, "API", "Validated access from IP " .. ngx.var.remote_addr)
local ok, err, status, resp = api:do_api_call()
if not ok then
logger.log(ngx.WARN, "API", "Call from " .. ngx.var.remote_addr .. " on " .. ngx.var.uri .. " failed : " .. err)
else
logger.log(ngx.NOTICE, "API", "Successful call from " .. ngx.var.remote_addr .. " on " .. ngx.var.uri .. " : " .. err)
end
ngx.status = status
ngx.say(resp)
return ngx.exit(status)
}
}

View File

@ -1,2 +0,0 @@
auth_basic "%AUTH_BASIC_TEXT%";
auth_basic_user_file /etc/nginx/.htpasswd;

View File

@ -1,4 +0,0 @@
location %AUTH_BASIC_LOCATION% {
auth_basic "%AUTH_BASIC_TEXT%";
auth_basic_user_file /etc/nginx/.htpasswd;
}

View File

@ -1,7 +0,0 @@
listen 0.0.0.0:443 ssl %HTTP2%;
ssl_certificate /etc/letsencrypt/live/%FIRST_SERVER_NAME%/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/%FIRST_SERVER_NAME%/privkey.pem;
ssl_protocols TLSv1.3;
ssl_prefer_server_ciphers off;
ssl_session_tickets off;
%STRICT_TRANSPORT_SECURITY%

View File

@ -1,3 +0,0 @@
if ($bad_user_agent = yes) {
return 444;
}

View File

@ -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%;

View File

@ -1 +0,0 @@
more_set_headers "Content-Security-Policy: %CONTENT_SECURITY_POLICY%";

View File

@ -1 +0,0 @@
set_cookie_flag %COOKIE_FLAGS%;

View File

@ -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%

View File

@ -0,0 +1,15 @@
server {
server_name _;
# HTTP listen
{% if LISTEN_HTTP == "yes" +%}
listen 0.0.0.0:{{ HTTP_PORT }} default_server {% if USE_PROXY_PROTOCOL == "yes" %}proxy_protocol{% endif %};
{% endif %}
# include core and plugins default-server configurations
include /etc/nginx/default-server-http/*.conf;
# include custom default-server configurations
include /opt/bunkerweb/configs/default-server-http/*.conf;
}

8
confs/dhparam Normal file
View 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-----

View File

@ -1,3 +0,0 @@
if ($host !~ ^(%SERVER_NAME%)$) {
return 444;
}

View File

@ -1,7 +0,0 @@
error_page %CODE% %PAGE%;
location = %PAGE% {
root %ROOT_FOLDER%;
modsecurity off;
internal;
}

25
confs/fastcgi.conf Normal file
View 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;

25
confs/fastcgi_params Normal file
View File

@ -0,0 +1,25 @@
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;

View File

@ -1 +0,0 @@
more_set_headers "Feature-Policy: %FEATURE_POLICY%";

View File

@ -1,3 +0,0 @@
if ($allowed_country = no) {
return 444;
}

View File

@ -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%
}

View File

@ -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%;

25
confs/healthcheck.conf Normal file
View File

@ -0,0 +1,25 @@
server {
# healthcheck service for docker, swarm and k8s
server_name healthcheck.bunkerweb.io;
# only listen on localhost
listen 127.0.0.1:6000;
# healthcheck endpoint
location ~ ^/healthz$ {
keepalive_timeout 0;
default_type "text/plain";
content_by_lua_block {
ngx.say("ok")
}
}
# disable logging
access_log off;
# don't respond to other requests
location / {
return 444;
}
}

94
confs/http.conf Normal file
View File

@ -0,0 +1,94 @@
# /etc/nginx/base_http.conf
# 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;
# access log format
log_format logf '{{ LOG_FORMAT }}';
access_log /var/log/nginx/access.log logf;
# temp paths
proxy_temp_path /opt/bunkerweb/tmp/proxy_temp;
client_body_temp_path /opt/bunkerweb/tmp/client_temp;
fastcgi_temp_path /opt/bunkerweb/tmp/fastcgi_temp;
uwsgi_temp_path /opt/bunkerweb/tmp/uwsgi_temp;
scgi_temp_path /opt/bunkerweb/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/bunkerweb/lua/?.lua;/opt/bunkerweb/core/?.lua;/opt/bunkerweb/plugins/?.lua;/opt/bunkerweb/deps/lib/lua/?.lua;;";
lua_package_cpath "/opt/bunkerweb/deps/lib/?.so;/opt/bunkerweb/deps/lib/lua/?.so;;";
lua_ssl_trusted_certificate "/opt/bunkerweb/misc/root-ca.pem";
lua_ssl_verify_depth 2;
lua_shared_dict datastore {{ DATASTORE_MEMORY_SIZE }};
# LUA init block
include /etc/nginx/init-lua.conf;
# API server
{% if USE_API == "yes" %}include /etc/nginx/api.conf;{% endif +%}
# healthcheck server
include /etc/nginx/healthcheck.conf;
# default server
{% if MULTISITE == "yes" or DISABLE_DEFAULT_SERVER == "yes" +%}
include /etc/nginx/default-server-http.conf;
{% endif +%}
# disable sending nginx version globally
server_tokens off;
# server config(s)
{% if TEMP_NGINX != "yes" +%}
{% 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" and SERVER_NAME != "" +%}
include /etc/nginx/server.conf;
{% endif %}
{% endif %}

View File

@ -1,7 +0,0 @@
listen 0.0.0.0:443 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%

118
confs/init-lua.conf Normal file
View File

@ -0,0 +1,118 @@
init_by_lua_block {
local logger = require "logger"
local datastore = require "datastore"
local plugins = require "plugins"
local utils = require "utils"
local cjson = require "cjson"
logger.log(ngx.NOTICE, "INIT", "Init phase started")
-- Remove previous data from the datastore
local data_keys = {"^plugin_", "^variable_", "^plugins$", "^api_", "^misc_"}
for i, key in pairs(data_keys) do
local ok, err = datastore:delete_all(key)
if not ok then
logger.log(ngx.ERR, "INIT", "Can't delete " .. key .. " from datastore : " .. err)
return false
end
logger.log(ngx.INFO, "INIT", "Deleted " .. key .. " from datastore")
end
-- Load variables into the datastore
local file = io.open("/etc/nginx/variables.env")
if not file then
logger.log(ngx.ERR, "INIT", "Can't open /etc/nginx/variables.env file")
return false
end
file:close()
for line in io.lines("/etc/nginx/variables.env") do
local variable, value = line:match("(.+)=(.*)")
ok, err = datastore:set("variable_" .. variable, value)
if not ok then
logger.log(ngx.ERR, "INIT", "Can't save variable " .. variable .. " into datastore")
return false
end
end
-- Set default values into the datastore
ok, err = datastore:set("plugins", cjson.encode({}))
if not ok then
logger.log(ngx.ERR, "INIT", "Can't set default value for plugins into the datastore : " .. err)
return false
end
ok, err = utils.set_values()
if not ok then
logger.log(ngx.ERR, "INIT", "Error while setting default values : " .. err)
return false
end
-- API setup
local value, err = datastore:get("variable_USE_API")
if not value then
logger.log(ngx.ERR, "INIT", "Can't get variable USE_API from the datastore")
return false
end
if value == "yes" then
value, err = datastore:get("variable_API_WHITELIST_IP")
if not value then
logger.log(ngx.ERR, "INIT", "Can't get variable API_WHITELIST_IP from the datastore")
return false
end
local whitelists = { data = {}}
for whitelist in value:gmatch("%S+") do
table.insert(whitelists.data, whitelist)
end
ok, err = datastore:set("api_whitelist_ip", cjson.encode(whitelists))
if not ok then
logger.log(ngx.ERR, "INIT", "Can't save api_whitelist_ip to datastore : " .. err)
return false
end
end
-- Load plugins into the datastore
local plugin_paths = {"/opt/bunkerweb/core", "/opt/bunkerweb/plugins"}
for i, plugin_path in ipairs(plugin_paths) do
local paths = io.popen("find -L " .. plugin_path .. " -maxdepth 1 -type d ! -path " .. plugin_path)
for path in paths:lines() do
plugin, err = plugins:load(path)
if not plugin then
logger.log(ngx.ERR, "INIT", "Error while loading plugin from " .. path .. " : " .. err)
return false
end
logger.log(ngx.NOTICE, "INIT", "Loaded plugin " .. plugin.id .. " v" .. plugin.version)
end
end
-- Call init method of plugins
local list, err = plugins:list()
if not list then
logger.log(ngx.ERR, "INIT", "Can't list loaded plugins : " .. err)
list = {}
end
for i, plugin in ipairs(list) do
local ret, plugin_lua = pcall(require, plugin.id .. "/" .. plugin.id)
if ret then
local plugin_obj = plugin_lua.new()
if plugin_obj.init ~= nil then
ok, err = plugin_obj:init()
if not ok then
logger.log(ngx.ERR, "INIT", "Plugin " .. plugin.id .. " failed on init() : " .. err)
else
logger.log(ngx.INFO, "INIT", "Successfull init() call for plugin " .. plugin.id .. " : " .. err)
end
else
logger.log(ngx.INFO, "INIT", "init() method not found in " .. plugin.id .. ", skipped execution")
end
else
if plugin_lua:match("not found") then
logger.log(ngx.INFO, "INIT", "can't require " .. plugin.id .. " : not found")
else
logger.log(ngx.ERR, "INIT", "can't require " .. plugin.id .. " : " .. plugin_lua)
end
end
end
logger.log(ngx.NOTICE, "INIT", "Init phase ended")
}

View File

@ -1,3 +0,0 @@
limit_req_status 429;
limit_req zone=limit burst=%LIMIT_REQ_BURST% nodelay;

View File

@ -1,136 +0,0 @@
set $session_secret %ANTIBOT_SESSION_SECRET%;
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%

View File

@ -1,4 +0,0 @@
map $http_user_agent $bad_user_agent {
default no;
%BLOCK_USER_AGENT%
}

99
confs/mime.types Normal file
View File

@ -0,0 +1,99 @@
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/avif avif;
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/wasm wasm;
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;
}

View File

@ -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'"

View File

@ -1,66 +0,0 @@
# process rules with disruptive actions
SecRuleEngine On
# allow body checks
SecRequestBodyAccess On
# enable XML parsing
SecRule REQUEST_HEADERS:Content-Type "(?:application(?:/soap\+|/)|text/)xml" \
"id:'200000',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=XML"
# enable JSON parsing
SecRule REQUEST_HEADERS:Content-Type "application/json" \
"id:'200001',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=JSON"
# maximum data size
SecRequestBodyLimit 13107200
SecRequestBodyNoFilesLimit 131072
# reject requests if bigger than max data size
SecRequestBodyLimitAction Reject
# reject if we can't process the body
SecRule REQBODY_ERROR "!@eq 0" \
"id:'200002', phase:2,t:none,log,deny,status:400,msg:'Failed to parse request body.',logdata:'%{reqbody_error_msg}',severity:2"
# be strict with multipart/form-data body
SecRule MULTIPART_STRICT_ERROR "!@eq 0" \
"id:'200003',phase:2,t:none,log,deny,status:400, \
msg:'Multipart request body failed strict validation: \
PE %{REQBODY_PROCESSOR_ERROR}, \
BQ %{MULTIPART_BOUNDARY_QUOTED}, \
BW %{MULTIPART_BOUNDARY_WHITESPACE}, \
DB %{MULTIPART_DATA_BEFORE}, \
DA %{MULTIPART_DATA_AFTER}, \
HF %{MULTIPART_HEADER_FOLDING}, \
LF %{MULTIPART_LF_LINE}, \
SM %{MULTIPART_MISSING_SEMICOLON}, \
IQ %{MULTIPART_INVALID_QUOTING}, \
IP %{MULTIPART_INVALID_PART}, \
IH %{MULTIPART_INVALID_HEADER_FOLDING}, \
FL %{MULTIPART_FILE_LIMIT_EXCEEDED}'"
SecRule MULTIPART_UNMATCHED_BOUNDARY "@eq 1" \
"id:'200004',phase:2,t:none,log,deny,msg:'Multipart parser detected a possible unmatched boundary.'"
# enable response body checks
SecResponseBodyAccess On
SecResponseBodyMimeType text/plain text/html text/xml application/json
SecResponseBodyLimit 524288
SecResponseBodyLimitAction ProcessPartial
# log usefull stuff
SecAuditEngine RelevantOnly
SecAuditLogRelevantStatus "^(?:5|4(?!04))"
SecAuditLogType Serial
SecAuditLog /var/log/modsec_audit.log
# scan uploaded files with clamv
%USE_CLAMAV_UPLOAD%
# include OWASP CRS rules
%MODSECURITY_INCLUDE_CRS%
%MODSECURITY_INCLUDE_CUSTOM_CRS%
%MODSECURITY_INCLUDE_CRS_RULES%
# include custom rules
%MODSECURITY_INCLUDE_CUSTOM_RULES%

View File

@ -1,2 +0,0 @@
modsecurity on;
modsecurity_rules_file /etc/nginx/modsecurity-rules.conf;

View File

@ -1,96 +1,64 @@
# /etc/nginx/nginx.conf # /etc/nginx/nginx.conf
# run as daemon # load dynamic modules
daemon on; load_module /opt/bunkerweb/modules/ngx_http_cookie_flag_filter_module.so;
#load_module /opt/bunkerweb/modules/ngx_http_geoip2_module.so;
load_module /opt/bunkerweb/modules/ngx_http_headers_more_filter_module.so;
load_module /opt/bunkerweb/modules/ngx_http_lua_module.so;
load_module /opt/bunkerweb/modules/ngx_http_modsecurity_module.so;
load_module /opt/bunkerweb/modules/ngx_http_brotli_filter_module.so;
load_module /opt/bunkerweb/modules/ngx_http_brotli_static_module.so;
#load_module /opt/bunkerweb/modules/ngx_stream_geoip2_module.so;
#load_module /opt/bunkerweb/modules/ngx_stream_lua_module.so;
# do NOT run as root # PID file
user nginx; {% if TEMP_NGINX != "yes" +%}
pid /opt/bunkerweb/tmp/nginx.pid;
{% else +%}
pid /opt/bunkerweb/tmp/nginx-temp.pid;
{% endif %}
# worker number = CPU core(s) # worker number (default = auto)
worker_processes auto; worker_processes {{ WORKER_PROCESSES }};
# faster regexp # faster regexp
pcre_jit on; pcre_jit on;
# config files for dynamic modules # max open files for each worker
include /etc/nginx/modules/*.conf; worker_rlimit_nofile {{ WORKER_RLIMIT_NOFILE }};
# error log level
error_log /var/log/nginx/error.log {{ LOG_LEVEL }};
# reason env var
env REASON;
events { events {
# max connections per worker # max connections per worker
worker_connections 1024; worker_connections {{ WORKER_CONNECTIONS }};
# epoll seems to be the best on Linux # epoll seems to be the best on Linux
use epoll; use epoll;
} }
http { http {
# zero copy within the kernel # include base http configuration
sendfile on; include /etc/nginx/http.conf;
# send packets only if filled # include core and plugins http configurations
tcp_nopush on; include /etc/nginx/http/*.conf;
# remove 200ms delay # include custom http configurations
tcp_nodelay on; include /opt/bunkerweb/configs/http/*.conf;
# 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%;
# 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%
# 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;
# 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;
} }
#stream {
# include base stream configuration
# include /etc/nginx/stream.conf;
# include core and plugins stream configurations
# include /etc/nginx/stream/*.conf;
# include custom stream configurations
# include /opt/bunkerweb/configs/stream/*.conf;
#}

View File

@ -1,5 +0,0 @@
location ~ \.php$ {
fastcgi_pass %REMOTE_PHP%:9000;
fastcgi_index index.php;
include fastcgi.conf;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +0,0 @@
%PROXY_REAL_IP_FROM%
real_ip_header %PROXY_REAL_IP_HEADER%;
real_ip_recursive %PROXY_REAL_IP_RECURSIVE%;

View File

@ -1,3 +0,0 @@
if ($scheme = http) {
return 301 https://$host$request_uri;
}

View File

@ -1 +0,0 @@
more_set_headers "Referrer-Policy: %REFERRER_POLICY%";

17
confs/scgi_params Normal file
View File

@ -0,0 +1,17 @@
scgi_param REQUEST_METHOD $request_method;
scgi_param REQUEST_URI $request_uri;
scgi_param QUERY_STRING $query_string;
scgi_param CONTENT_TYPE $content_type;
scgi_param DOCUMENT_URI $document_uri;
scgi_param DOCUMENT_ROOT $document_root;
scgi_param SCGI 1;
scgi_param SERVER_PROTOCOL $server_protocol;
scgi_param REQUEST_SCHEME $scheme;
scgi_param HTTPS $https if_not_empty;
scgi_param REMOTE_ADDR $remote_addr;
scgi_param REMOTE_PORT $remote_port;
scgi_param SERVER_PORT $server_port;
scgi_param SERVER_NAME $server_name;

View File

@ -1,3 +0,0 @@
root %ROOT_FOLDER%;
index index.html index.php;
try_files $uri $uri/ =404;

View File

@ -0,0 +1,63 @@
access_by_lua_block {
local logger = require "logger"
local datastore = require "datastore"
local plugins = require "plugins"
-- Don't process internal requests
if ngx.req.is_internal() then
logger.log(ngx.INFO, "ACCESS", "Skipped access phase because request is internal")
return
end
logger.log(ngx.INFO, "ACCESS", "Access phase started")
-- Process bans as soon as possible
local banned, err = datastore:get("bans_ip_" .. ngx.var.remote_addr)
if banned then
logger.log(ngx.WARN, "ACCESS", "IP " .. ngx.var.remote_addr .. " is banned with reason : " .. banned)
ngx.exit(ngx.HTTP_FORBIDDEN)
end
-- List all plugins
local list, err = plugins:list()
if not list then
logger.log(ngx.ERR, "ACCESS", "Can't list loaded plugins : " .. err)
list = {}
end
-- Call access method of plugins
for i, plugin in ipairs(list) do
local ret, plugin_lua = pcall(require, plugin.id .. "/" .. plugin.id)
if ret then
local plugin_obj = plugin_lua.new()
if plugin_obj.access ~= nil then
logger.log(ngx.INFO, "ACCESS", "Executing access() of " .. plugin.id)
local ok, err, ret, value = plugin_obj:access()
if not ok then
logger.log(ngx.ERR, "ACCESS", "Error while calling access() on plugin " .. plugin.id .. " : " .. err)
else
logger.log(ngx.INFO, "ACCESS", "Return value from " .. plugin.id .. ".access() is : " .. err)
end
if ret then
if type(value) == "number" then
if value == ngx.HTTP_FORBIDDEN then
logger.log(ngx.WARN, "ACCESS", "Denied access from " .. plugin.id .. " : " .. err)
ngx.var.reason = plugin.id
else
logger.log(ngx.NOTICE, "ACCESS", plugin.id .. " returned status " .. tostring(value) .. " : " .. err)
end
return ngx.exit(value)
else
return value
end
end
else
logger.log(ngx.INFO, "ACCESS", "access() method not found in " .. plugin.id .. ", skipped execution")
end
end
end
logger.log(ngx.INFO, "ACCESS", "Access phase ended")
}

View File

@ -0,0 +1,44 @@
log_by_lua_block {
local utils = require "utils"
local logger = require "logger"
local datastore = require "datastore"
local plugins = require "plugins"
logger.log(ngx.INFO, "LOG", "Log phase started")
-- List all plugins
local list, err = plugins:list()
if not list then
logger.log(ngx.ERR, "LOG", "Can't list loaded plugins : " .. err)
list = {}
end
-- Call log method of plugins
for i, plugin in ipairs(list) do
local ret, plugin_lua = pcall(require, plugin.id .. "/" .. plugin.id)
if ret then
local plugin_obj = plugin_lua.new()
if plugin_obj.log ~= nil then
logger.log(ngx.INFO, "LOG", "Executing log() of " .. plugin.id)
local ok, err = plugin_obj:log()
if not ok then
logger.log(ngx.ERR, "LOG", "Error while calling log() on plugin " .. plugin.id .. " : " .. err)
else
logger.log(ngx.INFO, "LOG", "Return value from " .. plugin.id .. ".log() is : " .. err)
end
else
logger.log(ngx.INFO, "LOG", "log() method not found in " .. plugin.id .. ", skipped execution")
end
end
end
-- Display reason at info level
local reason = utils.get_reason()
if reason then
logger.log(ngx.INFO, "LOG", "Client was denied with reason : " .. reason)
end
logger.log(ngx.INFO, "LOG", "Log phase ended")
}

View File

@ -0,0 +1,27 @@
server {
# server name (vhost)
server_name {{ SERVER_NAME }};
# HTTP listen
{% if LISTEN_HTTP == "yes" +%}
listen 0.0.0.0:{{ HTTP_PORT }}{% if MULTISITE == "no" and DISABLE_DEFAULT_SERVER == "no" %} default_server{% endif %}{% if USE_PROXY_PROTOCOL == "yes" %} proxy_protocol{% endif %};
{% endif %}
index index.php index.html index.htm;
# custom config
include /opt/bunkerweb/configs/server-http/*.conf;
{% if MULTISITE == "yes" +%}
include /opt/bunkerweb/configs/server-http/{{ SERVER_NAME.split(" ")[0] }}/*.conf;
{% endif %}
# reason variable
set $reason '';
# include LUA files
include {{ NGINX_PREFIX }}access-lua.conf;
include {{ NGINX_PREFIX }}log-lua.conf;
# include config files
include {{ NGINX_PREFIX }}server-http/*.conf;
}

View File

@ -1,33 +0,0 @@
server {
include /server-confs/*.conf;
set $session_secret %ANTIBOT_SESSION_SECRET%;
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%
}

71
confs/stream.conf Normal file
View File

@ -0,0 +1,71 @@
# /etc/nginx/stream.conf
# size of the preread buffer
preread_buffer_size 16k;
# timeout of the preread phase
preread_timeout 30s;
# proxy protocol timeout
proxy_protocol_timeout 30s;
# resolvers to use
resolver {{ DNS_RESOLVERS }} ipv6=off;
# resolver timeout
resolver_timeout 30s;
# remove 200ms delay
tcp_nodelay on;
# bucket hash size
variables_hash_bucket_size 64;
variables_hash_max_size 1024;
# log format and level
log_format proxy '$remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received '
'$session_time "$upstream_addr" '
'"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';
access_log /var/log/nginx/access.log proxy;
# lua path and dicts
lua_package_path "/opt/bunkerweb/lua/?.lua;/opt/bunkerweb/core/?.lua;/opt/bunkerweb/plugins/?.lua;/opt/bunkerweb/deps/lib/lua/?.lua;;";
lua_package_cpath "/opt/bunkerweb/deps/lib/?.so;/opt/bunkerweb/deps/lib/lua/?.so;;";
lua_ssl_trusted_certificate "/opt/bunkerweb/misc/root-ca.pem";
lua_ssl_verify_depth 2;
lua_shared_dict datastore 256m;
# 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 %}

17
confs/uwsgi_params Normal file
View File

@ -0,0 +1,17 @@
uwsgi_param QUERY_STRING $query_string;
uwsgi_param REQUEST_METHOD $request_method;
uwsgi_param CONTENT_TYPE $content_type;
uwsgi_param CONTENT_LENGTH $content_length;
uwsgi_param REQUEST_URI $request_uri;
uwsgi_param PATH_INFO $document_uri;
uwsgi_param DOCUMENT_ROOT $document_root;
uwsgi_param SERVER_PROTOCOL $server_protocol;
uwsgi_param REQUEST_SCHEME $scheme;
uwsgi_param HTTPS $https if_not_empty;
uwsgi_param REMOTE_ADDR $remote_addr;
uwsgi_param REMOTE_PORT $remote_port;
uwsgi_param SERVER_PORT $server_port;
uwsgi_param SERVER_NAME $server_name;

View File

@ -1 +0,0 @@
more_set_headers "X-Content-Type-Options: %X_CONTENT_TYPE_OPTIONS%";

View File

@ -1 +0,0 @@
more_set_headers "X-Frame-Options: %X_FRAME_OPTIONS%";

View File

@ -1 +0,0 @@
more_set_headers "X-XSS-Protection: %X_XSS_PROTECTION%";

375
core/antibot/antibot.lua Normal file
View File

@ -0,0 +1,375 @@
local _M = {}
_M.__index = _M
local utils = require "utils"
local datastore = require "datastore"
local logger = require "logger"
local cjson = require "cjson"
local session = require "resty.session"
local captcha = require "antibot.captcha"
local base64 = require "base64"
local sha256 = require "resty.sha256"
local str = require "resty.string"
local http = require "resty.http"
function _M.new()
local self = setmetatable({}, _M)
return self, nil
end
function _M:init()
-- Check if init is needed
local init_needed, err = utils.has_not_variable("USE_ANTIBOT", "no")
if init_needed == nil then
return false, err
end
if not init_needed then
return true, "no service uses Antibot, skipping init"
end
-- Load templates
local templates = {}
for i, template in ipairs({"javascript", "captcha", "recaptcha", "hcaptcha"}) do
local f, err = io.open("/opt/bunkerweb/core/antibot/files/" .. template .. ".html")
if not f then
return false, "error while loading " .. template .. ".html : " .. err
end
templates[template] = f:read("*all")
f:close()
end
local ok, err = datastore:set("plugin_antibot_templates", cjson.encode(templates))
if not ok then
return false, "can't save templates to datastore : " .. err
end
return true, "success"
end
function _M:access()
-- Check if access is needed
local antibot, err = utils.get_variable("USE_ANTIBOT")
if antibot == nil then
return false, err, nil, nil
end
if antibot == "no" then
return true, "Antibot not activated", nil, nil
end
-- Get challenge URI
local challenge_uri, err = utils.get_variable("ANTIBOT_URI")
if not challenge_uri then
return false, "can't get Antibot URI from datastore : " .. err, nil, nil
end
-- Don't go further if client resolved the challenge
local resolved, err, original_uri = self:challenge_resolved(antibot)
if resolved == nil then
return false, "can't check if challenge is resolved : " .. err, nil, nil
end
if resolved then
if ngx.var.uri == challenge_uri then
return true, "client already resolved the challenge", true, ngx.redirect(original_uri)
end
return true, "client already resolved the challenge", nil, nil
end
-- Redirect to challenge page
if ngx.var.uri ~= challenge_uri then
local ok, err = self:prepare_challenge(antibot, challenge_uri)
if not ok then
return false, "can't prepare challenge : " .. err, true, ngx.HTTP_INTERNAL_SERVER_ERROR
end
return true, "redirecting client to the challenge uri", true, ngx.redirect(challenge_uri)
end
-- Display challenge
if ngx.var.request_method == "GET" then
local ok, err = self:display_challenge(antibot, challenge_uri)
if not ok then
if err == "can't open session" then
local ok, err = self:prepare_challenge(antibot, challenge_uri)
if not ok then
return false, "can't prepare challenge : " .. err, true, ngx.HTTP_INTERNAL_SERVER_ERROR
end
return true, "redirecting client to the challenge uri", true, ngx.redirect(challenge_uri)
end
return false, "display challenge error : " .. err, true, ngx.HTTP_INTERNAL_SERVER_ERROR
end
return true, "displaying challenge to client", true, ngx.HTTP_OK
end
-- Check challenge
if ngx.var.request_method == "POST" then
local ok, err, redirect = self:check_challenge(antibot)
if ok == nil then
if err == "can't open session" then
local ok, err = self:prepare_challenge(antibot, challenge_uri)
if not ok then
return false, "can't prepare challenge : " .. err, true, ngx.HTTP_INTERNAL_SERVER_ERROR
end
return true, "redirecting client to the challenge uri", true, ngx.redirect(challenge_uri)
end
return false, "check challenge error : " .. err, true, ngx.HTTP_INTERNAL_SERVER_ERROR
end
if redirect then
return true, "check challenge redirect : " .. redirect, true, ngx.redirect(redirect)
end
local ok, err = self:display_challenge(antibot)
if not ok then
if err == "can't open session" then
local ok, err = self:prepare_challenge(antibot, challenge_uri)
if not ok then
return false, "can't prepare challenge : " .. err, true, ngx.HTTP_INTERNAL_SERVER_ERROR
end
return true, "redirecting client to the challenge uri", true, ngx.redirect(challenge_uri)
end
return false, "display challenge error : " .. err, true, ngx.HTTP_INTERNAL_SERVER_ERROR
end
return true, "displaying challenge to client", true, ngx.HTTP_OK
end
-- Method is suspicious, let's deny the request
return true, "unsupported HTTP method for Antibot", true, ngx.HTTP_FORBIDDEN
end
function _M:challenge_resolved(antibot)
local chall_session, present, reason = session.open()
if present and chall_session.data.resolved and chall_session.data.type == antibot then
return true, "challenge " .. antibot .. " resolved", chall_session.data.original_uri
end
return false, "challenge " .. antibot .. " not resolved", nil
end
function _M:prepare_challenge(antibot, challenge_uri)
local chall_session, present, reason = session.open()
if not present then
local chall_session, present, reason = chall_session:start()
if not chall_session then
return false, "can't start session", nil
end
chall_session.data.type = antibot
chall_session.data.resolved = false
if ngx.var.request_uri == challenge_uri then
chall_session.data.original_uri = "/"
else
chall_session.data.original_uri = ngx.var.request_uri
end
if antibot == "cookie" then
chall_session.data.resolved = true
end
local saved, err = chall_session:save()
if not saved then
return false, "error while saving session : " .. err
end
end
return true, antibot .. " challenge prepared"
end
function _M:display_challenge(antibot, challenge_uri)
-- Open session
local chall_session, present, reason = session.open()
if not present then
return false, "can't open session"
end
-- Check if session type is equal to antibot type
if antibot ~= chall_session.data.type then
return false, "session type is different from antibot type"
end
-- Compute challenges
if antibot == "javascript" then
chall_session:start()
chall_session.data.random = utils.rand(20)
chall_session:save()
elseif antibot == "captcha" then
chall_session:start()
local chall_captcha = captcha.new()
chall_captcha:font("/opt/bunkerweb/core/antibot/files/font.ttf")
chall_captcha:generate()
chall_session.data.image = base64.encode(chall_captcha:jpegStr(70))
chall_session.data.text = chall_captcha:getStr()
chall_session:save()
end
-- Load HTML templates
local str_templates, err = datastore:get("plugin_antibot_templates")
if not str_templates then
return false, "can't get templates from datastore : " .. err
end
local templates = cjson.decode(str_templates)
local html = ""
-- Javascript case
if antibot == "javascript" then
html = templates.javascript:format(challenge_uri, chall_session.data.random)
end
-- Captcha case
if antibot == "captcha" then
html = templates.captcha:format(challenge_uri, chall_session.data.image)
end
-- reCAPTCHA case
if antibot == "recaptcha" then
local recaptcha_sitekey, err = utils.get_variable("ANTIBOT_RECAPTCHA_SITEKEY")
if not recaptcha_sitekey then
return false, "can't get reCAPTCHA sitekey variable : " .. err
end
html = templates.recaptcha:format(recaptcha_sitekey, challenge_uri, recaptcha_sitekey)
end
-- hCaptcha case
if antibot == "hcaptcha" then
local hcaptcha_sitekey, err = utils.get_variable("ANTIBOT_HCAPTCHA_SITEKEY")
if not hcaptcha_sitekey then
return false, "can't get hCaptcha sitekey variable : " .. err
end
html = templates.hcaptcha:format(challenge_uri, hcaptcha_sitekey)
end
ngx.header["Content-Type"] = "text/html"
ngx.say(html)
return true, "displayed challenge"
end
function _M:check_challenge(antibot)
-- Open session
local chall_session, present, reason = session.open()
if not present then
return nil, "can't open session", nil
end
-- Check if session type is equal to antibot type
if antibot ~= chall_session.data.type then
return nil, "session type is different from antibot type", nil
end
local resolved = false
local err = ""
local redirect = nil
-- Javascript case
if antibot == "javascript" then
ngx.req.read_body()
local args, err = ngx.req.get_post_args(1)
if err == "truncated" or not args or not args["challenge"] then
return false, "missing challenge arg", nil
end
local hash = sha256:new()
hash:update(chall_session.data.random .. args["challenge"])
local digest = hash:final()
resolved = str.to_hex(digest):find("^0000") ~= nil
if not resolved then
return false, "wrong value", nil
end
chall_session:start()
chall_session.data.resolved = true
chall_session:save()
return true, "resolved", chall_session.data.original_uri
end
-- Captcha case
if antibot == "captcha" then
ngx.req.read_body()
local args, err = ngx.req.get_post_args(1)
if err == "truncated" or not args or not args["captcha"] then
return false, "missing challenge arg", nil
end
if chall_session.data.text ~= args["captcha"] then
return false, "wrong value", nil
end
chall_session:start()
chall_session.data.resolved = true
chall_session:save()
return true, "resolved", chall_session.data.original_uri
end
-- reCAPTCHA case
if antibot == "recaptcha" then
ngx.req.read_body()
local args, err = ngx.req.get_post_args(1)
if err == "truncated" or not args or not args["token"] then
return false, "missing challenge arg", nil
end
local recaptcha_secret, err = utils.get_variable("ANTIBOT_RECAPTCHA_SECRET")
if not recaptcha_secret then
return nil, "can't get reCAPTCHA secret variable : " .. err, nil
end
local httpc, err = http.new()
if not httpc then
return false, "can't instantiate http object : " .. err, nil, nil
end
local res, err = httpc:request_uri("https://www.google.com/recaptcha/api/siteverify", {
method = "POST",
body = "secret=" .. recaptcha_secret .. "&response=" .. args["token"] .. "&remoteip=" .. ngx.var.remote_addr,
headers = {
["Content-Type"] = "application/x-www-form-urlencoded"
}
})
httpc:close()
if not res then
return nil, "can't send request to reCAPTCHA API : " .. err, nil
end
local ok, data = pcall(cjson.decode, res.body)
if not ok then
return nil, "error while decoding JSON from reCAPTCHA API : " .. data, nil
end
local recaptcha_score, err = utils.get_variable("ANTIBOT_RECAPTCHA_SCORE")
if not recaptcha_score then
return nil, "can't get reCAPTCHA score variable : " .. err, nil
end
if not data.success or data.score < tonumber(recaptcha_score) then
return false, "client failed challenge with score " .. tostring(data.score), nil
end
chall_session:start()
chall_session.data.resolved = true
chall_session:save()
return true, "resolved", chall_session.data.original_uri
end
-- hCaptcha case
if antibot == "hcaptcha" then
ngx.req.read_body()
local args, err = ngx.req.get_post_args(1)
if err == "truncated" or not args or not args["token"] then
return false, "missing challenge arg", nil
end
local hcaptcha_secret, err = utils.get_variable("ANTIBOT_HCAPTCHA_SECRET")
if not hcaptcha_secret then
return nil, "can't get hCaptcha secret variable : " .. err, nil
end
local httpc, err = http.new()
if not httpc then
return false, "can't instantiate http object : " .. err, nil, nil
end
local res, err = httpc:request_uri("https://hcaptcha.com/siteverify", {
method = "POST",
body = "secret=" .. hcaptcha_secret .. "&response=" .. args["token"] .. "&remoteip=" .. ngx.var.remote_addr,
headers = {
["Content-Type"] = "application/x-www-form-urlencoded"
}
})
httpc:close()
if not res then
return nil, "can't send request to hCaptcha API : " .. err, nil
end
local ok, data = pcall(cjson.decode, res.body)
if not ok then
return nil, "error while decoding JSON from hCaptcha API : " .. data, nil
end
if not data.success then
return false, "client failed challenge", nil
end
chall_session:start()
chall_session.data.resolved = true
chall_session:save()
return true, "resolved", chall_session.data.original_uri
end
return nil, "unknown", nil
end
return _M

View File

@ -2,16 +2,15 @@
-- Modifications copyright mrDoctorWho <mrdoctorwho@gmail.com> -- Modifications copyright mrDoctorWho <mrdoctorwho@gmail.com>
-- Published under the MIT license -- Published under the MIT license
-- module("captcha", package.seeall) local _M = {}
local M = {}
local gd = require 'gd' local gd = require 'gd'
local logger = require "logger"
local mt = { __index = {} } local mt = { __index = {} }
function M.new() function _M.new()
local cap = {} local cap = {}
local f = setmetatable({ cap = cap}, mt) local f = setmetatable({ cap = cap}, mt)
return f return f
@ -34,7 +33,8 @@ end
local function random_char(length) local function random_char(length)
local set, char, uid local set, char, uid
local set = [[1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]] -- local set = [[1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]]
local set = [[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]]
local captcha_t = {} local captcha_t = {}
math.randomseed(urandom()) math.randomseed(urandom())
@ -115,7 +115,7 @@ function mt.__index:generate()
local white = self.im:colorAllocate(255, 255, 255) local white = self.im:colorAllocate(255, 255, 255)
local bgcolor local bgcolor
if not self.cap.bgcolor then if not self.cap.bgcolor then
bgcolor = white bgcolor = white
else else
bgcolor = self.im:colorAllocate(self.cap.bgcolor.r , self.cap.bgcolor.g, self.cap.bgcolor.b ) bgcolor = self.im:colorAllocate(self.cap.bgcolor.r , self.cap.bgcolor.g, self.cap.bgcolor.b )
end end
@ -190,4 +190,4 @@ function mt.__index:write(outfile, quality)
return self:getStr() return self:getStr()
end end
return M return _M

View File

@ -0,0 +1,9 @@
map "{{ ANTIBOT_SESSION_SECRET }}" $session_secret {
default "{{ ANTIBOT_SESSION_SECRET }}";
"random" "{{ random(32) }}";
}
map "{{ ANTIBOT_SESSION_NAME }}" $session_name {
default "{{ ANTIBOT_SESSION_NAME }}";
"random" "{{ random(16) }}";
}

File diff suppressed because one or more lines are too long

BIN
core/antibot/files/font.ttf Normal file

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

98
core/antibot/plugin.json Normal file
View File

@ -0,0 +1,98 @@
{
"id": "antibot",
"order": 4,
"name": "Antibot",
"description": "Bot detection by using a challenge.",
"version": "0.1",
"settings": {
"USE_ANTIBOT": {
"context": "multisite",
"default": "no",
"help": "Activate antibot feature.",
"id": "use-antibot",
"label": "Antibot challenge",
"regex": "^(no|cookie|javascript|captcha|recaptcha|hcaptcha)$",
"type": "select",
"select": [
"no",
"cookie",
"javascript",
"captcha",
"recaptcha",
"hcaptcha"
]
},
"ANTIBOT_URI": {
"context": "multisite",
"default": "/challenge",
"help": "Unused URI that clients will be redirected to solve the challenge.",
"id": "antibot-uri",
"label": "Antibot URL",
"regex": "^.*$",
"type": "text"
},
"ANTIBOT_SESSION_SECRET": {
"context": "global",
"default": "random",
"help": "Secret used to encrypt sessions variables for storing data related to challenges.",
"id": "antibot-session-secret",
"label": "Session secret",
"regex": "^.*$",
"type": "text"
},
"ANTIBOT_SESSION_NAME": {
"context": "global",
"default": "random",
"help": "Name of the cookie used by the antibot feature.",
"id": "antibot-session-name",
"label": "Session name",
"regex": "^.*$",
"type": "text"
},
"ANTIBOT_RECAPTCHA_SCORE": {
"context": "multisite",
"default": "0.7",
"help": "Minimum score required for reCAPTCHA challenge.",
"id": "antibot-recaptcha-score",
"label": "reCAPTCHA score",
"regex": "^.*$",
"type": "text"
},
"ANTIBOT_RECAPTCHA_SITEKEY": {
"context": "multisite",
"default": "",
"help": "Sitekey for reCAPTCHA challenge.",
"id": "antibot-recaptcha-sitekey",
"label": "reCAPTCHA sitekey",
"regex": "^.*$",
"type": "text"
},
"ANTIBOT_RECAPTCHA_SECRET": {
"context": "multisite",
"default": "",
"help": "Secret for reCAPTCHA challenge.",
"id": "antibot-recaptcha-secret",
"label": "reCAPTCHA secret",
"regex": "^.*$",
"type": "text"
},
"ANTIBOT_HCAPTCHA_SITEKEY": {
"context": "multisite",
"default": "",
"help": "Sitekey for hCaptcha challenge.",
"id": "antibot-hcaptcha-sitekey",
"label": "hCaptcha sitekey",
"regex": "^.*$",
"type": "text"
},
"ANTIBOT_HCAPTCHA_SECRET": {
"context": "multisite",
"default": "",
"help": "Secret for hCaptcha challenge.",
"id": "antibot-hcaptcha-secret",
"label": "hCaptcha secret",
"regex": "^.*$",
"type": "text"
}
}
}

View File

@ -0,0 +1,11 @@
{% if USE_AUTH_BASIC == "yes" +%}
{% if AUTH_BASIC_LOCATION == "sitewide" %}
auth_basic "{{ AUTH_BASIC_TEXT }}";
auth_basic_user_file {{ NGINX_PREFIX }}server-http/htpasswd;
{% else %}
location {{ AUTH_BASIC_LOCATION }} {
auth_basic "{{ AUTH_BASIC_TEXT }}";
auth_basic_user_file {{ NGINX_PREFIX }}server-http/htpasswd;
}
{% endif %}
{% endif %}

View File

@ -0,0 +1,4 @@
{% set crypt = import('crypt') %}
{% if USE_AUTH_BASIC == "yes" %}
{{ AUTH_BASIC_USER }}:{{ crypt.crypt(AUTH_BASIC_PASSWORD, crypt.mksalt(crypt.METHOD_SHA512)) }}
{% endif %}

View File

@ -0,0 +1,54 @@
{
"id": "authbasic",
"order": 999,
"name": "Auth basic",
"description": "Enforce login before accessing a resource or the whole site using HTTP basic auth method.",
"version": "0.1",
"settings": {
"USE_AUTH_BASIC": {
"context": "multisite",
"default": "no",
"help": "Use HTTP basic auth",
"id": "use-auth-basic",
"label": "Use HTTP basic auth",
"regex": "^(yes|no)$",
"type": "check"
},
"AUTH_BASIC_LOCATION": {
"context": "multisite",
"default": "sitewide",
"help": "URL of the protected resource or sitewide value.",
"id": "auth-basic-location",
"label": "Location",
"regex": "^.*$",
"type": "text"
},
"AUTH_BASIC_USER": {
"context": "multisite",
"default": "changeme",
"help": "Username",
"id": "auth-basic-user",
"label": "Username",
"regex": "^.*$",
"type": "text"
},
"AUTH_BASIC_PASSWORD": {
"context": "multisite",
"default": "changeme",
"help": "Password",
"id": "auth-basic-password",
"label": "Password",
"regex": "^.*$",
"type": "text"
},
"AUTH_BASIC_TEXT": {
"context": "multisite",
"default": "Restricted area",
"help": "Text to display",
"id": "auth-basic-text",
"label": "Text",
"regex": "^.*$",
"type": "text"
}
}
}

View File

@ -0,0 +1,72 @@
local _M = {}
_M.__index = _M
local utils = require "utils"
local datastore = require "datastore"
local logger = require "logger"
local cjson = require "cjson"
function _M.new()
local self = setmetatable({}, _M)
return self, nil
end
function _M:log()
self.use = utils.get_variable("USE_BAD_BEHAVIOR")
self.ban_time = utils.get_variable("BAD_BEHAVIOR_BAN_TIME")
self.status_codes = utils.get_variable("BAD_BEHAVIOR_STATUS_CODES")
self.threshold = utils.get_variable("BAD_BEHAVIOR_THRESHOLD")
self.count_time = utils.get_variable("BAD_BEHAVIOR_COUNT_TIME")
if self.use ~= "yes" then
return true, "bad behavior not activated"
end
if not self.status_codes:match(tostring(ngx.status)) then
return true, "not increasing counter"
end
local count, err = datastore:get("plugin_badbehavior_count_" .. ngx.var.remote_addr)
if not count and err ~= "not found" then
return false, "can't get counts from the datastore : " .. err
end
local new_count = 1
if count ~= nil then
new_count = count + 1
end
local ok, err = datastore:set("plugin_badbehavior_count_" .. ngx.var.remote_addr, new_count)
if not ok then
return false, "can't save counts to the datastore : " .. err
end
local function decrease_callback(premature, ip)
local count, err = datastore:get("plugin_badbehavior_count_" .. ip)
if err then
logger.log(ngx.ERR, "BAD-BEHAVIOR", "(decrease_callback) Can't get counts from the datastore : " .. err)
return
end
if not count then
logger.log(ngx.ERR, "BAD-BEHAVIOR", "(decrease_callback) Count is null")
return
end
local new_count = count - 1
if new_count <= 0 then
datastore:delete("plugin_badbehavior_count_" .. ip)
return
end
local ok, err = datastore:set("plugin_badbehavior_count_" .. ip, new_count)
if not ok then
logger.log(ngx.ERR, "BAD-BEHAVIOR", "(decrease_callback) Can't save counts to the datastore : " .. err)
end
end
local hdr, err = ngx.timer.at(tonumber(self.count_time), decrease_callback, ngx.var.remote_addr)
if not ok then
return false, "can't create decrease timer : " .. err
end
if new_count > tonumber(self.threshold) then
local ok, err = datastore:set("bans_ip_" .. ngx.var.remote_addr, "bad behavior", tonumber(self.ban_time))
if not ok then
return false, "can't save ban to the datastore : " .. err
end
logger.log(ngx.WARN, "BAD-BEHAVIOR", "IP " .. ngx.var.remote_addr .. " is banned for " .. tostring(self.ban_time) .. "s (" .. tostring(new_count) .. "/" .. tostring(self.threshold) .. ")")
end
return true, "success"
end
return _M

View File

@ -0,0 +1,54 @@
{
"id": "badbehavior",
"order": 2,
"name": "Bad behavior",
"description": "Ban IP generating too much 'bad' HTTP status code in a period of time.",
"version": "0.1",
"settings": {
"USE_BAD_BEHAVIOR": {
"context": "multisite",
"default": "yes",
"help": "Activate Bad behavior feature.",
"id": "use-bad-behavior",
"label": "Activate bad behavior",
"regex": "^(yes|no)$",
"type": "check"
},
"BAD_BEHAVIOR_STATUS_CODES": {
"context": "multisite",
"default": "400 401 403 404 405 429 444",
"help": "List of HTTP status codes considered as 'bad'.",
"id": "bad-behavior-status-code",
"label": "Bad status codes",
"regex": "^.*$",
"type": "text"
},
"BAD_BEHAVIOR_BAN_TIME": {
"context": "multisite",
"default": "86400",
"help": "The duration time (in seconds) of a ban when the corresponding IP has reached the threshold.",
"id": "bad-behavior-ban-time",
"label": "Ban duration (in seconds)",
"regex": "^.*$",
"type": "text"
},
"BAD_BEHAVIOR_THRESHOLD": {
"context": "multisite",
"default": "10",
"help": "Maximum number of 'bad' HTTP status codes within the period of time before IP is banned.",
"id": "bad-behavior-threshold",
"label": "Threshold",
"regex": "^.*$",
"type": "text"
},
"BAD_BEHAVIOR_COUNT_TIME": {
"context": "multisite",
"default": "60",
"help": "Period of time where we count 'bad' HTTP status codes.",
"id": "bad-behavior-period",
"label": "Period (in seconds)",
"regex": "^.*$",
"type": "text"
}
}
}

View File

@ -0,0 +1,245 @@
local _M = {}
_M.__index = _M
local utils = require "utils"
local datastore = require "datastore"
local logger = require "logger"
local cjson = require "cjson"
local ipmatcher = require "resty.ipmatcher"
function _M.new()
local self = setmetatable({}, _M)
return self, nil
end
function _M:init()
-- Check if init is needed
local init_needed, err = utils.has_variable("USE_BLACKLIST", "yes")
if init_needed == nil then
return false, err
end
if not init_needed then
return true, "no service uses Blacklist, skipping init"
end
-- Read blacklists
local blacklists = {
["IP"] = {},
["RDNS"] = {},
["ASN"] = {},
["USER_AGENT"] = {},
["URI"] = {}
}
local i = 0
for kind, _ in pairs(blacklists) do
local f, err = io.open("/opt/bunkerweb/cache/blacklist/" .. kind .. ".list", "r")
if f then
for line in f:lines() do
table.insert(blacklists[kind], line)
i = i + 1
end
f:close()
end
end
-- Load them into datastore
local ok, err = datastore:set("plugin_blacklist_list", cjson.encode(blacklists))
if not ok then
return false, "can't store Blacklist list into datastore : " .. err
end
return true, "successfully loaded " .. tostring(i) .. " bad IP/network/rDNS/ASN/User-Agent/URI"
end
function _M:access()
-- Check if access is needed
local access_needed, err = utils.get_variable("USE_BLACKLIST")
if access_needed == nil then
return false, err
end
if access_needed ~= "yes" then
return true, "Blacklist not activated"
end
-- Check the cache
local cached_ip, err = self:is_in_cache("ip" .. ngx.var.remote_addr)
if cached_ip and cached_ip ~= "ok" then
return true, "IP is in blacklist cache (info = " .. cached_ip .. ")", true, ngx.HTTP_FORBIDDEN
end
local cached_uri, err = self:is_in_cache("uri" .. ngx.var.uri)
if cached_uri and cached_uri ~= "ok" then
return true, "URI is in blacklist cache (info = " .. cached_uri .. ")", true, ngx.HTTP_FORBIDDEN
end
local cached_ua = true
if ngx.var.http_user_agent then
cached_ua, err = self:is_in_cache("ua" .. ngx.var.http_user_agent)
if cached_ua and cached_ua ~= "ok" then
return true, "User-Agent is in blacklist cache (info = " .. cached_ua .. ")", true, ngx.HTTP_FORBIDDEN
end
end
if cached_ip and cached_uri and cached_ua then
return true, "full request is in blacklist cache (not blacklisted)", nil, nil
end
-- Get list
local data, err = datastore:get("plugin_blacklist_list")
if not data then
return false, "can't get Blacklist list : " .. err, false, nil
end
local ok, blacklists = pcall(cjson.decode, data)
if not ok then
return false, "error while decoding blacklists : " .. blacklists, false, nil
end
-- Return value
local ret, ret_err = true, "success"
-- Check if IP is in IP/net blacklist
local ip_net, err = utils.get_variable("BLACKLIST_IP")
if ip_net and ip_net ~= "" then
for element in ip_net:gmatch("%S+") do
table.insert(blacklists["IP"], element)
end
end
if not cached_ip then
local ipm, err = ipmatcher.new(blacklists["IP"])
if not ipm then
ret = false
ret_err = "can't instantiate ipmatcher " .. err
else
if ipm:match(ngx.var.remote_addr) then
self:add_to_cache("ip" .. ngx.var.remote_addr, "ip/net")
return ret, "client IP " .. ngx.var.remote_addr .. " is in blacklist", true, ngx.HTTP_FORBIDDEN
end
end
end
-- Check if rDNS is in blacklist
local rdns_global, err = utils.get_variable("BLACKLIST_RDNS_GLOBAL")
local check = true
if not rdns_global then
logger.log(ngx.ERR, "BLACKLIST", "Error while getting BLACKLIST_RDNS_GLOBAL variable : " .. err)
elseif rdns_global == "yes" then
check, err = utils.ip_is_global(ngx.var.remote_addr)
if check == nil then
logger.log(ngx.ERR, "BLACKLIST", "Error while getting checking if IP is global : " .. err)
end
end
if not cached_ip and check then
local rdns, err = utils.get_rdns(ngx.var.remote_addr)
if not rdns then
ret = false
ret_err = "error while trying to get reverse dns : " .. err
else
local rdns_list, err = utils.get_variable("BLACKLIST_RDNS")
if rdns_list and rdns_list ~= "" then
for element in rdns_list:gmatch("%S+") do
table.insert(blacklists["RDNS"], element)
end
end
for i, suffix in ipairs(blacklists["RDNS"]) do
if rdns:sub(-#suffix) == suffix then
self:add_to_cache("ip" .. ngx.var.remote_addr, "rDNS " .. suffix)
return ret, "client IP " .. ngx.var.remote_addr .. " is in blacklist (info = rDNS " .. suffix .. ")", true, ngx.HTTP_FORBIDDEN
end
end
end
end
-- Check if ASN is in blacklist
if not cached_ip then
if utils.ip_is_global(ngx.var.remote_addr) then
local asn, err = utils.get_asn(ngx.var.remote_addr)
if not asn then
ret = false
ret_err = "error while trying to get asn number : " .. err
else
local asn_list, err = utils.get_variable("BLACKLIST_ASN")
if asn_list and asn_list ~= "" then
for element in asn_list:gmatch("%S+") do
table.insert(blacklists["ASN"], element)
end
end
for i, asn_bl in ipairs(blacklists["ASN"]) do
if tostring(asn) == asn_bl then
self:add_to_cache("ip" .. ngx.var.remote_addr, "ASN " .. tostring(asn))
return ret, "client IP " .. ngx.var.remote_addr .. " is in blacklist (kind = ASN " .. tostring(asn) .. ")", true, ngx.HTTP_FORBIDDEN
end
end
end
end
end
-- IP is not blacklisted
local ok, err = self:add_to_cache("ip" .. ngx.var.remote_addr, "ok")
if not ok then
ret = false
ret_err = err
end
-- Check if User-Agent is in blacklist
if not cached_ua and ngx.var.http_user_agent then
local ua_list, err = utils.get_variable("BLACKLIST_USER_AGENT")
if ua_list and ua_list ~= "" then
for element in ua_list:gmatch("%S+") do
table.insert(blacklists["USER_AGENT"], element)
end
end
for i, ua_bl in ipairs(blacklists["USER_AGENT"]) do
if ngx.var.http_user_agent:match(ua_bl) then
self:add_to_cache("ua" .. ngx.var.http_user_agent, "UA " .. ua_bl)
return ret, "client User-Agent " .. ngx.var.http_user_agent .. " is in blacklist (matched " .. ua_bl .. ")", true, ngx.HTTP_FORBIDDEN
end
end
-- UA is not blacklisted
local ok, err = self:add_to_cache("ua" .. ngx.var.http_user_agent, "ok")
if not ok then
ret = false
ret_err = err
end
end
-- Check if URI is in blacklist
if not cached_uri then
local uri_list, err = utils.get_variable("BLACKLIST_URI")
if uri_list and uri_list ~= "" then
for element in uri_list:gmatch("%S+") do
table.insert(blacklists["URI"], element)
end
end
for i, uri_bl in ipairs(blacklists["URI"]) do
if ngx.var.uri:match(uri_bl) then
self:add_to_cache("uri" .. ngx.var.uri, "URI " .. uri_bl)
return ret, "client URI " .. ngx.var.uri .. " is in blacklist (matched " .. uri_bl .. ")", true, ngx.HTTP_FORBIDDEN
end
end
end
-- URI is not blacklisted
local ok, err = self:add_to_cache("uri" .. ngx.var.uri, "ok")
if not ok then
ret = false
ret_err = err
end
return ret, "IP is not in list (error = " .. ret_err .. ")", false, nil
end
function _M:is_in_cache(ele)
local kind, err = datastore:get("plugin_blacklist_cache_" .. ngx.var.server_name .. ele)
if not kind then
if err ~= "not found" then
logger.log(ngx.ERR, "BLACKLIST", "Error while accessing cache : " .. err)
end
return false, err
end
return kind, "success"
end
function _M:add_to_cache(ele, kind)
local ok, err = datastore:set("plugin_blacklist_cache_" .. ngx.var.server_name .. ele, kind, 3600)
if not ok then
logger.log(ngx.ERR, "BLACKLIST", "Error while adding element to cache : " .. err)
return false, err
end
return true, "success"
end
return _M

View File

@ -0,0 +1,152 @@
#!/usr/bin/python3
import sys, os, traceback
sys.path.append("/opt/bunkerweb/deps/python")
sys.path.append("/opt/bunkerweb/utils")
import logger, jobs, requests, ipaddress
def check_line(kind, line) :
if kind == "IP" :
if "/" in line :
try :
ipaddress.ip_network(line)
return True, line
except :
pass
else :
try :
ipaddress.ip_address(line)
return True, line
except :
pass
return False, ""
elif kind == "RDNS" :
if re.match(r"^(\.?[A-Za-z0-9\-]+)*\.[A-Za-z]{2,}$", line) :
return True, line.lower()
return False, ""
elif kind == "ASN" :
real_line = line.replace("AS", "")
if re.match(r"^\d+$", real_line) :
return True, real_line
elif kind == "USER_AGENT" :
return True, line.replace("\\ ", " ").replace("\\.", "%.").replace("\\\\", "\\").replace("-", "%-")
elif kind == "URI" :
if re.match(r"^/", line) :
return True, line
return False, ""
status = 0
try :
# Check if at least a server has Blacklist activated
blacklist_activated = False
# Multisite case
if os.getenv("MULTISITE") == "yes" :
for first_server in os.getenv("SERVER_NAME").split(" ") :
if os.getenv(first_server + "_USE_BLACKLIST", os.getenv("USE_BLACKLIST")) == "yes" :
blacklist_activated = True
break
# Singlesite case
elif os.getenv("USE_BLACKLIST") == "yes" :
blacklist_activated = True
if not blacklist_activated :
logger.log("BLACKLIST", "", "Blacklist is not activated, skipping downloads...")
os._exit(0)
# Create directories if they don't exist
os.makedirs("/opt/bunkerweb/cache/blacklist", exist_ok=True)
os.makedirs("/opt/bunkerweb/tmp/blacklist", exist_ok=True)
# Our urls data
urls = {
"IP": [],
"RDNS": [],
"ASN" : [],
"USER_AGENT": [],
"URI": []
}
# Don't go further if the cache is fresh
kinds_fresh = {
"IP": True,
"RDNS": True,
"ASN" : True,
"USER_AGENT": True,
"URI": True
}
all_fresh = True
for kind in kinds_fresh :
if not jobs.is_cached_file("/opt/bunkerweb/cache/blacklist/" + kind + ".list", "hour") :
kinds_fresh[kind] = False
all_fresh = False
logger.log("BLACKLIST", "", "Blacklist for " + kind + " is not cached, processing downloads..")
else :
logger.log("BLACKLIST", "", "Blacklist for " + kind + " is already in cache, skipping downloads...")
if all_fresh :
os._exit(0)
# Get URLs
urls = {
"IP": [],
"RDNS": [],
"ASN" : [],
"USER_AGENT": [],
"URI": []
}
for kind in urls :
for url in os.getenv("BLACKLIST_" + kind + "_URLS", "").split(" ") :
if url != "" and url not in urls[kind] :
urls[kind].append(url)
# Loop on kinds
for kind, urls_list in urls.items() :
if kinds_fresh[kind] :
continue
# Write combined data of the kind to a single temp file
for url in urls_list :
try :
logger.log("BLACKLIST", "", "Downloading blacklist data from " + url + " ...")
resp = requests.get(url, stream=True)
if resp.status_code != 200 :
continue
i = 0
with open("/opt/bunkerweb/tmp/blacklist/" + kind + ".list", "w") as f :
for line in resp.iter_lines(decode_unicode=True) :
line = line.strip()
if kind != "USER_AGENT" :
line = line.strip().split(" ")[0]
if line == "" or line.startswith("#") or line.startswith(";") :
continue
ok, data = check_line(kind, line)
if ok :
f.write(data + "\n")
i += 1
logger.log("BLACKLIST", "", "Downloaded " + str(i) + " bad " + kind)
# Check if file has changed
file_hash = jobs.file_hash("/opt/bunkerweb/tmp/blacklist/" + kind + ".list")
cache_hash = jobs.cache_hash("/opt/bunkerweb/cache/blacklist/" + kind + ".list")
if file_hash == cache_hash :
logger.log("BLACKLIST", "", "New file " + kind + ".list is identical to cache file, reload is not needed")
else :
logger.log("BLACKLIST", "", "New file " + kind + ".list is different than cache file, reload is needed")
# Put file in cache
cached, err = jobs.cache_file("/opt/bunkerweb/tmp/blacklist/" + kind + ".list", "/opt/bunkerweb/cache/blacklist/" + kind + ".list", file_hash)
if not cached :
logger.log("BLACKLIST", "", "Error while caching blacklist : " + err)
status = 2
if status != 2 :
status = 1
except :
status = 2
logger.log("BLACKLIST", "", "Exception while getting blacklist from " + url + " :")
print(traceback.format_exc())
except :
status = 2
logger.log("BLACKLIST", "", "Exception while running blacklist-download.py :")
print(traceback.format_exc())
sys.exit(status)

125
core/blacklist/plugin.json Normal file
View File

@ -0,0 +1,125 @@
{
"id": "blacklist",
"order": 2,
"name": "Blacklist",
"description": "Deny access based on internal and external IP/network/rDNS/ASN blacklists.",
"version": "0.1",
"settings": {
"USE_BLACKLIST": {
"context": "multisite",
"default": "yes",
"help": "Activate blacklist feature.",
"id": "use-blacklist",
"label": "Activate blacklisting",
"regex": "^(yes|no)$",
"type": "check"
},
"BLACKLIST_IP_URLS": {
"context": "global",
"default": "https://www.dan.me.uk/torlist/?exit",
"help": "List of URLs, separated with spaces, containing bad IP/network to block.",
"id": "blacklist-ip-urls",
"label": "Blacklist IP/network URLs",
"regex": "^.*$",
"type": "text"
},
"BLACKLIST_IP": {
"context": "multisite",
"default": "",
"help": "List of IP/network, separated with spaces, to block.",
"id": "blacklist-ip",
"label": "Blacklist IP/network",
"regex": "^.*$",
"type": "text"
},
"BLACKLIST_RDNS": {
"context": "multisite",
"default": ".shodan.io .censys.io",
"help": "List of reverse DNS suffixes, separated with spaces, to block.",
"id": "blacklist-rdns",
"label": "Blacklist reverse DNS",
"regex": "^.*$",
"type": "text"
},
"BLACKLIST_RDNS_URLS": {
"context": "global",
"default": "",
"help": "List of URLs, separated with spaces, containing reverse DNS suffixes to block.",
"id": "blacklist-rdns-urls",
"label": "Blacklist reverse DNS URLs",
"regex": "^.*$",
"type": "text"
},
"BLACKLIST_RDNS_GLOBAL": {
"context": "multisite",
"default": "yes",
"help": "Only perform RDNS blacklist checks on global IP addresses.",
"id": "blacklist-rdns-global",
"label": "Blacklist reverse DNS global IPs",
"regex": "^.*$",
"type": "text"
},
"BLACKLIST_ASN": {
"context": "multisite",
"default": "",
"help": "List of ASN numbers, separated with spaces, to block.",
"id": "blacklist-asn",
"label": "Blacklist ASN",
"regex": "^.*$",
"type": "text"
},
"BLACKLIST_ASN_URLS": {
"context": "global",
"default": "",
"help": "List of URLs, separated with spaces, containing ASN to block.",
"id": "blacklist-rdns-urls",
"label": "Blacklist ASN URLs",
"regex": "^.*$",
"type": "text"
},
"BLACKLIST_USER_AGENT": {
"context": "multisite",
"default": "",
"help": "List of User-Agent, separated with spaces, to block.",
"id": "blacklist-user-agent",
"label": "Blacklist User-Agent",
"regex": "^.*$",
"type": "text"
},
"BLACKLIST_USER_AGENT_URLS": {
"context": "global",
"default": "https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/_generator_lists/bad-user-agents.list",
"help": "List of URLs, separated with spaces, containing bad User-Agent to block.",
"id": "blacklist-user-agent-urls",
"label": "Blacklist User-Agent URLs",
"regex": "^.*$",
"type": "text"
},
"BLACKLIST_URI": {
"context": "multisite",
"default": "",
"help": "List of URI, separated with spaces, to block.",
"id": "blacklist-uri",
"label": "Blacklist URI",
"regex": "^.*$",
"type": "text"
},
"BLACKLIST_URI_URLS": {
"context": "global",
"default": "",
"help": "List of URLs, separated with spaces, containing bad URI to block.",
"id": "blacklist-uri-urls",
"label": "Blacklist URI URLs",
"regex": "^.*$",
"type": "text"
}
},
"jobs": [
{
"name": "blacklist-download",
"file": "blacklist-download.py",
"every": "hour",
"reload": true
}
]
}

View File

@ -0,0 +1,6 @@
{% if USE_BROTLI == "yes" +%}
brotli on;
brotli_types {{ BROTLI_TYPES }};
brotli_comp_level {{ BROTLI_COMP_LEVEL }};
brotli_min_length {{ BROTLI_MIN_LENGTH }};
{% endif %}

58
core/brotli/plugin.json Normal file
View File

@ -0,0 +1,58 @@
{
"id": "brotli",
"order": 999,
"name": "Brotli",
"description": "Compress HTTP requests with the brotli algorithm.",
"version": "0.1",
"settings": {
"USE_BROTLI": {
"context": "multisite",
"default": "no",
"help": "Use brotli",
"id": "use-brotli",
"label": "Use brotli",
"regex": "^(yes|no)$",
"type": "check"
},
"BROTLI_TYPES": {
"context": "multisite",
"default": "application/atom+xml application/javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype application/x-font-ttf application/x-javascript application/xhtml+xml application/xml font/eot font/opentype font/otf font/truetype image/svg+xml image/vnd.microsoft.icon image/x-icon image/x-win-bitmap text/css text/javascript text/plain text/xml",
"help": "List of MIME types that will be compressed with brotli.",
"id": "brotli-types",
"label": "MIME types",
"regex": "^.*$",
"type": "text"
},
"BROTLI_MIN_LENGTH": {
"context": "multisite",
"default": "1000",
"help": "Minimum length for brotli compression.",
"id": "brotli-min-length",
"label": "Minimum length",
"regex": "^.*$",
"type": "text"
},
"BROTLI_COMP_LEVEL": {
"context": "multisite",
"default": "6",
"help": "The compression level of the brotli algorithm.",
"id": "brotli-comp-level",
"label": "Compression level",
"regex": "^([1-9]|10|11)$",
"type": "select",
"select": [
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11"
]
}
}
}

View File

@ -0,0 +1,222 @@
local _M = {}
_M.__index = _M
local utils = require "utils"
local datastore = require "datastore"
local logger = require "logger"
local cjson = require "cjson"
local http = require "resty.http"
function _M.new()
local self = setmetatable({}, _M)
local server, err = datastore:get("variable_BUNKERNET_SERVER")
if not server then
return nil, "can't get BUNKERNET_SERVER from datastore : " .. err
end
self.server = server
local id, err = datastore:get("plugin_bunkernet_id")
if not id then
self.id = nil
else
self.id = id
end
return self, nil
end
function _M:init()
local init_needed, err = utils.has_variable("USE_BUNKERNET", "yes")
if init_needed == nil then
return false, err
end
if not init_needed then
return true, "no service uses BunkerNet, skipping init"
end
-- Check if instance ID is present
local f, err = io.open("/opt/bunkerweb/cache/bunkernet/instance.id", "r")
if not f then
return false, "can't read instance id : " .. err
end
-- Retrieve instance ID
id = f:read("*all"):gsub("[\r\n]", "")
f:close()
self.id = id
-- TODO : regex check just in case
-- Send a ping with the ID
--local ok, err, status, response = self:ping()
-- BunkerNet server is down or instance can't access it
--if not ok then
--return false, "can't send request to BunkerNet service : " .. err
-- Local instance ID is unknown to the server, let's delete it
--elseif status == 401 then
--local ok, message = os.remove("/opt/bunkerweb/cache/bunkernet/instance.id")
--if not ok then
--return false, "can't remove instance ID " .. message
--end
--return false, "instance ID is not valid"
--elseif status == 429 then
--return false, "sent too many requests to the BunkerNet service"
--elseif status ~= 200 then
--return false, "unknown error from BunkerNet service (HTTP status = " .. tostring(status) .. ")"
--end
-- Store ID in datastore
local ok, err = datastore:set("plugin_bunkernet_id", id)
if not ok then
return false, "can't save instance ID to the datastore : " .. err
end
-- Load databases
local ret = true
local i = 0
local db = {
ip = {}
}
f, err = io.open("/opt/bunkerweb/cache/bunkernet/ip.list", "r")
if not f then
ret = false
else
for line in f:lines() do
if utils.is_ipv4(line) and utils.ip_is_global(line) then
table.insert(db.ip, line)
i = i + 1
end
end
end
if not ret then
return false, "error while reading database : " .. err
end
f:close()
local ok, err = datastore:set("plugin_bunkernet_db", cjson.encode(db))
if not ok then
return false, "can't store BunkerNet database into datastore : " .. err
end
return true, "successfully connected to the BunkerNet service " .. self.server .. " with machine ID " .. id .. " and " .. tostring(i) .. " bad IPs in database"
end
function _M:request(method, url, data)
local httpc, err = http.new()
if not httpc then
return false, "can't instantiate http object : " .. err, nil, nil
end
local all_data = {
id = self.id,
integration = utils.get_integration(),
version = utils.get_version()
}
for k, v in pairs(data) do
all_data[k] = v
end
local res, err = httpc:request_uri(self.server .. url, {
method = method,
body = cjson.encode(all_data),
headers = {
["Content-Type"] = "application/json",
["User-Agent"] = "BunkerWeb/" .. utils.get_version()
}
})
httpc:close()
if not res then
return false, "error while sending request : " .. err, nil, nil
end
if res.status ~= 200 then
return false, "status code != 200", res.status, nil
end
local ok, ret = pcall(cjson.decode, res.body)
if not ok then
return false, "error while decoding json : " .. ret, nil, nil
end
return true, "success", res.status, ret
end
function _M:ping()
return self:request("GET", "/ping", {})
end
function _M:report(ip, reason, method, url, headers)
local data = {
ip = ip,
reason = reason,
method = method,
url = url,
headers = headers
}
return self:request("POST", "/report", data)
end
function _M:log()
-- Check if BunkerNet is activated
local use_bunkernet = utils.get_variable("USE_BUNKERNET")
if use_bunkernet ~= "yes" then
return true, "bunkernet not activated"
end
-- Check if BunkerNet ID is generated
if not self.id then
return true, "bunkernet ID is not generated"
end
-- Check if IP has been blocked
local reason = utils.get_reason()
if not reason then
return true, "ip is not blocked"
end
if reason == "bunkernet" then
return true, "skipping report because the reason is bunkernet"
end
-- Check if IP is global
local is_global, err = utils.ip_is_global(ngx.var.remote_addr)
if is_global == nil then
return false, "error while checking if IP is global " .. err
end
if not is_global then
return true, "IP is not global"
end
-- Only report if it hasn't been reported for the same reason recently
--local reported = datastore:get("plugin_bunkernet_cache_" .. ngx.var.remote_addr .. reason)
--if reported then
--return true, "ip already reported recently"
--end
local function report_callback(premature, obj, ip, reason, method, url, headers)
local ok, err, status, data = obj:report(ip, reason, method, url, headers)
if status == 429 then
logger.log(ngx.WARN, "BUNKERNET", "BunkerNet API is rate limiting us")
elseif not ok then
logger.log(ngx.ERR, "BUNKERNET", "Can't report IP : " .. err)
else
logger.log(ngx.NOTICE, "BUNKERNET", "Successfully reported IP " .. ip .. " (reason : " .. reason .. ")")
--local ok, err = datastore:set("plugin_bunkernet_cache_" .. ip .. reason, true, 3600)
--if not ok then
--logger.log(ngx.ERR, "BUNKERNET", "Can't store cached report : " .. err)
--end
end
end
local hdr, err = ngx.timer.at(0, report_callback, self, ngx.var.remote_addr, reason, ngx.var.request_method, ngx.var.request_uri, ngx.req.get_headers())
if not hdr then
return false, "can't create report timer : " .. err
end
return true, "created report timer"
end
function _M:access()
local use_bunkernet = utils.get_variable("USE_BUNKERNET")
if use_bunkernet ~= "yes" then
return true, "bunkernet not activated", false, nil
end
-- Check if BunkerNet ID is generated
if not self.id then
return true, "bunkernet ID is not generated"
end
local data, err = datastore:get("plugin_bunkernet_db")
if not data then
return false, "can't get bunkernet db : " .. err, false, nil
end
local db = cjson.decode(data)
for index, value in ipairs(db.ip) do
if value == ngx.var.remote_addr then
return true, "ip is in database", true, ngx.exit(ngx.HTTP_FORBIDDEN)
end
end
return true, "ip is not in database", false, nil
end
function _M:api()
return false, nil, nil
end
return _M

View File

@ -0,0 +1,59 @@
log_by_lua_block {
local bunkernet = require "bunkernet.bunkernet"
local utils = require "utils"
local datastore = require "datastore"
local logger = require "logger"
local disable_default_server = utils.get_variable("DISABLE_DEFAULT_SERVER", false)
local use_bunkernet = utils.has_variable("USE_BUNKERNET", "yes")
if disable_default_server == "yes" and use_bunkernet then
-- Instantiate bunkernet
local bnet, err = bunkernet.new()
if not bnet then
ngx.log(ngx.ERR, "BUNKERNET", "can't instantiate bunkernet " .. err)
return
end
-- Check if BunkerNet ID is generated
if not bnet.id then
return
end
-- Check if IP has been blocked
if ngx.status ~= ngx.HTTP_CLOSE then
return
end
-- Check if IP is global
local is_global, err = utils.ip_is_global(ngx.var.remote_addr)
if is_global == nil then
return
end
if not is_global then
return
end
-- Only report if it hasn't been reported for the same reason recently
local reported = datastore:get("plugin_bunkernet_cache_" .. ngx.var.remote_addr .. "default")
if reported then
return
end
-- report callback called in a light thread
local function report_callback(premature, obj, ip, reason, method, url, headers)
local ok, err, status, data = obj:report(ip, reason, method, url, headers)
if not ok then
logger.log(ngx.ERR, "BUNKERNET", "Can't report IP : " .. err)
elseif status ~= 200 then
logger.log(ngx.ERR, "BUNKERNET", "Error from remote server : " .. tostring(status))
else
logger.log(ngx.NOTICE, "BUNKERNET", "Successfully reported IP " .. ip .. " (reason : " .. reason .. ")")
local ok, err = datastore:set("plugin_bunkernet_cache_" .. ip .. reason, true, 3600)
if not ok then
logger.log(ngx.ERR, "BUNKERNET", "Can't store cached report : " .. err)
end
end
end
-- Set a timer at the end of log()
local hdr, err = ngx.timer.at(0, report_callback, bnet, ngx.var.remote_addr, "default", ngx.var.request_method, ngx.var.request_uri, ngx.req.get_headers())
if not hdr then
logger.log(ngx.ERR, "BUNKERNET", "can't create report timer : " .. err)
end
return
end
}

Some files were not shown because too many files have changed in this diff Show More