bunkerized-nginx/README.md

289 lines
17 KiB
Markdown
Raw Normal View History

<p align="center">
2022-06-03 17:24:14 +02:00
<img alt="BunkerWeb logo" src="https://github.com/bunkerity/bunkerweb/raw/master/logo.png" />
2021-03-18 18:08:42 +01:00
</p>
<p align="center">
2022-06-27 17:32:15 +02:00
<img src="https://img.shields.io/badge/bunkerweb-1.4.2-blue" />
2022-06-03 17:24:14 +02:00
<img src="https://img.shields.io/github/last-commit/bunkerity/bunkerweb" />
<img src="https://img.shields.io/github/workflow/status/bunkerity/bunkerweb/Automatic%20test%2C%20build%2C%20push%20and%20deploy%20%28DEV%29?label=CI%2FCD%20dev" />
<img src="https://img.shields.io/github/workflow/status/bunkerity/bunkerweb/Automatic%20test%2C%20build%2C%20push%20and%20deploy%20%28PROD%29?label=CI%2FCD%20prod" />
<img src="https://img.shields.io/github/issues/bunkerity/bunkerweb">
<img src="https://img.shields.io/github/issues-pr/bunkerity/bunkerweb">
2021-04-27 17:40:33 +02:00
</p>
<p align="center">
2022-06-03 17:24:14 +02:00
📓 <a href="https://docs.bunkerweb.io">Documentation</a>
&#124;
👨‍💻 <a href="https://demo.bunkerweb.io">Demo</a>
&#124;
🛡️ <a href="https://github.com/bunkerity/bunkerweb/tree/master/examples">Examples</a>
&#124;
💬 <a href="https://discord.com/invite/fTf46FmtyD">Chat</a>
&#124;
📝 <a href="https://github.com/bunkerity/bunkerweb/discussions">Forum</a>
&#124;
⚙️ <a href="https://config.bunkerweb.io">Configurator</a>
2021-03-18 18:08:42 +01:00
</p>
2020-10-10 16:46:23 +02:00
2021-08-06 11:55:24 +02:00
> Make security by default great again !
2020-10-10 16:46:23 +02:00
2022-06-03 17:24:14 +02:00
# Bunkerweb
2021-08-06 16:51:46 +02:00
2022-06-03 17:24:14 +02:00
<p align="center">
<img alt="overview" src="https://github.com/bunkerity/bunkerweb/raw/master/docs/assets/img/intro-overview.svg" />
</p>
2021-08-06 16:51:46 +02:00
2022-06-03 17:24:14 +02:00
BunkerWeb is a web server based on the notorious [NGINX](https://nginx.org/) and focused on security.
It integrates into existing environments ([Linux](#linux), [Docker](#docker), [Swarm](#swarm), [Kubernetes](#Kubernetes), …) to make your web services "secure by default" without any hassle. The security best practices are automatically applied for you while keeping control of every setting to meet your use case.
BunkerWeb contains primary [security features](#security-tuning) as part of the core but can be easily extended with additional ones thanks to a [plugin system](#plugins).
## Why BunkerWeb ?
- **Easy integration into existing environments** : support for Linux, Docker, Swarm and Kubernetes
- **Highly customizable** : enable, disable and configure features easily to meet your use case
- **Secure by default** : offers out-of-the-box and hassle-free minimal security for your web services
- **Free as in "freedom"** : licensed under the free [AGPLv3 license](https://www.gnu.org/licenses/agpl-3.0.en.html)
## Security features
A non-exhaustive list of security features :
- **HTTPS** support with transparent **Let's Encrypt** automation
- **State-of-the-art web security** : HTTP security headers, prevent leaks, TLS hardening, ...
- Integrated **ModSecurity WAF** with the **OWASP Core Rule Set**
- **Automatic ban** of strange behaviors based on HTTP status code
- Apply **connections and requests limit** for clients
- **Block bots** by asking them to solve a **challenge** (e.g. : cookie, javascript, captcha, hCaptcha or reCAPTCHA)
- **Block known bad IPs** with external blacklists and DNSBL
- And much more ...
Learn more about the core security features in the [security tuning](https://docs.bunkerweb.io/latest/security-tuning) section of the documentation.
2022-06-03 17:24:14 +02:00
## Demo
<p align="center">
<img alt="Demo GIF" src="https://github.com/bunkerity/bunkerweb/raw/master/docs/assets/img/demo.gif" />
</p>
A demo website protected with BunkerWeb is available at [demo.bunkerweb.io](https://demo.bunkerweb.io). Feel free to visit it and perform some security tests.
# Concepts
<p align="center">
<img alt="BunkerWeb logo" src="https://github.com/bunkerity/bunkerweb/raw/master/docs/assets/img/concepts.svg" />
</p>
2021-08-06 16:51:46 +02:00
You will find more information about the key concepts of BunkerWeb in the [documentation](https://docs.bunkerweb.io/latest/concepts).
2022-06-03 17:24:14 +02:00
## Integrations
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 :
- [Docker](https://docs.bunkerweb.io/latest/integrations/#docker)
- [Docker autoconf](https://docs.bunkerweb.io/latest/integrations/#docker-autoconf)
- [Swarm](https://docs.bunkerweb.io/latest/integrations/#swarm)
- [Kubernetes](https://docs.bunkerweb.io/latest/integrations/#kubernetes)
- [Linux](https://docs.bunkerweb.io/latest/integrations/#linux)
2022-06-03 17:24:14 +02:00
## Settings
Once BunkerWeb is integrated into your environment, you will need to configure it to serve and protect your web applications.
Configuration of BunkerWeb is done using what we called the "settings" or "variables". Each setting is identified by a name like `AUTO_LETS_ENCRYPT` or `USE_ANTIBOT` for example. You can assign values to the settings to configure BunkerWeb.
Here is a dummy example of a BunkerWeb configuration :
```conf
SERVER_NAME=www.example.com
AUTO_LETS_ENCRYPT=yes
USE_ANTIBOT=captcha
REFERRER_POLICY=no-referrer
USE_MODSECURITY=no
USE_GZIP=yes
USE_BROTLI=no
2021-08-06 16:51:46 +02:00
```
2022-06-03 17:24:14 +02:00
You will find an easy to use settings generator at [config.bunkerweb.io](https://config.bunkerweb.io).
## Multisite mode
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](https://en.wikipedia.org/wiki/Virtual_hosting)) 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 have 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 of the integration) instance of BunkerWeb.
## Custom configurations
Because meeting all the use cases only using the settings is not an option (even with [external plugins](https://docs.bunkerweb.io/latest/plugins)), you can use custom configurations to solve your specific challenges.
2022-06-03 17:24:14 +02:00
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](https://docs.nginx.com/nginx/admin-guide/basic-functionality/managing-configuration-files/#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.
# Setup
2021-08-06 16:51:46 +02:00
2022-06-03 17:24:14 +02:00
## Docker
<p align="center">
<img alt="Docker" src="https://github.com/bunkerity/bunkerweb/raw/master/docs/assets/img/integration-docker.svg" />
</p>
We provide ready to use prebuilt images for x64, x86, armv7 and arm64 platforms on [Docker Hub](https://hub.docker.com/r/bunkerity/bunkerweb) using the `bunkerity/bunkerweb` tag.
Usage and configuration of the BunkerWeb container are based on :
2022-06-03 17:24:14 +02:00
- **Environment variables** to configure BunkerWeb and meet your use cases
- **Volume** to cache important data and mount custom configuration files
- **Networks** to expose ports for clients and connect to upstream web services
You will find more information in the [Docker integration section](https://docs.bunkerweb.io/latest/integrations/#docker) of the documentation.
2021-08-11 16:26:35 +02:00
## Docker autoconf
2022-06-03 17:24:14 +02:00
<p align="center">
<img alt="Docker autoconf" src="https://github.com/bunkerity/bunkerweb/raw/master/docs/assets/img/integration-autoconf.svg" />
</p>
2021-08-06 16:51:46 +02:00
2022-06-03 17:24:14 +02:00
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.
2021-08-06 16:51:46 +02:00
2022-06-03 17:24:14 +02:00
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.
You will find more information in the [Docker autoconf section](https://docs.bunkerweb.io/latest/integrations/#docker-autoconf) of the documentation.
2021-08-06 16:51:46 +02:00
## Swarm
2022-06-03 17:24:14 +02:00
<p align="center">
<img alt="Swarm" src="https://github.com/bunkerity/bunkerweb/raw/master/docs/assets/img/integration-swarm.svg" />
</p>
2021-08-06 16:51:46 +02:00
2022-06-03 17:24:14 +02:00
To automatically configure BunkerWeb instances, a special service, called **autoconf**, will be scheduled on a manager node. That service will listen for Docker Swarm events like service creation or deletion and automatically configure the **BunkerWeb instances** in real-time without downtime.
2021-08-06 16:51:46 +02:00
2022-06-03 17:24:14 +02:00
Like the [Docker autoconf integration](#docker-autoconf), configuration for web services is defined using labels starting with the special **bunkerweb.** prefix.
2021-08-06 16:51:46 +02:00
2022-06-03 17:24:14 +02:00
The recommended setup is to schedule the **BunkerWeb service** as a **global service** on all worker nodes and the **autoconf service** as a **single replicated service** on a manager node.
2021-08-06 16:51:46 +02:00
You will find more information in the [Swarm section](https://docs.bunkerweb.io/latest/integrations/#swarm) of the documentation.
2022-06-03 17:24:14 +02:00
## Kubernetes
<p align="center">
<img alt="Kubernetes" src="https://github.com/bunkerity/bunkerweb/raw/master/docs/assets/img/integration-kubernetes.svg" />
</p>
2022-06-03 17:24:14 +02:00
The autoconf acts as an [Ingress controller](https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/) and will configure the BunkerWeb instances according to the [Ingress resources](https://kubernetes.io/docs/concepts/services-networking/ingress/). It also monitors other Kubernetes objects like [ConfigMap](https://kubernetes.io/docs/concepts/configuration/configmap/) for custom configurations.
2021-08-06 16:51:46 +02:00
You will find more information in the [Kubernetes section](https://docs.bunkerweb.io/latest/integrations/#kubernetes) of the documentation.
2021-08-06 16:51:46 +02:00
## Linux
2022-06-03 17:24:14 +02:00
<p align="center">
<img alt="Linux" src="https://github.com/bunkerity/bunkerweb/raw/master/docs/assets/img/integration-linux.svg" />
</p>
2022-06-03 17:24:14 +02:00
List of supported Linux distros :
2022-06-03 17:24:14 +02:00
- Debian 11 "Bullseye"
- Ubuntu 22.04 "Jammy"
- Fedora 36
- CentOS Stream 8
2021-08-06 16:51:46 +02:00
2022-06-03 17:24:14 +02:00
Repositories of Linux packages for BunkerWeb are available on [PackageCloud](https://packagecloud.io/bunkerity/bunkerweb), they provide a bash script to automatically add and trust the repository (but you can also follow the [manual installation](https://packagecloud.io/bunkerity/bunkerweb/install) instructions if you prefer).
2021-08-06 16:51:46 +02:00
You will find more information in the [Linux section](https://docs.bunkerweb.io/latest/integrations/#linux) of the documentation.
2021-08-06 16:51:46 +02:00
2022-06-03 17:24:14 +02:00
# Quickstart guide
2021-08-06 16:51:46 +02:00
Once you have setup BunkerWeb with the integration of your choice, you can follow the [quickstart guide](https://docs.bunkerweb.io/latest/quickstart-guide/) that will cover the following common use cases :
2022-06-03 17:24:14 +02:00
- Protecting a single HTTP application
- Protecting multiple HTTP application
- Retrieving the real IP of clients when operating behind a load balancer
- Adding custom configurations
2021-08-06 16:51:46 +02:00
2022-06-03 17:24:14 +02:00
# Security tuning
2021-08-06 16:51:46 +02:00
2022-06-03 17:24:14 +02:00
BunkerWeb offers many security features that you can configure with [settings](/settings). 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.
2021-08-06 16:51:46 +02:00
You will find more information in the [security tuning section](https://docs.bunkerweb.io/latest/security-tuning) of the documentation.
2022-06-03 17:24:14 +02:00
# Settings
2022-06-03 17:24:14 +02:00
To help you tuning BunkerWeb we have made an easy to use settings generator tool available at [config.bunkerweb.io](https://config.bunkerweb.io).
2021-08-06 16:51:46 +02:00
2022-06-03 17:24:14 +02:00
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.
2021-08-06 16:51:46 +02:00
2022-06-03 17:24:14 +02:00
When settings are considered as "multiple", it means that you can have multiple groups of settings for the same feature by adding numbers as suffix 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.
2021-08-06 16:51:46 +02:00
Check the [settings section](https://docs.bunkerweb.io/latest/settings) of the documentation to get the full list.
2021-08-06 16:51:46 +02:00
# Web UI
2022-06-03 17:24:14 +02:00
<p align="center">
<img alt="Linux" src="https://github.com/bunkerity/bunkerweb/raw/master/docs/assets/img/demo_bunkerweb_ui.gif" />
</p>
2022-06-03 17:24:14 +02:00
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.
2021-08-06 16:51:46 +02:00
2022-06-03 17:24:14 +02:00
- 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
- View the logs and search pattern
You will find more information in the [Web UI section](https://docs.bunkerweb.io/latest/web-ui) of the documentation.
2022-06-03 17:24:14 +02:00
# 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](https://github.com/bunkerity/bunkerweb-plugins) repository for more information) :
| Name | Version | Description | Link |
| :------------: | :-----: | :------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------: |
| **ClamAV** | 0.1 | Automatically scans uploaded files with the ClamAV antivirus engine and denies the request when a file is detected as malicious. | [bunkerweb-plugins/clamav](https://github.com/bunkerity/bunkerweb-plugins/tree/main/clamav) |
| **CrowdSec** | 0.1 | CrowdSec bouncer for BunkerWeb. | [bunkerweb-plugins/crowdsec](https://github.com/bunkerity/bunkerweb-plugins/tree/main/crowdsec) |
| **Discord** | 0.1 | Send security notifications to a Discord channel using a Webhook. | [bunkerweb-plugins/discord](https://github.com/bunkerity/bunkerweb-plugins/tree/main/discord) |
| **Slack** | 0.1 | Send security notifications to a Slack channel using a Webhook. | [bunkerweb-plugins/slack](https://github.com/bunkerity/bunkerweb-plugins/tree/main/slack) |
2022-06-03 17:24:14 +02:00
| **VirusTotal** | 0.1 | Automatically scans uploaded files with the VirusTotal API and denies the request when a file is detected as malicious. | [bunkerweb-plugins/virustotal](https://github.com/bunkerity/bunkerweb-plugins/tree/main/virustotal) |
You will find more information in the [plugins section](https://docs.bunkerweb.io/latest/plugins) of the documentation.
2022-06-03 17:24:14 +02:00
# Support
## Professional
We offer professional services related to BunkerWeb like :
* Consulting
* Support
* Custom development
* Partnership
Please contact us at [contact@bunkerity.com](mailto:contact@bunkerity.com) if you are interested.
## Community
2021-08-06 16:51:46 +02:00
2022-06-03 17:24:14 +02:00
To get free community support you can use the following medias :
2021-08-06 16:51:46 +02:00
2022-06-03 17:24:14 +02:00
* The #help channel of BunkerWeb in the [Discord server](https://discord.com/invite/fTf46FmtyD)
* The help category of [GitHub dicussions](https://github.com/bunkerity/bunkerweb/discussions)
* The [/r/BunkerWeb](https://www.reddit.com/r/BunkerWeb) subreddit
* The [Server Fault](https://serverfault.com/) and [Super User](https://superuser.com/) forums
2021-08-06 16:51:46 +02:00
2022-06-03 17:24:14 +02:00
Please don't use [GitHub issues](https://github.com/bunkerity/bunkerweb/issues) to ask for help, use it only for bug reports and feature requests.
2021-08-06 16:51:46 +02:00
# License
2022-06-03 17:24:14 +02:00
This project is licensed under the terms of the [GNU Affero General Public License (AGPL) version 3](https://github.com/bunkerity/bunkerweb/tree/master/LICENSE.md).
2021-08-06 16:51:46 +02:00
2022-06-03 17:24:14 +02:00
# Contribute
2021-08-06 16:51:46 +02:00
If you would like to contribute to the plugins you can read the [contributing guidelines](https://github.com/bunkerity/bunkerweb/tree/master/CONTRIBUTING.md) to get started.
2021-08-06 16:51:46 +02:00
# Security policy
2022-06-03 17:24:14 +02:00
We take security bugs as serious issues and encourage responsible disclosure, see our [security policy](https://github.com/bunkerity/bunkerweb/tree/master/SECURITY.md) for more information.