-
Notifications
You must be signed in to change notification settings - Fork 616
Binding to Low Ports
Terror edited this page Oct 10, 2017
·
4 revisions
If you want to bind fabio to ports below 1024 without running fabio as root you can use an operating system approach as described below. These best practices are taken from https://github.com/fabiolb/fabio/issues/195.
$ setcap 'cap_net_bind_service=+ep' $(which fabio)
$ cat /etc/systemd/system/fabio.service
[Unit]
Description=Fabio proxy
After=syslog.target
After=network.target
[Service]
LimitMEMLOCK=infinity
LimitNOFILE=65535
Type=simple
# unprivileged uid and gid
User=fabio_user
Group=fabio_group
WorkingDirectory=/
ExecStart=/path/to/fabio -cfg /path/to/fabio.conf
Restart=always
# no need that fabio messes with /dev
PrivateDevices=yes
# dedicated /tmp
PrivateTmp=yes
# make /usr, /boot, /etc read only
ProtectSystem=full
# /home is not accessible at all
ProtectHome=yes
# to be able to bind port < 1024
AmbientCapabilities=CAP_NET_BIND_SERVICE
NoNewPrivileges=yes
# only ipv4, ipv6, unix socket and netlink networking is possible
# netlink is necessary so that fabio can list available IPs on startup
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX AF_NETLINK
$ /usr/sbin/usermod -K defaultpriv=basic,net_privaddr fabio_user
$ grep fabio_user /etc/user_attr
fabio_user::::type=normal;defaultpriv=basic,net_privaddr
$ /usr/sbin/ppriv -s PELI+NET_PRIVADDR -e fabio
/etc/pf.conf
EXT_IF = "eth0"
HTTPS_PORT = 443
HTTPS_PORT_BACKEND = 4343
LOCAL_IP = "127.0.0.1"
...
pass in quick on $EXT_IF inet proto tcp from any to $LOCAL_IP port $HTTPS_PORT rdr-to $LOCAL_IP port $HTTPS_PORT_BACKEND
$ sysctl net.inet.ip.portrange.reservedhigh=79
# add to /etc/sysctl.conf to make this permament
Use launchd
to launch fabio by creating a service plist and using launchctl to run it:
$sudo launchctl load -w /path/to/fabio.plist
Example plist XML (needs reviewing):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist
PUBLIC '-//Apple//DTD PLIST 1.0//EN'
'http://www.apple.com/DTDs/PropertyList-1.0.dtd'>
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.github.fabiolb.fabio</string>
<key>Program</key>
<string>fabio</string>
<key>Sockets</key>
<dict>
<key>Listeners</key>
<dict>
<key>SockServiceName</key>
<string>80</string>
<key>SockType</key>
<string>stream</string>
<key>SockFamily</key>
<string>IPv4</string>
</dict>
</dict>
</dict>
</plist>
???
- Home
- Quickstart
- Installation
- Verifying Releases
- Configuration
- Binding to low ports
- Deployment
-
Features
- Access Logging ⭐️
- Certificate Stores
- Compression
- Circonus Support
- DataDog Support
- Docker Support
- Dynamic Reloading
- Graceful Shutdown
- Graphite Support
- HTTP Header
- HTTPS Upstream
- Metrics Support
- Path Stripping
- PROXY Protocol
- Request Debugging
- Request Tracing
- SSE Support
- StatsD Support
- TCP Proxy ⭐️
- TCP+SNI Support
- Traffic Shaping
- Vault Integration
- Websockets
- Web UI
- Performance
- Service Configuration
- Routing
- Debugging
- Contributing
- Why fabio?