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 systemd is free software; you can redistribute it and/or modify it
13 under the terms of the GNU Lesser General Public License as published by
14 the Free Software Foundation; either version 2.1 of the License, or
15 (at your option) any later version.
17 systemd is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
22 You should have received a copy of the GNU Lesser General Public License
23 along with systemd; If not, see <http://www.gnu.org/licenses/>.
25 <refentry id=
"systemd-socket-proxyd"
26 xmlns:
xi=
"http://www.w3.org/2001/XInclude">
29 <title>systemd-socket-proxyd
</title>
30 <productname>systemd
</productname>
33 <contrib>Developer
</contrib>
34 <firstname>David
</firstname>
35 <surname>Strauss
</surname>
36 <email>david@davidstrauss.net
</email>
41 <refentrytitle>systemd-socket-proxyd
</refentrytitle>
42 <manvolnum>8</manvolnum>
45 <refname>systemd-socket-proxyd
</refname>
46 <refpurpose>Bidirectionally proxy local sockets to another (possibly remote) socket.
</refpurpose>
50 <command>systemd-socket-proxyd
</command>
51 <arg choice=
"opt" rep=
"repeat"><replaceable>OPTIONS
</replaceable></arg>
52 <arg choice=
"plain"><replaceable>HOST
</replaceable>:
<replaceable>PORT
</replaceable></arg>
55 <command>systemd-socket-proxyd
</command>
56 <arg choice=
"opt" rep=
"repeat"><replaceable>OPTIONS
</replaceable></arg>
57 <arg choice=
"plain"><replaceable>UNIX-DOMAIN-SOCKET-PATH
</replaceable>
62 <title>Description
</title>
64 <command>systemd-socket-proxyd
</command> is a generic
65 socket-activated network socket forwarder proxy daemon for IPv4,
66 IPv6 and UNIX stream sockets. It may be used to bi-directionally
67 forward traffic from a local listening socket to a local or remote
68 destination socket.
</para>
70 <para>One use of this tool is to provide socket activation support
71 for services that do not natively support socket activation. On
72 behalf of the service to activate, the proxy inherits the socket
73 from systemd, accepts each client connection, opens a connection
74 to a configured server for each client, and then bidirectionally
75 forwards data between the two.
</para>
76 <para>This utility's behavior is similar to
77 <citerefentry project='die-net'
><refentrytitle>socat
</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
78 The main differences for
<command>systemd-socket-proxyd
</command>
79 are support for socket activation with
80 <literal>Accept=false
</literal> and an event-driven
81 design that scales better with the number of
85 <title>Options
</title>
86 <para>The following options are understood:
</para>
88 <xi:include href=
"standard-options.xml" xpointer=
"help" />
89 <xi:include href=
"standard-options.xml" xpointer=
"version" />
91 <term><option>--connections-max=
</option></term>
92 <term><option>-c
</option></term>
94 <listitem><para>Sets the maximum number of simultaneous connections, defaults to
256.
95 If the limit of concurrent connections is reached further connections will be refused.
</para></listitem>
100 <title>Exit status
</title>
101 <para>On success,
0 is returned, a non-zero failure
102 code otherwise.
</para>
105 <title>Examples
</title>
107 <title>Simple Example
</title>
108 <para>Use two services with a dependency and no namespace
111 <title>proxy-to-nginx.socket
</title>
112 <programlisting><![CDATA[[Socket]
116 WantedBy=sockets.target]]
></programlisting>
119 <title>proxy-to-nginx.service
</title>
120 <programlisting><![CDATA[[Unit]
121 Requires=nginx.service
123 Requires=proxy-to-nginx.socket
124 After=proxy-to-nginx.socket
127 ExecStart=/usr/lib/systemd/systemd-socket-proxyd /tmp/nginx.sock
129 PrivateNetwork=yes]]
></programlisting>
132 <title>nginx.conf
</title>
136 listen unix:/tmp/nginx.sock;
141 <title>Enabling the proxy
</title>
142 <programlisting><![CDATA[# systemctl enable --now proxy-to-nginx.socket
143 $ curl http://localhost:
80/]]
></programlisting>
147 <title>Namespace Example
</title>
148 <para>Similar as above, but runs the socket proxy and the main
149 service in the same private namespace, assuming that
150 <filename>nginx.service
</filename> has
151 <varname>PrivateTmp=
</varname> and
152 <varname>PrivateNetwork=
</varname> set, too.
</para>
154 <title>proxy-to-nginx.socket
</title>
155 <programlisting><![CDATA[[Socket]
159 WantedBy=sockets.target]]
></programlisting>
162 <title>proxy-to-nginx.service
</title>
163 <programlisting><![CDATA[[Unit]
164 Requires=nginx.service
166 Requires=proxy-to-nginx.socket
167 After=proxy-to-nginx.socket
168 JoinsNamespaceOf=nginx.service
171 ExecStart=/usr/lib/systemd/systemd-socket-proxyd
127.0.0.1:
8080
173 PrivateNetwork=yes]]
></programlisting>
176 <title>nginx.conf
</title>
177 <programlisting><![CDATA[[…]
180 […]]]
></programlisting>
183 <title>Enabling the proxy
</title>
184 <programlisting><![CDATA[# systemctl enable --now proxy-to-nginx.socket
185 $ curl http://localhost:
80/]]
></programlisting>
190 <title>See Also
</title>
192 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
193 <citerefentry><refentrytitle>systemd.socket
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
194 <citerefentry><refentrytitle>systemd.service
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
195 <citerefentry><refentrytitle>systemctl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
196 <citerefentry project='die-net'
><refentrytitle>socat
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
197 <citerefentry project='die-net'
><refentrytitle>nginx
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
198 <citerefentry project='die-net'
><refentrytitle>curl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>