https + volume

This commit is contained in:
Georges-Leonard Prunet
2026-03-31 14:21:11 +02:00
parent e1573ba9f0
commit 41612f5d39
5 changed files with 27 additions and 16 deletions
+3 -4
View File
@@ -1,5 +1,5 @@
volumes:
data:
pgdata:
networks:
transcendence:
@@ -12,7 +12,7 @@ services:
ports:
- "5432:5432"
volumes:
- data:/var/lib/postgresql/data/pg15/
- pgdata:/var/lib/postgresql
env_file:
- ../.env
networks:
@@ -38,8 +38,7 @@ services:
container_name: frontend
build: ./srcs/frontend/
ports:
- "8080:8080"
- "8443:8443"
- "8443:443"
depends_on:
- backend
networks:
+8
View File
@@ -1,5 +1,13 @@
FROM node:20-alpine
RUN apk add --no-cache openssl
RUN mkdir -p /etc/backend/.ssl
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /etc/backend/.ssl/key.pem \
-out /etc/backend/.ssl/cert.pem \
-subj "/CN=localhost" \
-addext "subjectAltName=DNS:localhost,IP:127.0.0.1"
WORKDIR /app
COPY package*.json ./
+7 -2
View File
@@ -1,5 +1,6 @@
import express from 'express';
import http from 'http';
import https from 'https';
import fs from 'fs';
import cors from 'cors';
import {Server} from 'socket.io';
import authRouter from './routes/auth.js';
@@ -13,7 +14,11 @@ import setupSocketIO from './services/socket.js';
import avatarService from './services/avatar.js';
const app = express();
const server = http.createServer(app);
const httpsOptions = {
key: fs.readFileSync('/etc/backend/.ssl/key.pem'),
cert: fs.readFileSync('/etc/backend/.ssl/cert.pem')
};
const server = https.createServer(httpsOptions, app);
const io = new Server(server,
{
cors:
+1 -1
View File
@@ -8,5 +8,5 @@ RUN apk add --no-cache openssl && \
-addext "subjectAltName=DNS:localhost,IP:127.0.0.1"
COPY src /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 8080 8443
EXPOSE 443
CMD ["nginx", "-g", "daemon off;"]
+8 -9
View File
@@ -1,13 +1,9 @@
server {
listen 8080;
return 301 https://$host:8443$request_uri;
}
server {
listen 8443 ssl;
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/cert.pem;
ssl_certificate_key /etc/nginx/ssl/key.pem;
error_page 497 =301 https://$host:8443$request_uri;
root /usr/share/nginx/html;
index index.html;
@@ -19,7 +15,8 @@ server {
# Backend API
location /api/ {
proxy_pass http://backend:3001;
proxy_pass https://backend:3001;
proxy_ssl_verify off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
@@ -27,7 +24,8 @@ server {
# Socket.IO WebSocket proxying
location /socket.io/ {
proxy_pass http://backend:3001;
proxy_pass https://backend:3001;
proxy_ssl_verify off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
@@ -40,9 +38,10 @@ server {
}
location /avatar/ {
proxy_pass http://backend:3001/avatar/;
proxy_pass https://backend:3001/avatar/;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_ssl_verify off;
proxy_hide_header Content-Type;
add_header Cache-Control "public, max-age=3600";
}