1SYSTEMD-SOCKET-PROXYD(8) systemd-socket-proxyd SYSTEMD-SOCKET-PROXYD(8)
2
3
4
6 systemd-socket-proxyd - Bidirectionally proxy local sockets to another
7 (possibly remote) socket.
8
10 systemd-socket-proxyd [OPTIONS...] HOST:PORT
11
12 systemd-socket-proxyd [OPTIONS...] UNIX-DOMAIN-SOCKET-PATH
13
15 systemd-socket-proxyd is a generic socket-activated network socket
16 forwarder proxy daemon for IPv4, IPv6 and UNIX stream sockets. It may
17 be used to bi-directionally forward traffic from a local listening
18 socket to a local or remote destination socket.
19
20 One use of this tool is to provide socket activation support for
21 services that do not natively support socket activation. On behalf of
22 the service to activate, the proxy inherits the socket from systemd,
23 accepts each client connection, opens a connection to a configured
24 server for each client, and then bidirectionally forwards data between
25 the two.
26
27 This utility's behavior is similar to socat(1). The main differences
28 for systemd-socket-proxyd are support for socket activation with
29 "Accept=false" and an event-driven design that scales better with the
30 number of connections.
31
33 The following options are understood:
34
35 -h, --help
36 Print a short help text and exit.
37
38 --version
39 Print a short version string and exit.
40
42 On success, 0 is returned, a non-zero failure code otherwise.
43
45 Simple Example
46 Use two services with a dependency and no namespace isolation.
47
48 Example 1. proxy-to-nginx.socket
49
50 [Socket]
51 ListenStream=80
52
53 [Install]
54 WantedBy=sockets.target
55
56 Example 2. proxy-to-nginx.service
57
58 [Unit]
59 Requires=nginx.service
60 After=nginx.service
61
62 [Service]
63 ExecStart=/usr/lib/systemd/systemd-socket-proxyd /tmp/nginx.sock
64 PrivateTmp=yes
65 PrivateNetwork=yes
66
67 Example 3. nginx.conf
68
69 [...]
70 server {
71 listen unix:/tmp/nginx.sock;
72 [...]
73
74 Example 4. Enabling the proxy
75
76 # systemctl enable proxy-to-nginx.socket
77 # systemctl start proxy-to-nginx.socket
78 $ curl http://localhost:80/
79
80 Namespace Example
81 Similar as above, but runs the socket proxy and the main service in the
82 same private namespace, assuming that nginx.service has PrivateTmp= and
83 PrivateNetwork= set, too.
84
85 Example 5. proxy-to-nginx.socket
86
87 [Socket]
88 ListenStream=80
89
90 [Install]
91 WantedBy=sockets.target
92
93 Example 6. proxy-to-nginx.service
94
95 [Unit]
96 Requires=nginx.service
97 After=nginx.service
98 JoinsNamespaceOf=nginx.service
99
100 [Service]
101 ExecStart=/usr/lib/systemd/systemd-socket-proxyd 127.0.0.1:8080
102 PrivateTmp=yes
103 PrivateNetwork=yes
104
105 Example 7. nginx.conf
106
107 [...]
108 server {
109 listen 8080;
110 listen unix:/tmp/nginx.sock;
111 [...]
112
113 Example 8. Enabling the proxy
114
115 # systemctl enable proxy-to-nginx.socket
116 # systemctl start proxy-to-nginx.socket
117 $ curl http://localhost:80/
118
120 systemd(1), systemd.socket(5), systemd.service(5), systemctl(1),
121 socat(1), nginx(1), curl(1)
122
123
124
125systemd 219 SYSTEMD-SOCKET-PROXYD(8)