systemd-socket-proxyd.html 8.84 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>systemd-socket-proxyd</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><style>
    a.headerlink {
      color: #c60f0f;
      font-size: 0.8em;
      padding: 0 4px 0 4px;
      text-decoration: none;
      visibility: hidden;
    }

    a.headerlink:hover {
      background-color: #c60f0f;
      color: white;
    }

    h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink {
      visibility: visible;
    }
  </style><a href="index.html">Index </a>·
  <a href="systemd.directives.html">Directives </a>·
  <a href="../python-systemd/index.html">Python </a>·
  <a href="../libudev/index.html">libudev </a>·
Michael Biebl's avatar
Michael Biebl committed
22 23
  <a href="../libudev/index.html">gudev </a><span style="float:right">systemd 215</span><hr><div class="refentry"><a name="systemd-socket-proxyd"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>systemd-socket-proxyd — Bidirectionally proxy local sockets to another (possibly remote) socket.</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">systemd-socket-proxyd</code>  [<em class="replaceable"><code>OPTIONS</code></em>...]  <em class="replaceable"><code>HOST</code></em>:<em class="replaceable"><code>PORT</code></em> </p></div><div class="cmdsynopsis"><p><code class="command">systemd-socket-proxyd</code>  [<em class="replaceable"><code>OPTIONS</code></em>...]  <em class="replaceable"><code>UNIX-DOMAIN-SOCKET-PATH</code></em>
                         </p></div></div><div class="refsect1"><a name="idm214196073104"></a><h2 id="Description">Description<a class="headerlink" title="Permalink to this headline" href="#Description"></a></h2><p>
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
                <span class="command"><strong>systemd-socket-proxyd</strong></span> is a generic
                socket-activated network socket forwarder proxy daemon
                for IPv4, IPv6 and UNIX stream sockets. It may be used
                to bi-directionally forward traffic from a local listening socket to a
                local or remote destination socket.</p><p>One use of this tool is to provide
                socket activation support for services that do not
                natively support socket activation. On behalf of the
                service to activate, the proxy inherits the socket
                from systemd, accepts each client connection, opens a
                connection to a configured server for each client, and
                then bidirectionally forwards data between the
                two.</p><p>This utility's behavior is similar to
                <a href="socat.html"><span class="citerefentry"><span class="refentrytitle">socat</span>(1)</span></a>.
                The main differences for <span class="command"><strong>systemd-socket-proxyd</strong></span>
                are support for socket activation with
                "<code class="literal">Accept=false</code>" and an event-driven
                design that scales better with the number of
Michael Biebl's avatar
Michael Biebl committed
41 42 43 44
                connections.</p></div><div class="refsect1"><a name="idm214196067280"></a><h2 id="Options">Options<a class="headerlink" title="Permalink to this headline" href="#Options"></a></h2><p>The following options are understood:</p><div class="variablelist"><dl class="variablelist"><dt id="-h"><span class="term"><code class="option">-h</code>, </span><span class="term"><code class="option">--help</code></span><a class="headerlink" title="Permalink to this term" href="#-h"></a></dt><dd><p><a name="help-text"></a>Print a short help text and exit.
    </p></dd><dt id="--version"><span class="term"><code class="option">--version</code></span><a class="headerlink" title="Permalink to this term" href="#--version"></a></dt><dd><p><a name="version-text"></a>Print a short version string and exit.</p></dd></dl></div></div><div class="refsect1"><a name="idm214199963248"></a><h2 id="Exit status">Exit status<a class="headerlink" title="Permalink to this headline" href="#Exit%20status"></a></h2><p>On success, 0 is returned, a non-zero failure
                code otherwise.</p></div><div class="refsect1"><a name="idm214199962064"></a><h2 id="Examples">Examples<a class="headerlink" title="Permalink to this headline" href="#Examples"></a></h2><div class="refsect2"><a name="idm214199961392"></a><h3 id="Simple Example">Simple Example<a class="headerlink" title="Permalink to this headline" href="#Simple%20Example"></a></h3><p>Use two services with a dependency
                        and no namespace isolation.</p><div class="example"><a name="idm214199960336"></a><p class="title"><b>Example 1. proxy-to-nginx.socket</b></p><div class="example-contents"><pre class="programlisting">[Socket]
45 46 47
ListenStream=80

[Install]
Michael Biebl's avatar
Michael Biebl committed
48
WantedBy=sockets.target</pre></div></div><br class="example-break"><div class="example"><a name="idm214199958768"></a><p class="title"><b>Example 2. proxy-to-nginx.service</b></p><div class="example-contents"><pre class="programlisting">[Unit]
49 50 51 52 53 54
Requires=nginx.service
After=nginx.service

[Service]
ExecStart=/usr/lib/systemd/systemd-socket-proxyd /tmp/nginx.sock
PrivateTmp=yes
Michael Biebl's avatar
Michael Biebl committed
55
PrivateNetwork=yes</pre></div></div><br class="example-break"><div class="example"><a name="idm214199957168"></a><p class="title"><b>Example 3. nginx.conf</b></p><div class="example-contents"><pre class="programlisting">
56 57 58 59
[...]
server {
    listen       unix:/tmp/nginx.sock;
    [...]
Michael Biebl's avatar
Michael Biebl committed
60
</pre></div></div><br class="example-break"><div class="example"><a name="idm214199955424"></a><p class="title"><b>Example 4. Enabling the proxy</b></p><div class="example-contents"><pre class="programlisting"># systemctl enable proxy-to-nginx.socket
61
# systemctl start proxy-to-nginx.socket
Michael Biebl's avatar
Michael Biebl committed
62
$ curl http://localhost:80/</pre></div></div><br class="example-break"></div><div class="refsect2"><a name="idm214199953776"></a><h3 id="Namespace Example">Namespace Example<a class="headerlink" title="Permalink to this headline" href="#Namespace%20Example"></a></h3><p>Similar as above, but runs the socket
63 64 65 66 67
                        proxy and the main service in the same private
                        namespace, assuming that
                        <code class="filename">nginx.service</code> has
                        <code class="varname">PrivateTmp=</code> and
                        <code class="varname">PrivateNetwork=</code> set,
Michael Biebl's avatar
Michael Biebl committed
68
                        too.</p><div class="example"><a name="idm214199950864"></a><p class="title"><b>Example 5. proxy-to-nginx.socket</b></p><div class="example-contents"><pre class="programlisting">[Socket]
69 70 71
ListenStream=80

[Install]
Michael Biebl's avatar
Michael Biebl committed
72
WantedBy=sockets.target</pre></div></div><br class="example-break"><div class="example"><a name="idm214199949296"></a><p class="title"><b>Example 6. proxy-to-nginx.service</b></p><div class="example-contents"><pre class="programlisting">[Unit]
73 74 75 76 77 78 79
Requires=nginx.service
After=nginx.service
JoinsNamespaceOf=nginx.service

[Service]
ExecStart=/usr/lib/systemd/systemd-socket-proxyd 127.0.0.1:8080
PrivateTmp=yes
Michael Biebl's avatar
Michael Biebl committed
80
PrivateNetwork=yes</pre></div></div><br class="example-break"><div class="example"><a name="idm214199947664"></a><p class="title"><b>Example 7. nginx.conf</b></p><div class="example-contents"><pre class="programlisting">[...]
81 82 83
server {
    listen       8080;
    listen       unix:/tmp/nginx.sock;
Michael Biebl's avatar
Michael Biebl committed
84
    [...]</pre></div></div><br class="example-break"><div class="example"><a name="idm214199938672"></a><p class="title"><b>Example 8. Enabling the proxy</b></p><div class="example-contents"><pre class="programlisting"># systemctl enable proxy-to-nginx.socket
85
# systemctl start proxy-to-nginx.socket
Michael Biebl's avatar
Michael Biebl committed
86
$ curl http://localhost:80/</pre></div></div><br class="example-break"></div></div><div class="refsect1"><a name="idm214199936864"></a><h2 id="See Also">See Also<a class="headerlink" title="Permalink to this headline" href="#See%20Also"></a></h2><p>
87 88 89 90 91 92 93 94
                        <a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>,
                        <a href="systemd.socket.html"><span class="citerefentry"><span class="refentrytitle">systemd.socket</span>(5)</span></a>,
                        <a href="systemd.service.html"><span class="citerefentry"><span class="refentrytitle">systemd.service</span>(5)</span></a>,
                        <a href="systemctl.html"><span class="citerefentry"><span class="refentrytitle">systemctl</span>(1)</span></a>,
                        <a href="socat.html"><span class="citerefentry"><span class="refentrytitle">socat</span>(1)</span></a>,
                        <a href="nginx.html"><span class="citerefentry"><span class="refentrytitle">nginx</span>(1)</span></a>,
                        <a href="curl.html"><span class="citerefentry"><span class="refentrytitle">curl</span>(1)</span></a>
                </p></div></div></body></html>