Last active
August 30, 2021 11:06
-
-
Save tuanle/1ab7fe1fb14c648c8f34 to your computer and use it in GitHub Desktop.
Configuring to run php ratchet websocket via SSL connect (using Apache2 proxy)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check http version or apache2 version | |
httpd -v # apache2 -v | |
# Building mod_proxy_wstunnel.so for httpd 2.2.x | |
# Check apache version (should be 2.2.20 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.x/ httpd-2.2.x | |
# Get patch and apply it | |
# wget http://cafarelli.fr/gentoo/apache-2.2.24-wstunnel.patch | |
wget https://gist.github.com/vitkin/6661683/raw/873dd8b4de4ad1ff69757ffe48fc574374aedc57/apache-2.2-wstunnel.patch | |
cd httpd-2.2.x | |
patch -p1 < ../apache-2.2.24-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 and recompiled mod_proxy (for new symbols) to the ubuntu apache installation and update the permissions to match the other modules | |
sudo cp modules/proxy/.libs/mod_proxy{_wstunnel,}.so /usr/lib/apache2/modules/ | |
sudo chmod 644 /usr/lib/apache2/modules/mod_proxy{_wstunnel,}.so | |
echo -e "# Depends: proxy\nLoadModule proxy_wstunnel_module /usr/lib/apache2/modules/mod_proxy_wstunnel.so" | sudo tee -a /etc/apache2/mods-available/proxy_wstunnel.load | |
# Enable the module (also make any configuration changes you need) | |
sudo a2enmod proxy_wstunnel | |
sudo service apache2 restart | |
# If using httpd, cp .so file to /etc/httpd/modules/mod_proxy_wstunnel.so | |
# Add this to /etc/httpd/conf/httpd.conf | |
oadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so | |
# Add proxy config | |
<VirtualHost *:443> | |
.... | |
ProxyPass /wss/ ws://localhost:8080/ | |
</VirtualHost> | |
# Using below connection | |
var conn = new WebSocket('wss://' + "<?php echo Configure::read('WsAddress.Pull') ?>" + '/wss/'); | |
DONE!!! | |
# REFERENCE | |
http://httpd.apache.org/docs/2.4/mod/mod_proxy_wstunnel.html | |
https://gist.github.com/vitkin/6661683 | |
http://www.amoss.me.uk/2013/06/apache-2-2-websocket-proxying-ubuntu-mod_proxy_wstunnel/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks for this.