6

Raspberry Pi はまだ Apache 2.2 (現在 2.2.22-13+deb7u4) を使用しています。Websockets (「ProxyPass」) のプロキシとして Apache を使用するには、Apache モジュール mod_proxy_wstunnel が必要です。

Apache モジュール mod_proxy_wstunnel は、httpd 2.4.5 以降で使用できます。

mod_proxy_wstunnel を Raspberry Pi 上の Apache2 2.2 に追加するにはどうすればよいですか (バックポート mod_proxy_wstunnel)?

4

3 に答える 3

8

Apache ソースをダウンロードし、Vitkin からパッチを追加し、Apache をコンパイルして、モジュール mod_proxy_wstunnel.so を Apache モジュールに追加します。

パッチの詳細: https://gist.github.com/vitkin/6661683

詳細な手順:

# Check apache version (should be 2.2.22 as of writing, if not adjust the next step)
dpkg -s apache2

# Checkout apache source
svn checkout http://svn.apache.org/repos/asf/httpd/httpd/tags/2.2.22/ httpd-2.2.22

# Get patch and apply it
wget https://gist.github.com/vitkin/6661683/raw/873dd8b4de4ad1ff69757ffe48fc574374aedc57/apache-2.2-wstunnel.patch
cd httpd-2.2.22
patch -p1 -i ../apache-2.2-wstunnel.patch

# Build Apache 
svn co http://svn.apache.org/repos/asf/apr/apr/branches/1.4.x srclib/apr
svn co http://svn.apache.org/repos/asf/apr/apr-util/branches/1.3.x srclib/apr-util
./buildconf # EDIT: Some commenters noted that buildconf should be run before the configure
./configure --enable-proxy=shared --enable-proxy_wstunnel=shared
make

# Copy the module to apache installation
sudo cp modules/proxy/.libs/mod_proxy_wstunnel.so /usr/lib/apache2/modules

# Create module load file
cd /etc/apache2/mods-available
sudo echo "LoadModule proxy_wstunnel_module /usr/lib/apache2/modules/mod_proxy_wstunnel.so" > proxy_wstunnel.load

# Create symbolic link to load the module
cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/proxy_wstunnel.load proxy_wstunnel.load

# Add ProxyPass to Site config
cd /etc/apache2/sites-available

# e.g. modify default site config with "sudo nano default"
# and add the following line inside the VirtualHost element:
# "ProxyPass /websockets/mywebsocket ws://mywebsocketserver.com/websockets/mywebsocket"

# Restart Apache
sudo /etc/init.d/apache2 restart
于 2015-05-25T18:21:33.627 に答える
4

CentOS 2.2 の場合は次の手順に従いましたが、Raspberry Pi の場合も同様の行にあるはずです。私はこれを理解するために多くの時間を費やしましたが、これに関するドキュメントはほとんどありません。これが役立つかどうかお知らせください。そうでない場合は、問題のトラブルシューティングをお手伝いします。また、これが将来の読者に役立つことを願っています。

コンパイルするmod_proxy_tunnel.soには、

  1. yum install httpd-devel

  2. をダウンロードしmod_proxy_tunnel.cてコンパイルします。apxs -i -a -c mod_proxy_tunnel.c

次に、上記のコンパイル済みモジュールを次の場所にロードします/etc/httpd/modules

  1. をコピーmod_proxy_wstunnel.soします/etc/httpd/modules(上からコンパイル)

  2. サーバーの起動中にモジュールをロードするLoadModuleには、httpd conf ファイルでディレクティブを使用します。/etc/httpd/conf/httpd.conf

    次の行を他のすべての LoadModule 行とともに追加します

    LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
    
  3. Apache の使用を再起動するにはservice httpd restart

  4. 使用を再起動した後にApacheでロードされたモジュールを確認するにはhttpd -M

  5. モジュールをインストールしたら、次の 2 行を に追加します/etc/httpd/conf/httpd.conf

    ProxyPass /websockets/mywebsocket ws://mywebsocketserver.com//websockets/mywebsocket retry=4
    ProxyPassReverse /websockets/mywebsocket ws://mywebsocketserver.com//websockets/mywebsocket retry=4
    

注: 上記の行がデフォルトのケースの前に追加されていることを確認してください/。安全のためにapacheも再起動してください。

于 2015-07-06T20:59:37.190 に答える