3 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
4 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 This file is part of systemd.
8 Copyright 2013 David Strauss
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 <refentry id="systemd-socket-proxyd"
24 xmlns:xi="http://www.w3.org/2001/XInclude">
27 <title>systemd-socket-proxyd</title>
28 <productname>systemd</productname>
31 <contrib>Developer</contrib>
32 <firstname>David</firstname>
33 <surname>Strauss</surname>
34 <email>david@davidstrauss.net</email>
39 <refentrytitle>systemd-socket-proxyd</refentrytitle>
40 <manvolnum>8</manvolnum>
43 <refname>systemd-socket-proxyd</refname>
44 <refpurpose>Bidirectionally proxy local sockets to another (possibly remote) socket.</refpurpose>
48 <command>systemd-socket-proxyd</command>
49 <arg choice="opt" rep="repeat"><replaceable>OPTIONS</replaceable></arg>
50 <arg choice="plain"><replaceable>HOST</replaceable>:<replaceable>PORT</replaceable></arg>
53 <command>systemd-socket-proxyd</command>
54 <arg choice="opt" rep="repeat"><replaceable>OPTIONS</replaceable></arg>
55 <arg choice="plain"><replaceable>UNIX-DOMAIN-SOCKET-PATH</replaceable>
60 <title>Description</title>
62 <command>systemd-socket-proxyd</command> is a generic
63 socket-activated network socket forwarder proxy daemon for IPv4,
64 IPv6 and UNIX stream sockets. It may be used to bi-directionally
65 forward traffic from a local listening socket to a local or remote
66 destination socket.</para>
68 <para>One use of this tool is to provide socket activation support
69 for services that do not natively support socket activation. On
70 behalf of the service to activate, the proxy inherits the socket
71 from systemd, accepts each client connection, opens a connection
72 to a configured server for each client, and then bidirectionally
73 forwards data between the two.</para>
74 <para>This utility's behavior is similar to
75 <citerefentry project='die-net'><refentrytitle>socat</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
76 The main differences for <command>systemd-socket-proxyd</command>
77 are support for socket activation with
78 <literal>Accept=false</literal> and an event-driven
79 design that scales better with the number of
83 <title>Options</title>
84 <para>The following options are understood:</para>
86 <xi:include href="standard-options.xml" xpointer="help" />
87 <xi:include href="standard-options.xml" xpointer="version" />
91 <title>Exit status</title>
92 <para>On success, 0 is returned, a non-zero failure
93 code otherwise.</para>
96 <title>Examples</title>
98 <title>Simple Example</title>
99 <para>Use two services with a dependency and no namespace
102 <title>proxy-to-nginx.socket</title>
103 <programlisting><![CDATA[[Socket]
107 WantedBy=sockets.target]]></programlisting>
110 <title>proxy-to-nginx.service</title>
111 <programlisting><![CDATA[[Unit]
112 Requires=nginx.service
116 ExecStart=/usr/lib/systemd/systemd-socket-proxyd /tmp/nginx.sock
118 PrivateNetwork=yes]]></programlisting>
121 <title>nginx.conf</title>
125 listen unix:/tmp/nginx.sock;
130 <title>Enabling the proxy</title>
131 <programlisting><![CDATA[# systemctl enable proxy-to-nginx.socket
132 # systemctl start proxy-to-nginx.socket
133 $ curl http://localhost:80/]]></programlisting>
137 <title>Namespace Example</title>
138 <para>Similar as above, but runs the socket proxy and the main
139 service in the same private namespace, assuming that
140 <filename>nginx.service</filename> has
141 <varname>PrivateTmp=</varname> and
142 <varname>PrivateNetwork=</varname> set, too.</para>
144 <title>proxy-to-nginx.socket</title>
145 <programlisting><![CDATA[[Socket]
149 WantedBy=sockets.target]]></programlisting>
152 <title>proxy-to-nginx.service</title>
153 <programlisting><![CDATA[[Unit]
154 Requires=nginx.service
156 JoinsNamespaceOf=nginx.service
159 ExecStart=/usr/lib/systemd/systemd-socket-proxyd 127.0.0.1:8080
161 PrivateNetwork=yes]]></programlisting>
164 <title>nginx.conf</title>
165 <programlisting><![CDATA[[...]
168 [...]]]></programlisting>
171 <title>Enabling the proxy</title>
172 <programlisting><![CDATA[# systemctl enable proxy-to-nginx.socket
173 # systemctl start proxy-to-nginx.socket
174 $ curl http://localhost:80/]]></programlisting>
179 <title>See Also</title>
181 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
182 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
183 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
184 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
185 <citerefentry project='die-net'><refentrytitle>socat</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
186 <citerefentry project='die-net'><refentrytitle>nginx</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
187 <citerefentry project='die-net'><refentrytitle>curl</refentrytitle><manvolnum>1</manvolnum></citerefentry>