Compare commits

..

21 commits
main ... v0.1.0

Author SHA1 Message Date
aa12d23858 update CI
Some checks failed
Build and Publish Debian Package / build (push) Failing after 33s
2025-03-15 03:03:57 +01:00
ac5e859977 release 2025-03-15 03:01:53 +01:00
0a7a3f70eb rename package
All checks were successful
Build and Publish Debian Package / build (push) Successful in 39s
2025-03-15 02:54:49 +01:00
063ea9b64b Aggiorna .forgejo/workflows/build.yml
All checks were successful
Build and Publish Debian Package / build (push) Successful in 39s
2025-03-15 02:50:36 +01:00
409ad256f0 Aggiorna .forgejo/workflows/build.yml
Some checks failed
Build and Publish Debian Package / build (push) Failing after 37s
2025-03-15 02:48:59 +01:00
2ad4a88382 Aggiorna .forgejo/workflows/build.yml
Some checks failed
Build and Publish Debian Package / build (push) Failing after 34s
2025-03-15 02:47:50 +01:00
dd5ee5c832 Aggiorna .forgejo/workflows/build.yml
All checks were successful
Build and Publish Debian Package / build (push) Successful in 39s
2025-03-15 02:37:29 +01:00
a5db9d457d Aggiorna .forgejo/workflows/build.yml
Some checks failed
Build and Publish Debian Package / build (push) Has been cancelled
2025-03-15 02:36:00 +01:00
b7aaf2253b Aggiorna .forgejo/workflows/build.yml
Some checks failed
Build and Publish Debian Package / build (push) Failing after 1m26s
2025-03-15 02:31:09 +01:00
d55391bf15 Trigger CI 2025-03-15 02:30:31 +01:00
5524987beb test 2025-03-15 02:12:34 +01:00
bf1e27cad3 test 2025-03-15 02:11:33 +01:00
f1a0ef62d2 Trigger CI 2025-03-15 02:10:49 +01:00
bcb21618a2 Aggiorna README.md 2025-03-15 02:06:46 +01:00
0951031c35 Aggiorna .forgejo/workflows/build-debian-package.yml 2025-03-15 02:06:08 +01:00
4d52e80b0f Aggiorna .forgejo/workflows/build-debian-package.yml 2025-03-15 02:03:42 +01:00
d95c49a1c4 Aggiorna .forgejo/workflows/build-debian-package.yml 2025-03-15 02:02:38 +01:00
25af0cff8b Aggiorna .forgejo/workflows/build-debian-package.yml 2025-03-15 02:01:50 +01:00
d6890b19e3 back to ubuntu
Some checks failed
Build and Deploy Debian Package / build-package (push) Failing after 21s
2025-01-28 19:15:24 +01:00
d72596fe04 replace image
Some checks failed
Build and Deploy Debian Package / build-package (push) Failing after 16s
2025-01-28 19:11:01 +01:00
7c218fc664 add build workflow
Some checks failed
Build and Deploy Debian Package / build-package (push) Failing after 20s
2025-01-28 19:02:32 +01:00
3 changed files with 9 additions and 14 deletions

View file

@ -50,7 +50,7 @@ jobs:
- name: Generate version number - name: Generate version number
run: | run: |
VERSION=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//') VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.1.$(git rev-list --count HEAD)")
echo "VERSION=$VERSION" >> $GITHUB_ENV echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Build Debian package with FPM - name: Build Debian package with FPM
@ -58,9 +58,7 @@ jobs:
# The -s dir option tells FPM the source is a directory. # The -s dir option tells FPM the source is a directory.
# The -t deb option builds a deb package. # The -t deb option builds a deb package.
# -n is the package name and -v the version. # -n is the package name and -v the version.
fpm -s dir -t deb -n magicfw-docker -v $VERSION -C package \ fpm -s dir -t deb -n magicfw-docker -v $VERSION -C package .
-d "python3" \
-d "python3-docker"
- name: Upload to Forgejo Debian Registry - name: Upload to Forgejo Debian Registry
env: env:

View file

@ -20,19 +20,14 @@ You can define rules per container using specific Docker labels:
| **Label Key** | **Description** | **Default** | | **Label Key** | **Description** | **Default** |
|----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|-------------| |----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|-------------|
| `magicfw.firewall.allow_icc` | Enables communication between the container and other containers on different Docker networks (not normally possible in Docker environments). | `false` | | `magicfw.firewall.allow_icc` | Enables communication between the container and other containers on different Docker networks (not normally possible in Docker environments). | `false` |
| `magicfw.firewall.allow_external` | Enables access from external networks (e.g., the internet) for the container. | `false` | | `magicfw.firewall.allow_external` | Enables access to external networks (e.g., the internet) for the container. | `false` |
### Behavior and Functionalities ### Behavior and Functionalities
- **Allow ICC (Inter-Container Communication):** When `magicfw.firewall.allow_icc` is `true`, the container can communicate with other containers across **different Docker networks** (useful for applications like reverse proxies such as Traefik). If `false`, the container is isolated from other Docker networks (default Docker behavior). - **Allow ICC (Inter-Container Communication):** When `magicfw.firewall.allow_icc` is `true`, the container can communicate with other containers across **different Docker networks** (useful for applications like reverse proxies such as Traefik). If `false`, the container is isolated from other Docker networks (default Docker behavior).
- **External Traffic:** When `magicfw.firewall.allow_external` is `true`, the container's network rules allow communication from external networks (useful when NAT is disabled). - **External Traffic:** When `magicfw.firewall.allow_external` is `true`, the container's network rules allow communication with external IPs.
- **Automatic Rule Cleanup:** When a container is restarted, stopped, or removed, the corresponding firewall rules are automatically cleaned. - **Automatic Rule Cleanup:** When a container is restarted, stopped, or removed, the corresponding firewall rules are automatically cleaned.
- **Support for Published Ports:** Rules are auto-generated for any published ports, restricting incoming traffic to only the ports explicitly exposed via Docker. - **Support for Published Ports:** Rules are auto-generated for any published ports, restricting incoming traffic to only the ports explicitly exposed via Docker.
## Install
To make the installation easy, I provide a package for Debian-based distros, follow the instructions here: [https://git.marcorealacci.me/marcorealacci/-/packages/debian/magicfw-docker](https://git.marcorealacci.me/marcorealacci/-/packages/debian/magicfw-docker)
To install the script manually, the required dependencies are `python3` and the `docker` library available from PyPI (`pip3 install docker`).
## Configuration ## Configuration
### Environment Variables ### Environment Variables
@ -61,11 +56,13 @@ services:
labels: labels:
magicfw.firewall.allow_icc: "true" magicfw.firewall.allow_icc: "true"
magicfw.firewall.allow_external: "true" magicfw.firewall.allow_external: "true"
ports:
- 8080:80
``` ```
In the above example: In the above example:
- The `web` container can communicate with other containers on different Docker networks (`magicfw.firewall.allow_icc: true`). - The `web` container can communicate with other containers on different Docker networks (`magicfw.firewall.allow_icc: true`).
- The container can be accessed by external hosts using the container's IP (**not host IP!**) (`magicfw.firewall.allow_external: true`). This requires a route on other hosts or the router. - The container can be accessed by external hosts using the container's IP (`magicfw.firewall.allow_external: true`).
#### Example 2 #### Example 2
```yaml ```yaml
@ -95,7 +92,7 @@ services:
In the above example: In the above example:
- The `web` container can communicate with other containers on different Docker networks (`magicfw.firewall.allow_icc: true`). - The `web` container can communicate with other containers on different Docker networks (`magicfw.firewall.allow_icc: true`).
- External hosts can access the container via both <container IP>:80 and <host IP>:8080 (port mapping still works even with `DISABLE_NAT` set to `true`, as only Source NAT will be disabled) - External hosts can access the container via both <container IP>:80 and <host IP>:8080 (port mapping still works even with DISABLE_NAT)
- External hosts will not be able to access the container on ports other than 80 - External hosts will not be able to access the container on ports other than 80
--- ---

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python
import os import os
import json import json
import logging import logging