feat: migrate from HTTPS to HTTP and add Traefik configuration for reverse proxy
This commit is contained in:
parent
340bbd22b9
commit
c4df4ccc33
@ -19,4 +19,14 @@ services:
|
|||||||
- ./data:/usr/src/app/data
|
- ./data:/usr/src/app/data
|
||||||
- /usr/src/app/node_modules
|
- /usr/src/app/node_modules
|
||||||
|
|
||||||
|
labels:
|
||||||
|
- "traefik.enable=true"
|
||||||
|
- "traefik.http.routers.library-manager.entrypoints=https"
|
||||||
|
- "traefik.http.routers.library-manager.rule=Host(`library.ghost.tel`)"
|
||||||
|
- "traefik.http.routers.library-manager.tls.certresolver=http"
|
||||||
|
networks:
|
||||||
|
- web
|
||||||
|
- default
|
||||||
|
networks:
|
||||||
|
web:
|
||||||
|
external: true
|
||||||
14
index.js
14
index.js
@ -1,6 +1,6 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const https = require('https');
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const sqlite3 = require('sqlite3').verbose();
|
const sqlite3 = require('sqlite3').verbose();
|
||||||
@ -26,11 +26,6 @@ const { Op } = require('sequelize'); // Import Sequelize Operators
|
|||||||
const app = express();
|
const app = express();
|
||||||
const PORT = process.env.PORT || 3000;
|
const PORT = process.env.PORT || 3000;
|
||||||
|
|
||||||
// SSL certificate paths
|
|
||||||
const privateKey = fs.readFileSync(path.join(__dirname, 'server.key'), 'utf8');
|
|
||||||
const certificate = fs.readFileSync(path.join(__dirname, 'server.cert'), 'utf8');
|
|
||||||
|
|
||||||
const credentials = { key: privateKey, cert: certificate };
|
|
||||||
|
|
||||||
// Middleware to parse JSON bodies
|
// Middleware to parse JSON bodies
|
||||||
app.use(express.json()); // Use built-in body-parser for JSON
|
app.use(express.json()); // Use built-in body-parser for JSON
|
||||||
@ -824,11 +819,8 @@ app.put('/api/books/:id', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const httpsServer = https.createServer(credentials, app);
|
app.listen(PORT, () => {
|
||||||
|
console.log(`HTTP Server running on http://localhost:${PORT}`);
|
||||||
|
|
||||||
httpsServer.listen(PORT, () => {
|
|
||||||
console.log(`HTTPS Server running on https://localhost:${PORT}`);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/api/books-on-loan', async (req, res) => {
|
app.get('/api/books-on-loan', async (req, res) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user