Skip to content

Commit 05c8493

Browse files
authored
Provide an example systemd service file (#77)
* Create README.md * Create wireproxy.service * Update README.md
1 parent 31e6afd commit 05c8493

2 files changed

Lines changed: 65 additions & 0 deletions

File tree

systemd/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Running wireproxy with systemd
2+
3+
If you're on a systemd-based distro, you'll most likely want to run Wireproxy as a systemd unit.
4+
5+
The provided systemd unit assumes you have the wireproxy executable installed on `/opt/wireproxy/wireproxy` and a configuration file stored at `/etc/wireproxy.conf`. These paths can be customized by editing the unit file.
6+
7+
# Setting up the unit
8+
9+
1. Copy the `wireproxy.service` file from this directory to `/etc/systemd/system/`, or use the following cURL command to download it:
10+
```bash
11+
sudo curl https://raw.githubusercontent.com/pufferffish/wireproxy/master/systemd/wireproxy.service > /etc/systemd/system/wireproxy.service
12+
```
13+
14+
2. If necessary, customize the unit.
15+
16+
Edit the parts with `ExecStartPre=` and `ExecStart=` to point to the executable and the configuration file. For example, if wireproxy is installed on `/usr/bin` and the configuration file is located in `/opt/myfiles/wireproxy.conf` do the following change:
17+
```service
18+
ExecStartPre=/usr/bin/wireproxy -n -c /opt/myfiles/wireproxy.conf
19+
ExecStart=/usr/bin/wireproxy -c /opt/myfiles/wireproxy.conf
20+
```
21+
#### 2.2 Drop root privileges (optional, but recommended)
22+
Without any modifications, this Wireproxy service will run as root. You might want to drop those privileges. One way to do this is to simply create a system account for Wireproxy (or just use your own user account to run it instead).
23+
```bash
24+
sudo useradd --comment "Wireproxy tunnel" --system wireproxy
25+
```
26+
Then uncomment these lines from the wireproxy.service:
27+
```service
28+
#User=wireproxy
29+
#Group=wireproxy
30+
```
31+
Caveats:
32+
1) Make sure `wireproxy` user can read the wireproxy configuration file.
33+
2) Also note that unprivileged user cannot bind to ports below 1024 by default.
34+
35+
4. Reload systemd and enable the unit.
36+
```bash
37+
sudo systemctl daemon-reload
38+
sudo systemctl enable --now wireproxy.service
39+
```
40+
41+
5. Make sure it's working correctly.
42+
43+
Finally, check out the unit status to confirm `wireproxy.service` has started without problems. You can use commands like `systemctl status wireproxy.service` and/or `sudo journalctl -u wireproxy.service`.
44+
45+
# Additional notes
46+
47+
If you want to disable the extensive logging that's done by Wireproxy, simply add `-s` parameter to `ExecStart=`. This will enable the silent mode that was implemented with [pull/67](https://github.com/pufferffish/wireproxy/pull/67).

systemd/wireproxy.service

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[Unit]
2+
Description=Wireproxy socks5/http tunnel
3+
Wants=network-online.target
4+
After=network-online.target
5+
6+
[Service]
7+
#Uncomment and/or change these if you don't want to run Wireproxy as root
8+
#User=wireproxy
9+
#Group=wireproxy
10+
Type=simple
11+
Restart=on-failure
12+
RestartSec=30s
13+
ExecStartPre=/opt/wireproxy/wireproxy -n -c /etc/wireproxy.conf
14+
ExecStart=/opt/wireproxy/wireproxy -c /etc/wireproxy.conf
15+
SyslogIdentifier=wireproxy
16+
17+
[Install]
18+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)