rathole/examples/systemd
inclyc 67182fbc10
docs: [example][systemd] use `DynamicUser=yes` (#186)
This patch fixes a warning generated by some new version of systemd. Use
"User=nobody" seems to be considered unsafe. So maybe we need to fix it
in our example files.

● ratholec@hitmc.service - Rathole Client Service
     Loaded: loaded (/etc/systemd/system/ratholec@.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2022-09-03 23:38:43 CST; 1h 27min ago
   Main PID: 507903 (rathole)
      Tasks: 14 (limit: 76731)
     Memory: 6.9M
        CPU: 39.908s
     CGroup: /system.slice/system-ratholec.slice/ratholec@hitmc.service
             └─507903 /usr/local/bin/rathole -c /etc/rathole/hitmc.toml

Sep 03 23:38:43 <hostname> systemd[1]: Started Rathole Client Service.
...
Sep 03 23:39:25 <hostname> systemd[1]: /etc/systemd/system/ratholec@.service:7: Special user nobody configured, this is not safe!
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Link: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=969329
Link: https://github.com/trojan-gfw/trojan/issues/612
Link: https://www.vvave.net/archives/fix-the-systemd-error-special-user-nobody-configured-this-is-not-safe.html
2022-09-04 19:54:21 +08:00
..
README.md docs: fix a typo 2022-01-26 21:11:48 +08:00
rathole@.service docs: [example][systemd] use `DynamicUser=yes` (#186) 2022-09-04 19:54:21 +08:00
ratholec.service docs: [example][systemd] use `DynamicUser=yes` (#186) 2022-09-04 19:54:21 +08:00
ratholec@.service docs: [example][systemd] use `DynamicUser=yes` (#186) 2022-09-04 19:54:21 +08:00
ratholes.service docs: [example][systemd] use `DynamicUser=yes` (#186) 2022-09-04 19:54:21 +08:00
ratholes@.service docs: [example][systemd] use `DynamicUser=yes` (#186) 2022-09-04 19:54:21 +08:00

README.md

Systemd Unit Examples

The directory lists some systemd unit files for example, which can be used to run rathole as a service on Linux.

The @ symbol in name of unit files such as rathole@.service facilitates the management of multiple instances of rathole.

For the naming of the example, ratholes stands for rathole --server, and ratholec stands for rathole --client, rathole is just rathole.

Assuming that rathole is installed in /usr/bin/rathole, and the configuration file is in /etc/rathole/app1.toml, the following steps shows how to run an instance of rathole --server.

  1. Create a service file.
sudo cp ratholes@.service /etc/systemd/system/
  1. Create the configuration file app1.toml.
sudo mkdir -p /etc/rathole
# And create the configuration file named `app1.toml` inside /etc/rathole
  1. Enable and start the service
sudo systemctl daemon-reload # Make sure systemd find the new unit
sudo systemctl enable ratholes@app1 --now

And if there's another configuration named app2.toml in /etc/rathole, then sudo systemctl enable ratholes@app2 --now can start an instance for that configuration.

The same applies to rathole --client and rathole.