[GH-ISSUE #157] Hello, i need to open server using ssl https protocol #345

Closed
opened 2026-03-15 03:05:33 +03:00 by kerem · 3 comments
Owner

Originally created by @MindOnFire93 on GitHub (Oct 17, 2018).
Original GitHub issue: https://github.com/asapach/peerflix-server/issues/157

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 :)

Originally created by @MindOnFire93 on GitHub (Oct 17, 2018). Original GitHub issue: https://github.com/asapach/peerflix-server/issues/157 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 :)
kerem 2026-03-15 03:05:33 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@asapach commented on GitHub (Oct 17, 2018):

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/

<!-- gh-comment-id:430560394 --> @asapach commented on GitHub (Oct 17, 2018): 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/
Author
Owner

@asapach commented on GitHub (Oct 17, 2018):

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.

<!-- gh-comment-id:430561257 --> @asapach commented on GitHub (Oct 17, 2018): 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.
Author
Owner

@MindOnFire93 commented on GitHub (Oct 20, 2018):

Thank you.

<!-- gh-comment-id:431624144 --> @MindOnFire93 commented on GitHub (Oct 20, 2018): Thank you.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/peerflix-server#345
No description provided.