]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd-socket-proxyd.xml
tree-wide: beautify remaining copyright statements
[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 Copyright © 2013 David Strauss
9 -->
10 <refentry id="systemd-socket-proxyd"
11 xmlns:xi="http://www.w3.org/2001/XInclude">
12
13 <refentryinfo>
14 <title>systemd-socket-proxyd</title>
15 <productname>systemd</productname>
16 <authorgroup>
17 <author>
18 <contrib>Developer</contrib>
19 <firstname>David</firstname>
20 <surname>Strauss</surname>
21 <email>david@davidstrauss.net</email>
22 </author>
23 </authorgroup>
24 </refentryinfo>
25 <refmeta>
26 <refentrytitle>systemd-socket-proxyd</refentrytitle>
27 <manvolnum>8</manvolnum>
28 </refmeta>
29 <refnamediv>
30 <refname>systemd-socket-proxyd</refname>
31 <refpurpose>Bidirectionally proxy local sockets to another (possibly remote) socket.</refpurpose>
32 </refnamediv>
33 <refsynopsisdiv>
34 <cmdsynopsis>
35 <command>systemd-socket-proxyd</command>
36 <arg choice="opt" rep="repeat"><replaceable>OPTIONS</replaceable></arg>
37 <arg choice="plain"><replaceable>HOST</replaceable>:<replaceable>PORT</replaceable></arg>
38 </cmdsynopsis>
39 <cmdsynopsis>
40 <command>systemd-socket-proxyd</command>
41 <arg choice="opt" rep="repeat"><replaceable>OPTIONS</replaceable></arg>
42 <arg choice="plain"><replaceable>UNIX-DOMAIN-SOCKET-PATH</replaceable>
43 </arg>
44 </cmdsynopsis>
45 </refsynopsisdiv>
46 <refsect1>
47 <title>Description</title>
48 <para>
49 <command>systemd-socket-proxyd</command> is a generic
50 socket-activated network socket forwarder proxy daemon for IPv4,
51 IPv6 and UNIX stream sockets. It may be used to bi-directionally
52 forward traffic from a local listening socket to a local or remote
53 destination socket.</para>
54
55 <para>One use of this tool is to provide socket activation support
56 for services that do not natively support socket activation. On
57 behalf of the service to activate, the proxy inherits the socket
58 from systemd, accepts each client connection, opens a connection
59 to a configured server for each client, and then bidirectionally
60 forwards data between the two.</para>
61 <para>This utility's behavior is similar to
62 <citerefentry project='die-net'><refentrytitle>socat</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
63 The main differences for <command>systemd-socket-proxyd</command>
64 are support for socket activation with
65 <literal>Accept=false</literal> and an event-driven
66 design that scales better with the number of
67 connections.</para>
68 </refsect1>
69 <refsect1>
70 <title>Options</title>
71 <para>The following options are understood:</para>
72 <variablelist>
73 <xi:include href="standard-options.xml" xpointer="help" />
74 <xi:include href="standard-options.xml" xpointer="version" />
75 <varlistentry>
76 <term><option>--connections-max=</option></term>
77 <term><option>-c</option></term>
78
79 <listitem><para>Sets the maximum number of simultaneous connections, defaults to 256.
80 If the limit of concurrent connections is reached further connections will be refused.</para></listitem>
81 </varlistentry>
82 </variablelist>
83 </refsect1>
84 <refsect1>
85 <title>Exit status</title>
86 <para>On success, 0 is returned, a non-zero failure
87 code otherwise.</para>
88 </refsect1>
89 <refsect1>
90 <title>Examples</title>
91 <refsect2>
92 <title>Simple Example</title>
93 <para>Use two services with a dependency and no namespace
94 isolation.</para>
95 <example>
96 <title>proxy-to-nginx.socket</title>
97 <programlisting><![CDATA[[Socket]
98 ListenStream=80
99
100 [Install]
101 WantedBy=sockets.target]]></programlisting>
102 </example>
103 <example>
104 <title>proxy-to-nginx.service</title>
105 <programlisting><![CDATA[[Unit]
106 Requires=nginx.service
107 After=nginx.service
108 Requires=proxy-to-nginx.socket
109 After=proxy-to-nginx.socket
110
111 [Service]
112 ExecStart=/usr/lib/systemd/systemd-socket-proxyd /run/nginx/socket
113 PrivateTmp=yes
114 PrivateNetwork=yes]]></programlisting>
115 </example>
116 <example>
117 <title>nginx.conf</title>
118 <programlisting>
119 <![CDATA[[…]
120 server {
121 listen unix:/run/nginx/socket;
122 […]]]>
123 </programlisting>
124 </example>
125 <example>
126 <title>Enabling the proxy</title>
127 <programlisting><![CDATA[# systemctl enable --now proxy-to-nginx.socket
128 $ curl http://localhost:80/]]></programlisting>
129 </example>
130 </refsect2>
131 <refsect2>
132 <title>Namespace Example</title>
133 <para>Similar as above, but runs the socket proxy and the main
134 service in the same private namespace, assuming that
135 <filename>nginx.service</filename> has
136 <varname>PrivateTmp=</varname> and
137 <varname>PrivateNetwork=</varname> set, too.</para>
138 <example>
139 <title>proxy-to-nginx.socket</title>
140 <programlisting><![CDATA[[Socket]
141 ListenStream=80
142
143 [Install]
144 WantedBy=sockets.target]]></programlisting>
145 </example>
146 <example>
147 <title>proxy-to-nginx.service</title>
148 <programlisting><![CDATA[[Unit]
149 Requires=nginx.service
150 After=nginx.service
151 Requires=proxy-to-nginx.socket
152 After=proxy-to-nginx.socket
153 JoinsNamespaceOf=nginx.service
154
155 [Service]
156 ExecStart=/usr/lib/systemd/systemd-socket-proxyd 127.0.0.1:8080
157 PrivateTmp=yes
158 PrivateNetwork=yes]]></programlisting>
159 </example>
160 <example>
161 <title>nginx.conf</title>
162 <programlisting><![CDATA[[…]
163 server {
164 listen 8080;
165 […]]]></programlisting>
166 </example>
167 <example>
168 <title>Enabling the proxy</title>
169 <programlisting><![CDATA[# systemctl enable --now proxy-to-nginx.socket
170 $ curl http://localhost:80/]]></programlisting>
171 </example>
172 </refsect2>
173 </refsect1>
174 <refsect1>
175 <title>See Also</title>
176 <para>
177 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
178 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
179 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
180 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
181 <citerefentry project='die-net'><refentrytitle>socat</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
182 <citerefentry project='die-net'><refentrytitle>nginx</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
183 <citerefentry project='die-net'><refentrytitle>curl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
184 </para>
185 </refsect1>
186 </refentry>