Webhook.siteのインストール方法

# 1. はじめに。Webhook.siteとは

[Webhook.site](https://webhook.site/)はホスティングされたWebサイト上でWebhookの動作を確認したりデバッグを支援することができるツールである。しかし、自分のローカル環境にインストールして稼働させることも可能である（ただし、デフォルトでhttpでしか対応していないようだが）。

Webhook.siteをローカル環境に導入するためには、docker-composeが必要である。また、docker-composeを稼働させるためにはdockerが必要である。

- [Webhook.siteのインストール方法](https://docs.webhook.site/open-source.html)
- [convenience scriptを利用したdockerのインストール方法](https://docs.docker.com/engine/install/centos/#install-using-the-convenience-script)
- [docker-composeのインストール方法](https://docs.docker.com/compose/install/other/)
- [docker-composeのrelease notes](https://github.com/docker/compose/releases)

# 2. インストール方法

```txt:環境確認
[root@syasuda-wehbook1 ~]# cat /etc/redhat-release
CentOS Stream release 9

[root@syasuda-wehbook1 ~]# uname -a
Linux syasuda-wehbook1 5.14.0-252.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Feb 1 13:25:18 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
```

```txt:dockerのインストール
[root@syasuda-wehbook1 ~]# curl -fsSL https://get.docker.com -o get-docker.sh
[root@syasuda-wehbook1 ~]# sudo sh get-docker.sh
[root@syasuda-wehbook1 ~]# docker version
Client: Docker Engine - Community
 Version:           23.0.4
 API version:       1.42
 Go version:        go1.19.8
 Git commit:        f480fb1
 Built:             Fri Apr 14 10:34:35 2023
 OS/Arch:           linux/amd64
 Context:           default
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[root@syasuda-wehbook1 ~]# systemctl start docker
```
```txt:docker composeのインストール
[root@syasuda-wehbook1 ~]# curl -SL https://github.com/docker/compose/releases/download/v2.17.3/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
[root@syasuda-wehbook1 ~]# chmod +x /usr/local/bin/docker-compose
[root@syasuda-wehbook1 ~]# docker-compose version
Docker Compose version v2.17.3
```
```txt:webhook.siteのインストール
[root@syasuda-wehbook1 ~]# yum install -y git
[root@syasuda-wehbook1 ~]# git clone https://github.com/fredsted/webhook.site
[root@syasuda-wehbook1 ~]# cd webhook.site/
[root@syasuda-wehbook1 webhook.site]# docker-compose up
（途中略）
Attaching to webhooksite-laravel-echo-server-1, webhooksite-redis-1, webhooksite-webhook-1
webhooksite-redis-1                | 1:C 24 Apr 2023 06:12:31.139 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
webhooksite-redis-1                | 1:C 24 Apr 2023 06:12:31.139 # Redis version=7.0.11, bits=64, commit=00000000, modified=0, pid=1, just started
webhooksite-redis-1                | 1:C 24 Apr 2023 06:12:31.139 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
webhooksite-redis-1                | 1:M 24 Apr 2023 06:12:31.139 * monotonic clock: POSIX clock_gettime
webhooksite-redis-1                | 1:M 24 Apr 2023 06:12:31.141 * Running mode=standalone, port=6379.
webhooksite-redis-1                | 1:M 24 Apr 2023 06:12:31.141 # Server initialized
webhooksite-redis-1                | 1:M 24 Apr 2023 06:12:31.141 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
webhooksite-redis-1                | 1:M 24 Apr 2023 06:12:31.141 * Ready to accept connections
webhooksite-webhook-1              | [s6-init] making user provided files available at /var/run/s6/etc...exited 0.
webhooksite-webhook-1              | [s6-init] ensuring user provided files have correct perms...exited 0.
webhooksite-webhook-1              | [fix-attrs.d] applying ownership & permissions fixes...
webhooksite-webhook-1              | [fix-attrs.d] done.
webhooksite-webhook-1              | [cont-init.d] executing container initialization scripts...
webhooksite-webhook-1              | [cont-init.d] done.
webhooksite-webhook-1              | [services.d] starting services
webhooksite-webhook-1              | PHP-FPM's opcache is NOT enabled
webhooksite-webhook-1              | [24-Apr-2023 06:12:31] NOTICE: fpm is running, pid 181
webhooksite-webhook-1              | [24-Apr-2023 06:12:31] NOTICE: ready to handle connections
webhooksite-webhook-1              | [services.d] done.
webhooksite-laravel-echo-server-1  |
webhooksite-laravel-echo-server-1  | L A R A V E L  E C H O  S E R V E R
webhooksite-laravel-echo-server-1  |
webhooksite-laravel-echo-server-1  | version 1.3.7
webhooksite-laravel-echo-server-1  |
webhooksite-laravel-echo-server-1  | ⚠ Starting server in DEV mode...
webhooksite-laravel-echo-server-1  |
webhooksite-laravel-echo-server-1  | ✔  Running at 0.0.0.0 on port 6001
webhooksite-laravel-echo-server-1  | ✔  Channels are ready.
webhooksite-laravel-echo-server-1  | ✔  Listening for http events...
webhooksite-laravel-echo-server-1  | ✔  Listening for redis events...
webhooksite-laravel-echo-server-1  |
webhooksite-laravel-echo-server-1  | Server ready!
webhooksite-laravel-echo-server-1  |
```

# 3. 動作確認

```txt:port8084で任意のインターフェースに対してlistenしている
[root@syasuda-wehbook1 ~]# ss -anpt
State               Recv-Q              Send-Q                             Local Address:Port                             Peer Address:Port               Process
LISTEN              0                   4096                                     0.0.0.0:111                                   0.0.0.0:*                   users:(("rpcbind",pid=671,fd=4),("systemd",pid=1,fd=89))
LISTEN              0                   128                                      0.0.0.0:22                                    0.0.0.0:*                   users:(("sshd",pid=828,fd=3))
LISTEN              0                   4096                                     0.0.0.0:8084                                  0.0.0.0:*                   users:(("docker-proxy",pid=5433,fd=4))
ESTAB               0                   0                                      10.0.0.40:22                                   10.0.0.4:36002               users:(("sshd",pid=937,fd=4),("sshd",pid=922,fd=4))
ESTAB               0                   0                                      10.0.0.40:22                                   10.0.0.4:36010               users:(("sshd",pid=5739,fd=4),("sshd",pid=5736,fd=4))
LISTEN              0                   4096                                        [::]:111                                      [::]:*                   users:(("rpcbind",pid=671,fd=6),("systemd",pid=1,fd=91))
LISTEN              0                   128                                         [::]:22                                       [::]:*                   users:(("sshd",pid=828,fd=4))
LISTEN              0                   4096                                        [::]:8084                                     [::]:*                   users:(("docker-proxy",pid=5440,fd=4))
```

```shell:SSH PortForwardingで該当のサーバーに接続
syasuda@MacBook ~ % ssh -L 8084:localhost:8084 root@xxx.xxx.xxx.xxx
```

これで、SSHの接続元環境にて、`http://localhost:8084/`でアクセスできる。
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/62127/121ce027-3b26-8ef3-af1e-cdc26db34f6c.png)


以下は、webhookでこのサーバーにアクセスした際の実行例。
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/62127/9d04a830-29d5-f88c-e3b3-856882b3599d.png)