1:255.16-alt1
[systemd_ALT.git] / man / systemd-socket-proxyd.xml
blob59a1073ab7462082f1d3a44604d216cd69268f91
1 <?xml version="1.0"?>
2 <!--*-nxml-*-->
3 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
4   "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
5 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
6 <refentry id="systemd-socket-proxyd"
7     xmlns:xi="http://www.w3.org/2001/XInclude">
9   <refentryinfo>
10     <title>systemd-socket-proxyd</title>
11     <productname>systemd</productname>
12   </refentryinfo>
13   <refmeta>
14     <refentrytitle>systemd-socket-proxyd</refentrytitle>
15     <manvolnum>8</manvolnum>
16   </refmeta>
17   <refnamediv>
18     <refname>systemd-socket-proxyd</refname>
19     <refpurpose>Bidirectionally proxy local sockets to another (possibly remote) socket</refpurpose>
20   </refnamediv>
21   <refsynopsisdiv>
22     <cmdsynopsis>
23       <command>systemd-socket-proxyd</command>
24       <arg choice="opt" rep="repeat"><replaceable>OPTIONS</replaceable></arg>
25       <arg choice="plain"><replaceable>HOST</replaceable>:<replaceable>PORT</replaceable></arg>
26     </cmdsynopsis>
27     <cmdsynopsis>
28       <command>systemd-socket-proxyd</command>
29       <arg choice="opt" rep="repeat"><replaceable>OPTIONS</replaceable></arg>
30       <arg choice="plain"><replaceable>UNIX-DOMAIN-SOCKET-PATH</replaceable>
31       </arg>
32     </cmdsynopsis>
33   </refsynopsisdiv>
34   <refsect1>
35     <title>Description</title>
36     <para>
37     <command>systemd-socket-proxyd</command> is a generic
38     socket-activated network socket forwarder proxy daemon for IPv4,
39     IPv6 and UNIX stream sockets. It may be used to bi-directionally
40     forward traffic from a local listening socket to a local or remote
41     destination socket.</para>
43     <para>One use of this tool is to provide socket activation support
44     for services that do not natively support socket activation. On
45     behalf of the service to activate, the proxy inherits the socket
46     from systemd, accepts each client connection, opens a connection
47     to a configured server for each client, and then bidirectionally
48     forwards data between the two.</para>
49     <para>This utility's behavior is similar to
50     <citerefentry project='die-net'><refentrytitle>socat</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
51     The main differences for <command>systemd-socket-proxyd</command>
52     are support for socket activation with
53     <literal>Accept=no</literal> and an event-driven
54     design that scales better with the number of
55     connections.</para>
57     <para>Note that <command>systemd-socket-proxyd</command> will not forward socket side channel
58     information, i.e. will not forward <constant>SCM_RIGHTS</constant>, <constant>SCM_CREDENTIALS</constant>,
59     <constant>SCM_SECURITY</constant>, <constant>SO_PEERCRED</constant>, <constant>SO_PEERPIDFD</constant>,
60     <constant>SO_PEERSEC</constant>, <constant>SO_PEERGROUPS</constant> and similar.</para>
61   </refsect1>
62   <refsect1>
63     <title>Options</title>
64     <para>The following options are understood:</para>
65     <variablelist>
66       <xi:include href="standard-options.xml" xpointer="help" />
67       <xi:include href="standard-options.xml" xpointer="version" />
68       <varlistentry>
69         <term><option>--connections-max=</option></term>
70         <term><option>-c</option></term>
72         <listitem><para>Sets the maximum number of simultaneous connections, defaults to 256.
73         If the limit of concurrent connections is reached further connections will be refused.</para>
75         <xi:include href="version-info.xml" xpointer="v233"/></listitem>
76       </varlistentry>
77       <varlistentry>
78         <term><option>--exit-idle-time=</option></term>
80         <listitem><para>Sets the time before exiting when there are no connections, defaults to
81         <constant>infinity</constant>. Takes a unit-less value in seconds, or a time span value such
82         as <literal>5min 20s</literal>.</para>
84         <xi:include href="version-info.xml" xpointer="v246"/></listitem>
85       </varlistentry>
86     </variablelist>
87   </refsect1>
88   <refsect1>
89     <title>Exit status</title>
90     <para>On success, 0 is returned, a non-zero failure
91     code otherwise.</para>
92   </refsect1>
93   <refsect1>
94     <title>Examples</title>
95     <refsect2>
96       <title>Simple Example</title>
97       <para>Use two services with a dependency and no namespace
98       isolation.</para>
99       <example>
100         <title>proxy-to-nginx.socket</title>
101         <programlisting><![CDATA[[Socket]
102 ListenStream=80
104 [Install]
105 WantedBy=sockets.target]]></programlisting>
106       </example>
107       <example>
108         <title>proxy-to-nginx.service</title>
109         <programlisting><![CDATA[[Unit]
110 Requires=nginx.service
111 After=nginx.service
112 Requires=proxy-to-nginx.socket
113 After=proxy-to-nginx.socket
115 [Service]
116 Type=notify
117 ExecStart=/usr/lib/systemd/systemd-socket-proxyd /run/nginx/socket
118 PrivateTmp=yes
119 PrivateNetwork=yes]]></programlisting>
120       </example>
121       <example>
122         <title>nginx.conf</title>
123         <programlisting>
124 <![CDATA[[…]
125 server {
126     listen       unix:/run/nginx/socket;
127     […]]]>
128 </programlisting>
129       </example>
130       <example>
131         <title>Enabling the proxy</title>
132         <programlisting><![CDATA[# systemctl enable --now proxy-to-nginx.socket
133 $ curl http://localhost:80/]]></programlisting>
134       </example>
135       <para>If <filename>nginx.service</filename> has <varname>StopWhenUnneeded=</varname> set, then
136       passing <option>--exit-idle-time=</option> to <command>systemd-socket-proxyd</command> allows
137       both services to stop during idle periods.</para>
138     </refsect2>
139     <refsect2>
140       <title>Namespace Example</title>
141       <para>Similar as above, but runs the socket proxy and the main
142       service in the same private namespace, assuming that
143       <filename>nginx.service</filename> has
144       <varname>PrivateTmp=</varname> and
145       <varname>PrivateNetwork=</varname> set, too.</para>
146       <example>
147         <title>proxy-to-nginx.socket</title>
148         <programlisting><![CDATA[[Socket]
149 ListenStream=80
151 [Install]
152 WantedBy=sockets.target]]></programlisting>
153       </example>
154       <example>
155         <title>proxy-to-nginx.service</title>
156         <programlisting><![CDATA[[Unit]
157 Requires=nginx.service
158 After=nginx.service
159 Requires=proxy-to-nginx.socket
160 After=proxy-to-nginx.socket
161 JoinsNamespaceOf=nginx.service
163 [Service]
164 Type=notify
165 ExecStart=/usr/lib/systemd/systemd-socket-proxyd 127.0.0.1:8080
166 PrivateTmp=yes
167 PrivateNetwork=yes]]></programlisting>
168       </example>
169       <example>
170         <title>nginx.conf</title>
171         <programlisting><![CDATA[[…]
172 server {
173     listen       8080;
174     […]]]></programlisting>
175       </example>
176       <example>
177         <title>Enabling the proxy</title>
178         <programlisting><![CDATA[# systemctl enable --now proxy-to-nginx.socket
179 $ curl http://localhost:80/]]></programlisting>
180       </example>
181     </refsect2>
182   </refsect1>
183   <refsect1>
184     <title>See Also</title>
185     <para>
186       <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
187       <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
188       <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
189       <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
190       <citerefentry project='die-net'><refentrytitle>socat</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
191       <citerefentry project='die-net'><refentrytitle>nginx</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
192       <citerefentry project='die-net'><refentrytitle>curl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
193     </para>
194   </refsect1>
195 </refentry>