3 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.2//EN"
4 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 SPDX-License-Identifier: LGPL-2.1+
8 This file is part of systemd.
10 Copyright 2013 David Strauss
12 <refentry id=
"systemd-socket-proxyd"
13 xmlns:
xi=
"http://www.w3.org/2001/XInclude">
16 <title>systemd-socket-proxyd
</title>
17 <productname>systemd
</productname>
20 <contrib>Developer
</contrib>
21 <firstname>David
</firstname>
22 <surname>Strauss
</surname>
23 <email>david@davidstrauss.net
</email>
28 <refentrytitle>systemd-socket-proxyd
</refentrytitle>
29 <manvolnum>8</manvolnum>
32 <refname>systemd-socket-proxyd
</refname>
33 <refpurpose>Bidirectionally proxy local sockets to another (possibly remote) socket.
</refpurpose>
37 <command>systemd-socket-proxyd
</command>
38 <arg choice=
"opt" rep=
"repeat"><replaceable>OPTIONS
</replaceable></arg>
39 <arg choice=
"plain"><replaceable>HOST
</replaceable>:
<replaceable>PORT
</replaceable></arg>
42 <command>systemd-socket-proxyd
</command>
43 <arg choice=
"opt" rep=
"repeat"><replaceable>OPTIONS
</replaceable></arg>
44 <arg choice=
"plain"><replaceable>UNIX-DOMAIN-SOCKET-PATH
</replaceable>
49 <title>Description
</title>
51 <command>systemd-socket-proxyd
</command> is a generic
52 socket-activated network socket forwarder proxy daemon for IPv4,
53 IPv6 and UNIX stream sockets. It may be used to bi-directionally
54 forward traffic from a local listening socket to a local or remote
55 destination socket.
</para>
57 <para>One use of this tool is to provide socket activation support
58 for services that do not natively support socket activation. On
59 behalf of the service to activate, the proxy inherits the socket
60 from systemd, accepts each client connection, opens a connection
61 to a configured server for each client, and then bidirectionally
62 forwards data between the two.
</para>
63 <para>This utility's behavior is similar to
64 <citerefentry project='die-net'
><refentrytitle>socat
</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
65 The main differences for
<command>systemd-socket-proxyd
</command>
66 are support for socket activation with
67 <literal>Accept=false
</literal> and an event-driven
68 design that scales better with the number of
72 <title>Options
</title>
73 <para>The following options are understood:
</para>
75 <xi:include href=
"standard-options.xml" xpointer=
"help" />
76 <xi:include href=
"standard-options.xml" xpointer=
"version" />
78 <term><option>--connections-max=
</option></term>
79 <term><option>-c
</option></term>
81 <listitem><para>Sets the maximum number of simultaneous connections, defaults to
256.
82 If the limit of concurrent connections is reached further connections will be refused.
</para></listitem>
87 <title>Exit status
</title>
88 <para>On success,
0 is returned, a non-zero failure
89 code otherwise.
</para>
92 <title>Examples
</title>
94 <title>Simple Example
</title>
95 <para>Use two services with a dependency and no namespace
98 <title>proxy-to-nginx.socket
</title>
99 <programlisting><![CDATA[[Socket]
103 WantedBy=sockets.target]]
></programlisting>
106 <title>proxy-to-nginx.service
</title>
107 <programlisting><![CDATA[[Unit]
108 Requires=nginx.service
110 Requires=proxy-to-nginx.socket
111 After=proxy-to-nginx.socket
114 ExecStart=/usr/lib/systemd/systemd-socket-proxyd /run/nginx/socket
116 PrivateNetwork=yes]]
></programlisting>
119 <title>nginx.conf
</title>
123 listen unix:/run/nginx/socket;
128 <title>Enabling the proxy
</title>
129 <programlisting><![CDATA[# systemctl enable --now proxy-to-nginx.socket
130 $ curl http://localhost:
80/]]
></programlisting>
134 <title>Namespace Example
</title>
135 <para>Similar as above, but runs the socket proxy and the main
136 service in the same private namespace, assuming that
137 <filename>nginx.service
</filename> has
138 <varname>PrivateTmp=
</varname> and
139 <varname>PrivateNetwork=
</varname> set, too.
</para>
141 <title>proxy-to-nginx.socket
</title>
142 <programlisting><![CDATA[[Socket]
146 WantedBy=sockets.target]]
></programlisting>
149 <title>proxy-to-nginx.service
</title>
150 <programlisting><![CDATA[[Unit]
151 Requires=nginx.service
153 Requires=proxy-to-nginx.socket
154 After=proxy-to-nginx.socket
155 JoinsNamespaceOf=nginx.service
158 ExecStart=/usr/lib/systemd/systemd-socket-proxyd
127.0.0.1:
8080
160 PrivateNetwork=yes]]
></programlisting>
163 <title>nginx.conf
</title>
164 <programlisting><![CDATA[[…]
167 […]]]
></programlisting>
170 <title>Enabling the proxy
</title>
171 <programlisting><![CDATA[# systemctl enable --now proxy-to-nginx.socket
172 $ curl http://localhost:
80/]]
></programlisting>
177 <title>See Also
</title>
179 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
180 <citerefentry><refentrytitle>systemd.socket
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
181 <citerefentry><refentrytitle>systemd.service
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
182 <citerefentry><refentrytitle>systemctl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
183 <citerefentry project='die-net'
><refentrytitle>socat
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
184 <citerefentry project='die-net'
><refentrytitle>nginx
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
185 <citerefentry project='die-net'
><refentrytitle>curl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>