I previously had a Socket.io script working perfectly on http, but updating to https violated it. I installed the certificate on the server, but no luck. Code to configure the server:
var https = require('https'), fs = require('fs'); var options = { key: fs.readFileSync('/etc/nginx/ssl/default/54082/server.key'), cert: fs.readFileSync('/etc/nginx/ssl/default/54082/server.crt') }; var app = https.createServer(options); var io = require('socket.io').listen(app);
However, the page cannot connect to it in a web browser, and the response of the server responded with a status of 502 (Bad Gateway)
displayed on the console.
Any ideas on if the script setting is incorrect? Or something in setting up Nginx?
Thank you very much
Edit: The front-end code that I use to connect is:
<script type="text/javascript" src="https://socket.example.com/socket.io/socket.io.js"></script> <script> var io = io('https://socket.example.com', { secure: true }); </script>
Edit :: Nginx configuration:
# FORGE CONFIG (DOT NOT REMOVE!) include forge-conf/socket.example.co.uk/before/*; server { listen 443 ssl; server_name socket.example.co.uk; root /home/forge/socket.example.co.uk;
source share