]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd-socket-proxyd.xml
verify: use manager_load_startable_unit_or_warn() to load units for verification
[thirdparty/systemd.git] / man / systemd-socket-proxyd.xml
1 <?xml version="1.0"?>
2 <!--*-nxml-*-->
3 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
4 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
5 <!--
6 SPDX-License-Identifier: LGPL-2.1+
7
8 This file is part of systemd.
9
10 Copyright 2013 David Strauss
11
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.
16
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.
21
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/>.
24 -->
25 <refentry id="systemd-socket-proxyd"
26 xmlns:xi="http://www.w3.org/2001/XInclude">
27
28 <refentryinfo>
29 <title>systemd-socket-proxyd</title>
30 <productname>systemd</productname>
31 <authorgroup>
32 <author>
33 <contrib>Developer</contrib>
34 <firstname>David</firstname>
35 <surname>Strauss</surname>
36 <email>david@davidstrauss.net</email>
37 </author>
38 </authorgroup>
39 </refentryinfo>
40 <refmeta>
41 <refentrytitle>systemd-socket-proxyd</refentrytitle>
42 <manvolnum>8</manvolnum>
43 </refmeta>
44 <refnamediv>
45 <refname>systemd-socket-proxyd</refname>
46 <refpurpose>Bidirectionally proxy local sockets to another (possibly remote) socket.</refpurpose>
47 </refnamediv>
48 <refsynopsisdiv>
49 <cmdsynopsis>
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>
53 </cmdsynopsis>
54 <cmdsynopsis>
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>
58 </arg>
59 </cmdsynopsis>
60 </refsynopsisdiv>
61 <refsect1>
62 <title>Description</title>
63 <para>
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>
69
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
82 connections.</para>
83 </refsect1>
84 <refsect1>
85 <title>Options</title>
86 <para>The following options are understood:</para>
87 <variablelist>
88 <xi:include href="standard-options.xml" xpointer="help" />
89 <xi:include href="standard-options.xml" xpointer="version" />
90 <varlistentry>
91 <term><option>--connections-max=</option></term>
92 <term><option>-c</option></term>
93
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>
96 </varlistentry>
97 </variablelist>
98 </refsect1>
99 <refsect1>
100 <title>Exit status</title>
101 <para>On success, 0 is returned, a non-zero failure
102 code otherwise.</para>
103 </refsect1>
104 <refsect1>
105 <title>Examples</title>
106 <refsect2>
107 <title>Simple Example</title>
108 <para>Use two services with a dependency and no namespace
109 isolation.</para>
110 <example>
111 <title>proxy-to-nginx.socket</title>
112 <programlisting><![CDATA[[Socket]
113 ListenStream=80
114
115 [Install]
116 WantedBy=sockets.target]]></programlisting>
117 </example>
118 <example>
119 <title>proxy-to-nginx.service</title>
120 <programlisting><![CDATA[[Unit]
121 Requires=nginx.service
122 After=nginx.service
123 Requires=proxy-to-nginx.socket
124 After=proxy-to-nginx.socket
125
126 [Service]
127 ExecStart=/usr/lib/systemd/systemd-socket-proxyd /tmp/nginx.sock
128 PrivateTmp=yes
129 PrivateNetwork=yes]]></programlisting>
130 </example>
131 <example>
132 <title>nginx.conf</title>
133 <programlisting>
134 <![CDATA[[…]
135 server {
136 listen unix:/tmp/nginx.sock;
137 […]]]>
138 </programlisting>
139 </example>
140 <example>
141 <title>Enabling the proxy</title>
142 <programlisting><![CDATA[# systemctl enable --now proxy-to-nginx.socket
143 $ curl http://localhost:80/]]></programlisting>
144 </example>
145 </refsect2>
146 <refsect2>
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>
153 <example>
154 <title>proxy-to-nginx.socket</title>
155 <programlisting><![CDATA[[Socket]
156 ListenStream=80
157
158 [Install]
159 WantedBy=sockets.target]]></programlisting>
160 </example>
161 <example>
162 <title>proxy-to-nginx.service</title>
163 <programlisting><![CDATA[[Unit]
164 Requires=nginx.service
165 After=nginx.service
166 Requires=proxy-to-nginx.socket
167 After=proxy-to-nginx.socket
168 JoinsNamespaceOf=nginx.service
169
170 [Service]
171 ExecStart=/usr/lib/systemd/systemd-socket-proxyd 127.0.0.1:8080
172 PrivateTmp=yes
173 PrivateNetwork=yes]]></programlisting>
174 </example>
175 <example>
176 <title>nginx.conf</title>
177 <programlisting><![CDATA[[…]
178 server {
179 listen 8080;
180 […]]]></programlisting>
181 </example>
182 <example>
183 <title>Enabling the proxy</title>
184 <programlisting><![CDATA[# systemctl enable --now proxy-to-nginx.socket
185 $ curl http://localhost:80/]]></programlisting>
186 </example>
187 </refsect2>
188 </refsect1>
189 <refsect1>
190 <title>See Also</title>
191 <para>
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>
199 </para>
200 </refsect1>
201 </refentry>