あっきぃ日誌

鉄道ブログのような技術系ブログのようななにか

Debian(どれかは知らない)/Ubuntu 18.04のApache2.4でproxy_wstunnelが動いてない

自宅Webサーバー環境でMastodonを立てるにあたり、すでにUbuntu 18.04+ApacheのサーバーからMastodonサーバー(別のサーバーでDocker運用)にリバースプロキシーするようにしていたのですが、なんかストリーミングが動いていない。ログを漁ったらApacheがエラーを出していました。

AH01144: No protocol handler was valid for the URL /api/v1/streaming/public/local (scheme 'ws'). If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.

proxy系のモジュールは有効になっているはずですが。

# a2query -m | grep proxy
proxy_wstunnel (enabled by site administrator)
proxy_http (enabled by site administrator)
proxy (enabled by site administrator)

設定もサンプル通りなので、はて。それにを入れてもエラーになります。なにそれ。

     ProxyPass "/api/v1/streaming/" "ws://192.168.29.14:4000/"
     ProxyPassReverse "/api/v1/streaming/" "ws://192.168.29.14:4000/"

ぐぐると、どうもUbuntuのアップストリームであるところのDebianでバグ報告が1年半ほど放置されているのを見つけました。まあ多分これでしょう。腐ってやがる。

#880195 - apache2: Trying to use ws:// in proxy results in "No protocol handler was valid for the URL /ws .... " - Debian Bug report logs

いくつかWorkaroundは書かれていますが、mod_rewriteの方法は私がクソなせいで設定がループしてしまう状態。ちなみにバグレポートの「RewriteCond %{HTTP:Connection } Upgrade [NC]」はこれはこれでなんかエラーになったので別のところからそれっぽいのを拾ってきてます。要はHTTP:Upgradeにwebsocketが入ってたらOKということっぽい。

   # これは動かない
   RewriteEngine On
   RewriteCond %{HTTP:Upgrade} =websocket [NC]
   RewriteRule /api/v1/streaming/(.*) ws://192.168.29.14:4000/$1 [P,L]
   ProxyPass /api/v1/streaming/ http://192.168.29.14:4000/
   ProxyPassReverse /api/v1/streaming/ http://192.168.29.14:4000/

いまのところ、CentOS 7を選んでいればよかったのか……というお気持ちです。誰か助けてー。

# cat /etc/issue
Ubuntu 18.04.2 LTS \n \l
# apache2ctl -v
Server version: Apache/2.4.29 (Ubuntu)

Workaround

あるじゃん!!!動いたじゃん!!!!ありがとう!!!!

nacika.com

半日以上かえして