Skip to content

Ssl proxy on apache 2.4 to ratchet symfony 2.8 on Ubuntu 16.4

Edu edited this page Jul 4, 2018 · 6 revisions

This is based in a running https configuration for Apache 2.4. Ratchet and Apache on the same server.

Apache part:

$ sudo a2enmod proxy proxy_http proxy_wstunnel

$ sudo vim /etc/apache2/sites-available/your-site.conf

Add this line under

<VirtualHost *:443>

    [...]

   ProxyPass "/wss2/" "ws://127.0.0.1:8080/"

And the restart apache

$ sudo service apache2 restart

Symfony part:

In config.yml

gos_web_socket:
    server:
        port: 8080        #The port the socket server will listen on
        host: 127.0.0.1   #The host ip to bind to

Launch ratchet

$ php app/console gos:websocket:server

Javascript part:

 var webSocket = WS.connect("wss:/www.your-site.xxx/wss2/");

 webSocket.on("socket/connect", function(session){

     //session is an Autobahn JS WAMP session.

     console.log("Successfully Connected!");

})