Skip to content

Instantly share code, notes, and snippets.

@danielpclin
Forked from ihipop/frp systemd.md
Last active December 26, 2023 05:15
Show Gist options
  • Save danielpclin/da17858e3c6b2016c7cace9ef4ed84c7 to your computer and use it in GitHub Desktop.
Save danielpclin/da17858e3c6b2016c7cace9ef4ed84c7 to your computer and use it in GitHub Desktop.
FRP systemd

This Version Allow run as nobody AND ports below 1024

/etc/systemd/system/frps.service

[Unit]
Description=FRP Server Daemon

[Service]
Type=simple
AmbientCapabilities=CAP_NET_BIND_SERVICE
ExecStart=/opt/frp/frps -c /opt/frp/frps.toml
Restart=always
RestartSec=2s
User=nobody
LimitNOFILE=infinity

[Install]
WantedBy=multi-user.target

Systems that without AmbientCapabilities support,You need apt install libcap2-bin then

[Unit]
Description=FRP Server Daemon

[Service]
Type=simple
ExecStartPre=-/usr/sbin/setcap cap_net_bind_service=+ep /opt/bin/frps
ExecStart=/opt/frp/frps -c /opt/frp/frps.toml
Restart=always
RestartSec=2s
User=nobody
PermissionsStartOnly=true
LimitNOFILE=infinity

[Install]
WantedBy=multi-user.target

/etc/systemd/system/frpc.service

[Unit]
Description=FRP Client Daemon
After=network.target
Wants=network.target

[Service]
Type=simple
ExecStart=/opt/frp/frpc -c /opt/frp/frpc.ini
Restart=always
RestartSec=20s
User=nobody
LimitNOFILE=infinity

[Install]
WantedBy=multi-user.target

Config

systemctl daemon-reload
systemctl enable frpc
systemctl status frpc
systemctl enable frps
systemctl status frps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment