weavescopeをApache2.4でproxyする方法


概要

weavescopeはDockerの相関図をリアルタイムに表示してくれるとてもかっこよいソフトだ。
https://github.com/weaveworks/scope

しかし、ポート番号でアクセスするのがかっこ悪いのでproxyを噛まそうとするとよくはまるらしい。
https://github.com/weaveworks/scope/issues/3725

かくいう私もその口。

結論

WebSocketも転送してやらないとならない

Apacheの設定ファイル例のコピペ

via https://github.com/weaveworks/scope/issues/3725#issuecomment-567626454

<VirtualHost *:443>
    ServerName weavescope.<your domain>.jp


    SSLEngine on
    ServerAdmin webmaster@localhost
    SSLCertificateFile /etc/letsencrypt/live/<your domain>/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/<your domain>/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/<your domain>/chain.pem


    ProxyRequests Off
    ProxyPreserveHost On

    RewriteEngine On
    RewriteCond %{HTTP:Connection} Upgrade [NC]
    RewriteCond %{HTTP:Upgrade} websocket [NC]
    RewriteRule /(.*) ws://localhost:4040/$1 [P,L]

    RequestHeader set X-Forwarded-Proto "https"
    RequestHeader set X-Forwarded-Port "443"


    ProxyPass / http://localhost:4040/
    ProxyPassReverse / http://localhost:4040/
    ProxyPass / ws://localhost:4040/
    ProxyPassReverse / ws://localhost:4040/

</VirtualHost>