https + volume
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
volumes:
|
volumes:
|
||||||
data:
|
pgdata:
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
transcendence:
|
transcendence:
|
||||||
@@ -12,7 +12,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
volumes:
|
volumes:
|
||||||
- data:/var/lib/postgresql/data/pg15/
|
- pgdata:/var/lib/postgresql
|
||||||
env_file:
|
env_file:
|
||||||
- ../.env
|
- ../.env
|
||||||
networks:
|
networks:
|
||||||
@@ -38,8 +38,7 @@ services:
|
|||||||
container_name: frontend
|
container_name: frontend
|
||||||
build: ./srcs/frontend/
|
build: ./srcs/frontend/
|
||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "8443:443"
|
||||||
- "8443:8443"
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
networks:
|
networks:
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
FROM node:20-alpine
|
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
|
WORKDIR /app
|
||||||
|
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import http from 'http';
|
import https from 'https';
|
||||||
|
import fs from 'fs';
|
||||||
import cors from 'cors';
|
import cors from 'cors';
|
||||||
import {Server} from 'socket.io';
|
import {Server} from 'socket.io';
|
||||||
import authRouter from './routes/auth.js';
|
import authRouter from './routes/auth.js';
|
||||||
@@ -13,7 +14,11 @@ import setupSocketIO from './services/socket.js';
|
|||||||
import avatarService from './services/avatar.js';
|
import avatarService from './services/avatar.js';
|
||||||
|
|
||||||
const app = express();
|
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,
|
const io = new Server(server,
|
||||||
{
|
{
|
||||||
cors:
|
cors:
|
||||||
|
|||||||
@@ -8,5 +8,5 @@ RUN apk add --no-cache openssl && \
|
|||||||
-addext "subjectAltName=DNS:localhost,IP:127.0.0.1"
|
-addext "subjectAltName=DNS:localhost,IP:127.0.0.1"
|
||||||
COPY src /usr/share/nginx/html
|
COPY src /usr/share/nginx/html
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
EXPOSE 8080 8443
|
EXPOSE 443
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
@@ -1,13 +1,9 @@
|
|||||||
server {
|
server {
|
||||||
listen 8080;
|
listen 443 ssl;
|
||||||
return 301 https://$host:8443$request_uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
server {
|
|
||||||
listen 8443 ssl;
|
|
||||||
|
|
||||||
ssl_certificate /etc/nginx/ssl/cert.pem;
|
ssl_certificate /etc/nginx/ssl/cert.pem;
|
||||||
ssl_certificate_key /etc/nginx/ssl/key.pem;
|
ssl_certificate_key /etc/nginx/ssl/key.pem;
|
||||||
|
error_page 497 =301 https://$host:8443$request_uri;
|
||||||
|
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
index index.html;
|
index index.html;
|
||||||
@@ -19,7 +15,8 @@ server {
|
|||||||
|
|
||||||
# Backend API
|
# Backend API
|
||||||
location /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 Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-Proto https;
|
proxy_set_header X-Forwarded-Proto https;
|
||||||
@@ -27,7 +24,8 @@ server {
|
|||||||
|
|
||||||
# Socket.IO WebSocket proxying
|
# Socket.IO WebSocket proxying
|
||||||
location /socket.io/ {
|
location /socket.io/ {
|
||||||
proxy_pass http://backend:3001;
|
proxy_pass https://backend:3001;
|
||||||
|
proxy_ssl_verify off;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection "upgrade";
|
proxy_set_header Connection "upgrade";
|
||||||
@@ -40,9 +38,10 @@ server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
location /avatar/ {
|
location /avatar/ {
|
||||||
proxy_pass http://backend:3001/avatar/;
|
proxy_pass https://backend:3001/avatar/;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
|
proxy_ssl_verify off;
|
||||||
proxy_hide_header Content-Type;
|
proxy_hide_header Content-Type;
|
||||||
add_header Cache-Control "public, max-age=3600";
|
add_header Cache-Control "public, max-age=3600";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user