mirror of
https://github.com/asapach/peerflix-server.git
synced 2026-04-25 14:45:50 +03:00
[GH-ISSUE #157] Hello, i need to open server using ssl https protocol #345
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 :)
@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/
@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.
@MindOnFire93 commented on GitHub (Oct 20, 2018):
Thank you.