Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add firewalld to doc/recipes.md #1079

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions doc/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,29 @@ but then reserved ports would be accessible by any user than can execute sōzu (
could setup of TCP proxy for SSH, SMTP etc to their own software).
The unit file is the recommended way.

## iptables
## Using unprivileged ports

iptables can be used to route connections to reserved ports to other unprivileged
ports. You can set it up as follows for 80 -> 8080 and 443 -> 8443 redirections:
Different firewalls can be used to route connections from reserved ports to other unprivileged ports.
Most common redirections follow 80 -> 8080 and 443 -> 8443.

### iptables

iptables can be utilized, using a simple nat.

```
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 8443
```

### firewalld

firewalld's syntax is very similiar to iptables. It can be made permanent using `--permanent`.

```
firewall-cmd --direct --add-rule ipv4 nat PREROUTING 0 -p tcp --dport 80 -j REDIRECT --to-port 8080
firewall-cmd --direct --add-rule ipv4 nat PREROUTING 0 -p tcp --dport 443 -j REDIRECT --to-port 8443
```

Note that any software running under the same uid as sōzu will be able to listen on
the 8080 and 8443 ports, because those ports are unprivileged and sōzu sets up
listen socket with the `SO_REUSEPORT` option.
Expand Down