0

So I have a site that uses https and websockets and socket.io (with node.js). The websocket will initially try to connect directly

var socket = io('https://' + socket_ip_addr + ":8443",{'forceNew': true, 'secure': true});

Here is my socket.io code (works fine with direct connection)

var http = require('https')
var fs = require('fs');

var options = {
    key:    fs.readFileSync('../certs/ssl.key'),
    cert:   fs.readFileSync('../certs/ssl.crt'),
};
var app = http.createServer(options)
var io = require('socket.io').listen(app);
app.listen(8443);

This works perfectly fine, but some users might have that random port blocked, for whatever reason, so i have a fallback method that tries to use port 443 with an apache proxy.

var socket = io('https://' + socket_ip_addr,{'forceNew': true, 'secure': true});

apache settings:

<VirtualHost *:443>
    ServerName somewebsite.ca
    ServerAlias somewebsite.ca
    DocumentRoot /var/www/html

    SSLEngine on
    SSLCertificateFile ../certs/ssl.crt
    SSLCertificateKeyFile ../certs/ssl.key

    RewriteEngine on
    RewriteCond %{REQUEST_URI}  ^/socket.io            [NC]
    RewriteCond %{QUERY_STRING} transport=websocket    [NC]
    RewriteRule /(.*)           wss://localhost:8443/$1 [P,L]

    ProxyRequests off
    ProxyPass /socket.io/ https://localhost:8443/socket.io/
    ProxyPassReverse /socket.io/ https://localhost:8443/socket.io/
</VirtualHost>

I used to do this before i switched over to https, and everything worked fine. Now that i am trying to do it with https and wss, its giving me good ol' error 500 (internal server error)

My real question is this: how do i even begin to try and debug what is going wrong. Can i look at some headers somehow? Can i print some messages somewhere in the middle steps?

Thanks.

1 Answer 1

2

Alright.. I'm just dumb. I checked the apache logs and added some extra commands, now it works fine. Additional things include:

SSLProxyEngine on //apache log told me about this
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
RequestHeader set Front-End-Https "On"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.