1

I am trying to connect to my websocket server using html 5 websockets. The direct connection works fine, but when I try to hide my server behind apache proxy it does not work.

it ends up:

var ws = new WebSocket("wss://www.example.com/generator/wss/");
undefined
WebSocket connection to 'wss://www.example.com/generator/wss/' failed: Error during WebSocket handshake: Invalid status line

but if I connect directly to wss://www.example.com:9002 then it works...

Here is my apache configuration:

<VirtualHost *:80>
    ServerName  www.example.com

    ServerAdmin me@example.com

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Redirect permanent / https://www.example.com/
</VirtualHost>

<VirtualHost *:443>

    ServerName www.example.com

    ServerAdmin me@example.com

    SetEnv EXAMPLE_SERVER_ENVIROMENT production

    SSLEngine on
    SSLProtocol all -SSLv2 -SSLv3
    SSLHonorCipherOrder on
    SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS"

   SSLCertificateFile /etc/ssl/certs/apache/www.example.crt
   SSLCertificateKeyFile /etc/ssl/certs/apache/private.key
   SSLCertificateChainFile /etc/ssl/certs/apache/sub.class1.server.sha2.ca.pem

   ProxyPass /generator/wss wss://127.0.0.1:9002/
ProxyPassReverse /generator/wss wss://127.0.0.1:9002/
ProxyPreserveHost On
ProxyRequests Off
ProxyVia On

   DocumentRoot /opt/example/prod/public

   <Directory "/opt/example/prod/public">
       Order allow,deny
       AllowOverride All
       Allow from all 
       Require all granted
   </Directory>

   ErrorLog ${APACHE_LOG_DIR}/error.log
   CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Any idea why it is not working? Thanks

Dusan Plavak
  • 143
  • 6

1 Answers1

1

Well, so i do not know where exactly error was, but when I upgraded apache2 from 2.4.7 to 2.4.16 then it is working...

Dusan Plavak
  • 143
  • 6