Closed MindOnFire93 closed 5 years ago
I don't see serverSsl.listen()
in your example.
Try following a guide such as this one: https://aghassi.github.io/ssl-using-express-4/
Although for real-life scenarios I would recommend putting a reverse proxy (such as nginx or apache2) in front of the server to terminate the ssl connection.
Thank you.
Hello, I'm MindOnFire i need to open server using ssl https protocol i trying change the server dxirectives inside the bin.js like assigning separate port, all work, but ssl server over https don't reply, i using this same example:
!/usr/bin/env node
'use strict';
var STATIC_OPTIONS = { maxAge: 3600000 };
var fs = require('fs'); var https = require('https'); var privateKey = fs.readFileSync('server/crt/key.crt', 'utf8'); var certificate = fs.readFileSync('crt/crt.crt', 'utf8'); var credentials = {key: privateKey, cert: certificate}; var express = require('express'), http = require('http'), https = require('https'), path = require('path'), socket = require('./socket'), api = require('./') .use(express.static(path.join(dirname, '../dist'), STATIC_OPTIONS)) .use(express.static(path.join(__dirname, '../.tmp'), STATIC_OPTIONS)) .use(express.static(path.join(dirname, '../app'), STATIC_OPTIONS));
var server = http.createServer(api); var serverSsl = https.createServer(credentials, api); socket(server); var port = process.env.PORT || 20000; var portssl = process.env.PORT || 20001;
server.listen(port).on('error', function (e) { if (e.code !== 'EADDRINUSE' && e.code !== 'EACCES') { throw e; }
I don't know good node js so really idk where i wrong, and how to open the same service over https ssl, thanks in advance, Mind :)