We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The restAPI must be upgraded from HTTP to HTTPS, as the webapp consuming its service is working on HTTPS.
The text was updated successfully, but these errors were encountered:
restapi/server.js
var fs = require('fs'); var https = require('https'); const express = require('express'); const path = require('path'); const cors = require("cors"); const bp = require("body-parser"); const api = require("./api"); var app = express(); const port = 5000; const portHttps = 5443; //Load certificates var privateKey = fs.readFileSync('claves/privkey.pem'); var certificate = fs.readFileSync('claves/fullchain.pem'); var credentials = {key: privateKey, cert: certificate}; //This will make sure that we will serve everything through https app.all('*', function(req, res, next){ if (req.secure) { return next(); } res.redirect('https://'+req.hostname + ":" + portHttps + req.url); }); const metricsMiddleware: RequestHandler = promBundle({ includeMethod: true }); app.use(metricsMiddleware); app.use(cors()); app.use(bp.json()); app.use("/api", api) const mongoose = require("mongoose") const db_uri = require("./settings"); const uri: string = db_uri; const options = { useNewUrlParser: true, useUnifiedTopology: true}; mongoose.connect(uri, options).then( () => console.log("Database is listening")).catch((error: Error) => console.log("Error while connecting to the database:" + error)) app.listen(port, ():void => { console.log('Restapi listening on '+ port); }).on("error",(error:Error)=>{ console.error('Error occured: ' + error.message); }); var httpsServer = https.createServer(credentials, app); httpsServer.listen(portHttps, (): void => { console.log("Restapi listening on " + portHttps); }) .on("error", (error: Error) => { console.error("Error occured: " + error.message); });
restapi/Dockerfile: change the cmd line for this:
CMD node server.js
docker-compose-deploy.yml
version: '3.5' services: restapi: image: ghcr.io/arquisoft/lomap_en3a/restapi:latest volumes: - /etc/letsencrypt/live/lomapen3a.cloudns.ph/privkey.pem:/app/claves/privkey.pem - /etc/letsencrypt/live/lomapen3a.cloudns.ph/fullchain.pem:/app/claves/fullchain.pem ports: - "5000:5000" - "5443:5443" webapp: image: ghcr.io/arquisoft/lomap_en3a/webapp:latest volumes: - /etc/letsencrypt/live/lomapen3a.cloudns.ph/privkey.pem:/app/claves/privkey.pem - /etc/letsencrypt/live/lomapen3a.cloudns.ph/fullchain.pem:/app/claves/fullchain.pem ports: - "443:443" depends_on: - restapi
Sorry, something went wrong.
uo282892
Pelayo-Reguera
Successfully merging a pull request may close this issue.
The restAPI must be upgraded from HTTP to HTTPS, as the webapp consuming its service is working on HTTPS.
The text was updated successfully, but these errors were encountered: