本文由 GitRead 中文社区 使用 AI 辅助生成,基于项目 README 与公开资料整理成中文解读, 并结合中文开发者的常见使用场景补充技术选型参考。内容可能存在疏漏,具体以项目官方文档为准。
深度剖析 bunkerity/bunkerweb:一款高性能的开源 Web 应用防火墙
项目背景与痛点
在如今这个安全性日益重要的时代,Web 应用防火墙(WAF)成为了保护 API 和 Web 应用的一种重要工具。bunkerity/bunkerweb 项目提供了一个可靠且高性能的解决方案,旨在帮助开发者和企业更好地保护他们的应用程序免受常见的 Web 攻击。通过使用这一开源且面向云原生的设计,团队可以快速集成并享受到高可扩展性和强大的保护机制。
核心技术揭秘
bunkerity/bunkerweb 使用 Nginx 作为基础 Web 服务器,结合多种防护模块实现全方位的安全保护。其高性能和高可靠性来自于纯 C 语言实现的 Nginx,并通过 Lua 脚本进行功能扩展。
BunkerWeb is a next-generation, open-source Web Application Firewall (WAF).
Being a full-featured web server (based on NGINX under the hood), it will protect your web services to make them “secure by default.” BunkerWeb integrates seamlessly into your existing environments (Linux, Docker, Swarm, Kubernetes, …) as a reverse proxy and is fully configurable (don’t panic, there is an awesome web UI if you don’t like the CLI) to meet your own use cases. In other words, cybersecurity is no longer a hassle.
BunkerWeb contains primary security features as part of the core but can be easily extended with additional ones thanks to a plugin system.
Seamlessly integrate BunkerWeb into various environments such as Linux, Docker, Swarm, Kubernetes, and more. Enjoy a smooth transition and hassle-free implementation.
Highly customizable
Tailor BunkerWeb to your specific requirements with ease. Enable, disable, and configure features effortlessly, allowing you to customize the security settings according to your unique use case.
Secure by default
BunkerWeb provides out-of-the-box, hassle-free minimal security for your web services. Experience peace of mind and enhanced protection right from the start.
Awesome web UI
Take control of BunkerWeb more efficiently with the exceptional web user interface (UI). Navigate settings and configurations effortlessly through a user-friendly graphical interface, eliminating the need for the command-line interface (CLI).
Plugin system
Extend the capabilities of BunkerWeb to meet your own use cases. Seamlessly integrate additional security measures and customize the functionality of BunkerWeb according to your specific requirements.
Free as in “freedom”
BunkerWeb is licensed under the free AGPLv3 license, embracing the principles of freedom and openness. Enjoy the freedom to use, modify, and distribute the software, backed by a supportive community.
Professional services
Get technical support, tailored consulting, and custom development directly from the maintainers of BunkerWeb. Visit the Bunker Panel for more information.
Security features
A non-exhaustive list of security features:
HTTPS support with transparent Let’s Encrypt automation
BunkerWeb offers an optional user interface to manage your instances and their configurations. An online read-only demo is available at demo-ui.bunkerweb.io, feel free to test it yourself.
BunkerWeb Cloud
Don’t want to self-host and manage your own BunkerWeb instance(s)? You might be interested in BunkerWeb Cloud, our fully managed SaaS offering for BunkerWeb.
A fully managed BunkerWeb instance hosted in our cloud
All BunkerWeb features, including PRO ones
A monitoring platform with dashboards and alerts
Technical support to assist you with configuration
If you are interested in the BunkerWeb Cloud offering, don’t hesitate to contact us so we can discuss your needs.
PRO version
Tip 提示
Start a 30-day BunkerWeb PRO free trial from the BunkerWeb panel: order a plan, then keep Free 30 Days Trial as the payment method at checkout (step-by-step guide).
When using BunkerWeb, you have the choice of the version you want to use: open-source or PRO.
Whether it’s enhanced security, an enriched user experience, or technical monitoring, the BunkerWeb PRO version allows you to fully benefit from BunkerWeb and meet your professional needs.
In the documentation or the user interface, PRO features are annotated with a crown to distinguish them from those integrated into the open-source version.
You can upgrade from the open-source version to the PRO one easily and at any time. To start your 30-day free trial:
Open the BunkerWeb Panel store and click Order Now on the STANDARD or ENTERPRISE plan.
Keep the Monthly billing cycle, choose the Number of services, then click Continue. The configuration summary still shows the full price: the trial is applied at checkout.
On the Review & Checkout page, under Payment Method, keep Free 30 Days Trial selected. Total Due Today then shows 0.00 €.
Create your account (or log in), accept the Terms of Service and click Place Order.
Once connected to the client area, copy your PRO license key.
Do not hesitate to visit the BunkerWeb panel or contact us if you have any questions regarding the PRO version.
Professional services
Get the most out of BunkerWeb by getting professional services directly from the maintainers of the project. From technical support to tailored consulting and development, we are here to assist you in the security of your web services.
You will find more information by visiting the BunkerWeb Panel, our dedicated platform for professional services.
Don’t hesitate to contact us if you have any questions; we will be more than happy to respond to your needs.
You will find more information about the key concepts of BunkerWeb in the documentation.
Integrations: BunkerWeb in the target environment
The first concept is the integration of BunkerWeb into the target environment. We prefer to use the word “integration” instead of “installation” because one of the goals of BunkerWeb is to integrate seamlessly into existing environments.
The following integrations are officially supported:
Once BunkerWeb is integrated into your environment, you will need to configure it to serve and protect your web applications.
The configuration of BunkerWeb is done by using what we call the “settings” or “variables.” Each setting is identified by a name such as AUTO_LETS_ENCRYPT or USE_ANTIBOT. You can assign values to the settings to configure BunkerWeb.
Here is a dummy example of a BunkerWeb configuration:
The multisite mode is a crucial concept to understand when using BunkerWeb. Because the goal is to protect web applications, we intrinsically inherit the concept of “virtual host” or “vhost” (more info here) which makes it possible to serve multiple web applications from a single (or a cluster of) instance.
By default, the multisite mode of BunkerWeb is disabled, which means that only one web application will be served and all the settings will be applied to it. The typical use case is when you have a single application to protect: you don’t have to worry about the multisite, and the default behavior should be the right one for you.
When multisite mode is enabled, BunkerWeb will serve and protect multiple web applications. Each web application is identified by a unique server name and has its own set of settings. The typical use case is when you have multiple applications to protect and you want to use a single (or a cluster depending on the integration) instance of BunkerWeb.
Custom configurations: NGINX and ModSecurity
Because meeting all the use cases only using the settings is not an option (even with external plugins), you can use custom configurations to solve your specific challenges.
Under the hood, BunkerWeb uses the notorious NGINX web server, that’s why you can leverage its configuration system for your specific needs. Custom NGINX configurations can be included in different contexts like HTTP or server (all servers and/or specific server block).
Another core component of BunkerWeb is the ModSecurity Web Application Firewall: you can also use custom configurations to fix some false positives or add custom rules, for example.
Database: where the configuration state lives
The state of the current configuration of BunkerWeb is stored in a backend database which contains the following data:
Settings defined for all the services
Custom configurations
BunkerWeb instances
Metadata about job execution
Cached files
The following backend databases are supported: SQLite, MariaDB, MySQL, and PostgreSQL.
Scheduler: the brain of BunkerWeb
To make things automagically work together, a dedicated service called the scheduler is in charge of:
Storing the settings and custom configurations inside the database
Executing various tasks (called jobs)
Generating a configuration which is understood by BunkerWeb
Being the intermediary for other services (like web UI or autoconf)
In other words, the scheduler is the brain of BunkerWeb.
Setup
Tip 提示
Building container images or Linux packages from source? See the community build guide.
Linux
Docker
Docker autoconf
Kubernetes
Swarm
Microsoft Azure
Linux
List of supported Linux distros:
Debian 12 “Bookworm”
Debian 13 “Trixie”
Ubuntu 22.04 “Jammy”
Ubuntu 24.04 “Noble”
Ubuntu 26.04 “Resolute Raccoon”
Fedora 43
Fedora 44
RHEL, CentOS, Rocky Linux and AlmaLinux 8, 9 and 10
You will find more information in the Linux section of the documentation.
Docker
We provide ready-to-use prebuilt images for x64, x86, armv7, and arm64 platforms on Docker Hub.
Docker integration key concepts are:
Environment variables to configure BunkerWeb
Scheduler container to store configuration and execute jobs
Networks to expose ports for clients and connect to upstream web services
The downside of using environment variables is that the container needs to be recreated each time there is an update, which is not very convenient. To counter that issue, you can use another image called autoconf which will listen for Docker events and automatically reconfigure BunkerWeb in real-time without recreating the container.
Instead of defining environment variables for the BunkerWeb container, you simply add labels to your web applications containers and the autoconf will “automagically” take care of the rest.
The autoconf acts as an Ingress controller and will configure the BunkerWeb instances according to the Ingress resources. It also monitors other Kubernetes objects like ConfigMap for custom configurations.
To automatically configure BunkerWeb instances, a special service, called autoconf will listen for Docker Swarm events like service creation or deletion and automatically configure the BunkerWeb instances in real-time without downtime.
Like the Docker autoconf integration, configuration for web services is defined using labels starting with the special bunkerweb. prefix.
You will find more information in the Swarm section of the documentation.
Quickstart guide
Once you have set up BunkerWeb with the integration of your choice, you can follow the quickstart guide that will cover the installation and first configuration to protect a web service.
Security tuning
BunkerWeb offers many security features that you can configure with features. Even if the default values of settings ensure a minimal “security by default,” we strongly recommend you to tune them. By doing so, you will be able to ensure a security level of your choice but also manage false positives.
As a general rule, when multisite mode is enabled, if you want to apply settings with multisite context to a specific server, you will need to add the primary (first) server name as a prefix like www.example.com_USE_ANTIBOT=captcha or myapp.example.com_USE_GZIP=yes, for example.
When settings are considered as “multiple,” it means that you can have multiple groups of settings for the same feature by adding numbers as suffixes like REVERSE_PROXY_URL_1=/subdir, REVERSE_PROXY_HOST_1=http://myhost1, REVERSE_PROXY_URL_2=/anotherdir, REVERSE_PROXY_HOST_2=http://myhost2, … for example.
Check the features section of the documentation to get the full list.
The “Web UI” is a web application that helps you manage your BunkerWeb instance using a user-friendly interface instead of the command-line one.
Here is the list of features offered by the web UI:
Get a comprehensive view of the blocked attacks
Start, stop, restart, and reload your BunkerWeb instance
Add, edit, and delete settings for your web applications
Add, edit, and delete custom configurations for NGINX and ModSecurity
Install and uninstall external plugins
Explore the cached files
Monitor job execution and restart them when needed
View the logs and search patterns
You will find more information in the Web UI section of the documentation.
Plugins
BunkerWeb comes with a plugin system to make it possible to easily add new features. Once a plugin is installed, you can manage it using additional settings defined by the plugin.
Here is the list of “official” plugins that we maintain (see the bunkerweb-plugins repository for more information):
Name
Version
Description
Link
ClamAV
1.9
Automatically scans uploaded files with the ClamAV antivirus engine and denies the request when a file is detected as malicious.
Get technical support directly from the BunkerWeb maintainers. You will find more information by visiting the BunkerWeb Panel, our dedicated platform for professional services.
Don’t hesitate to contact us if you have any questions; we will be more than happy to respond to your needs.
Community
To get free community support, you can use the following media:
评论