sbs20 / scanservjs

SANE scanner nodejs web ui
https://sbs20.github.io/scanservjs/
GNU General Public License v2.0
766 stars 145 forks source link

run scanservjs in ssl #706

Open piyushgarg opened 11 months ago

piyushgarg commented 11 months ago

This is more of a documentation point to be added as I was not able to find how to run scanserv in https/ssl certificate. Not very good at node paradigm, so please change. Edit server.js

#!/usr/bin/env node

const fs = require('fs');
const https = require('https')
const options = {
        cert: fs.readFileSync('/usr/lib/scanservjs/config/fullchain.pem'),
        key: fs.readFileSync('/usr/lib/scanservjs/config/privkey.pem')
};

const express = require('express');
const application = require('./application');
const ExpressConfigurer = require('./express-configurer');
const config = application.config();
const app = express();

ExpressConfigurer.with(app)
  .encoding()
  .statics()
  .basicAuth()
  .swagger()
  .endpoints();

const sslServer = https.createServer(options, app);
        sslServer.listen(config.port, () => {
})

sslServer.setTimeout(config.timeout);
Leone25 commented 10 months ago

it'd be probably better to just use a reverse proxy like nginx for that