Skip to content

Commit

Permalink
A small, descriptive extension to include firewalld.
Browse files Browse the repository at this point in the history
Avoiding a search for those not using iptables.
  • Loading branch information
obreidenich committed Feb 21, 2024
1 parent 129c0d7 commit 4cba552
Showing 1 changed file with 16 additions and 3 deletions.
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

0 comments on commit 4cba552

Please sign in to comment.