15
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

systemdで簡易中継サーバを作る

Posted at

xinetd と netcat で簡易中継サーバを作るのsystemd版をやってみました。

.socketファイルと.serviceファイルを作ります。

/etc/systemd/system/http-proxy.socket
[Unit]
Description=Simple HTTP Proxy Socket

[Socket]
ListenStream=0.0.0.0:80
/etc/systemd/system/http-proxy.service
[Unit]
Description=Simple HTTP Proxy

[Service]
ExecStart=/usr/lib/systemd/systemd-socket-proxyd 192.168.4.99:80
PrivateTmp=yes

daemon-reloadして.socketの方を起動します。

sudo systemctl daemon-reload
sudo systemctl start http-proxy.socket

あとはアクセスするだけ。

実はman systemd-socket-proxydにまさにこんな感じのサンプルが載っています。

余談

最初は同じようにnetcatでやろうと思ったんですがどうもうまくいかなくて、色々ググってるうちにsystemd-socket-proxydというまさにそれ用なやつに辿り着いたのでした。
あと、netcatみたいなやつでsocatっていうのもあるのね。

15
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?