sbs20 / scanservjs

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

run scanservjs in ssl #706

Open piyushgarg opened 6 months ago

piyushgarg commented 6 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 5 months ago

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