This commit is contained in:
Lukian LEIZOUR 2024-10-07 19:37:25 +01:00
parent afc5217d0a
commit 8ac3ef78b0
2 changed files with 18 additions and 18 deletions

View file

@ -6,7 +6,19 @@ services:
network: host
restart: always
image: joclud_api
ports:
- "3000:3000"
- "443:443"
container_name: joclud_api
expose:
- 80
networks:
- traefik
labels:
- "traefik.enable=true"
- "traefik.http.routers.joclud.rule=Host(`api.joclud.leizour.fr`)"
- "traefik.http.routers.joclud.entrypoints=websecure"
- "traefik.http.routers.joclud.tls=true"
- "traefik.http.routers.joclud.tls.certresolver=myresolver"
- "traefik.http.services.joclud.loadbalancer.server.port=80"
container_name: joclud_api
networks:
traefik:
external: true

View file

@ -8,7 +8,6 @@ const https = require("https");
require("dotenv").config();
const app = express();
const port = config.port || 3000;
app.use(express.json());
app.use(cookieParser());
@ -34,17 +33,6 @@ function loadRoutes(folderName) {
loadRoutes("api");
app.listen(port, () => {
console.log(`Server listening on http://localhost:${port}/`);
app.listen(80, () => {
console.log(`Server listening on http://localhost:80/`);
});
const privateKey = fs.readFileSync("./sslcert/privkey.pem", "utf8");
const certificate = fs.readFileSync("./sslcert/fullchain.pem", "utf8");
const credentials = { key: privateKey, cert: certificate };
const httpsServer = https.createServer(credentials, app);
httpsServer.listen(443, () => {
console.log("https server listening on port 443")
})