Самостоятельный хост Bitbucket с SSL с использованием Express - PullRequest
0 голосов
/ 08 апреля 2020

Я могу заставить bitbucket работать на localhost: 7990, но я хотел защитить его с помощью SSL, а также удалить порт из адреса. Когда я пытаюсь сделать это с помощью приведенного ниже кода и моего сервера узлов, я просто получаю ошибку «CANNOT GET /», если я иду на https://example.com. Хотя приложение bitbucket запущено.

// Dependencies
const fs = require('fs');
const path = require('path');
const http = require('http');
const https = require('https');
const express = require('express');
const express_force_ssl = require('express-force-ssl');
const app = express();

// Certificate
const privateKey = fs.readFileSync('/etc/letsencrypt/live/example.com/privkey.pem', 'utf8');
const certificate = fs.readFileSync('/etc/letsencrypt/live/example.com/fullchain.pem', 'utf8');
const ca = fs.readFileSync('/etc/letsencrypt/live/example.com/chain.pem', 'utf8');

const credentials = {
    key: privateKey,
    cert: certificate,
    ca: ca
};
app.use(express_force_ssl);

// Load main application
app.use(express.static(path.join(__dirname, '../../var/www/bitbucket/')));

// Starting both http & https servers
const httpServer = http.createServer(app);
const httpsServer = https.createServer(credentials, app);

httpServer.listen(80, (req,res) => {
  console.log('HTTPS Server running on port 80');
});

httpsServer.listen(443, (req, res) => {
    console.log('HTTPS Server running on port 443');
}); 
...