]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/systemd-socket-proxyd.xml
final v236 update (#7649)
[thirdparty/systemd.git] / man / systemd-socket-proxyd.xml
CommitLineData
912b54ad
DS
1<?xml version="1.0"?>
2<!--*-nxml-*-->
3<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
12b42c76 4 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
912b54ad 5<!--
572eb058
ZJS
6 SPDX-License-Identifier: LGPL-2.1+
7
912b54ad
DS
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-->
dfdebb1b 25<refentry id="systemd-socket-proxyd"
798d3a52 26 xmlns:xi="http://www.w3.org/2001/XInclude">
dfdebb1b 27
798d3a52
ZJS
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>
8569a776 69
798d3a52
ZJS
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
3ba3a79d 77 <citerefentry project='die-net'><refentrytitle>socat</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
798d3a52
ZJS
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" />
dc3b8afb 90 <varlistentry>
23d0fff7 91 <term><option>--connections-max=</option></term>
dc3b8afb
DK
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>
798d3a52
ZJS
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]
912b54ad
DS
113ListenStream=80
114
115[Install]
9fccdb0f 116WantedBy=sockets.target]]></programlisting>
798d3a52
ZJS
117 </example>
118 <example>
119 <title>proxy-to-nginx.service</title>
120 <programlisting><![CDATA[[Unit]
912b54ad 121Requires=nginx.service
34c7dc47 122After=nginx.service
d7cefe8b 123Requires=proxy-to-nginx.socket
e5bb1de8 124After=proxy-to-nginx.socket
912b54ad
DS
125
126[Service]
12b42c76 127ExecStart=/usr/lib/systemd/systemd-socket-proxyd /tmp/nginx.sock
34c7dc47 128PrivateTmp=yes
9fccdb0f 129PrivateNetwork=yes]]></programlisting>
798d3a52
ZJS
130 </example>
131 <example>
132 <title>nginx.conf</title>
133 <programlisting>
1eecafb8 134<![CDATA[[…]
912b54ad
DS
135server {
136 listen unix:/tmp/nginx.sock;
1eecafb8 137 […]]]>
912b54ad 138</programlisting>
798d3a52
ZJS
139 </example>
140 <example>
141 <title>Enabling the proxy</title>
ee3c52eb 142 <programlisting><![CDATA[# systemctl enable --now proxy-to-nginx.socket
9fccdb0f 143$ curl http://localhost:80/]]></programlisting>
798d3a52
ZJS
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]
912b54ad
DS
156ListenStream=80
157
158[Install]
9fccdb0f 159WantedBy=sockets.target]]></programlisting>
798d3a52
ZJS
160 </example>
161 <example>
162 <title>proxy-to-nginx.service</title>
163 <programlisting><![CDATA[[Unit]
34c7dc47
LP
164Requires=nginx.service
165After=nginx.service
e5bb1de8
RH
166Requires=proxy-to-nginx.socket
167After=proxy-to-nginx.socket
34c7dc47 168JoinsNamespaceOf=nginx.service
912b54ad
DS
169
170[Service]
12b42c76 171ExecStart=/usr/lib/systemd/systemd-socket-proxyd 127.0.0.1:8080
34c7dc47 172PrivateTmp=yes
9fccdb0f 173PrivateNetwork=yes]]></programlisting>
798d3a52
ZJS
174 </example>
175 <example>
176 <title>nginx.conf</title>
1eecafb8 177 <programlisting><![CDATA[[…]
912b54ad
DS
178server {
179 listen 8080;
1eecafb8 180 […]]]></programlisting>
798d3a52
ZJS
181 </example>
182 <example>
183 <title>Enabling the proxy</title>
ee3c52eb 184 <programlisting><![CDATA[# systemctl enable --now proxy-to-nginx.socket
9fccdb0f 185$ curl http://localhost:80/]]></programlisting>
798d3a52
ZJS
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>,
3ba3a79d
ZJS
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>
798d3a52
ZJS
199 </para>
200 </refsect1>
912b54ad 201</refentry>