HTTPSSSSSSSSSSSSSSSSS

This commit is contained in:
AdrienLSH 2024-05-15 15:28:29 +02:00
parent c0e8cd9501
commit 503fca16e1
3 changed files with 56 additions and 2 deletions

View File

@ -8,8 +8,6 @@ services:
image: django image: django
networks: networks:
- network - network
ports:
- "8000:8000"
container_name: django container_name: django
restart: always restart: always
env_file: .env env_file: .env
@ -36,6 +34,18 @@ services:
timeout: 5s timeout: 5s
retries: 5 retries: 5
nginx:
build: nginx/
image: nginx
networks:
- network
ports:
- '1443:443'
container_name: nginx
restart: always
depends_on:
- django
volumes: volumes:
db: db:

10
nginx/Dockerfile Normal file
View File

@ -0,0 +1,10 @@
FROM nginx
RUN apt-get update && apt-get -y install openssl
RUN openssl req -x509 -newkey rsa:4096 -days 365 -nodes \
-keyout /etc/ssl/private/bozopong.fr_key.pem \
-out /etc/ssl/certs/bozopong.fr_cert.pem -sha256 \
-subj "/C=FR/ST=Nouvelle Aquitaine/L=Angouleme/ \
O=42 Angouleme/CN=bozopong.fr"
COPY nginx.conf /etc/nginx/nginx.conf

34
nginx/nginx.conf Normal file
View File

@ -0,0 +1,34 @@
events {
worker_connections 1024;
}
http {
include mime.types;
sendfile on;
server {
listen 443 ssl;
server_name _;
ssl_certificate /etc/ssl/certs/bozopong.fr_cert.pem;
ssl_certificate_key /etc/ssl/private/bozopong.fr_key.pem;
location / {
proxy_pass http://django:8000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /ws/ {
proxy_pass http://django:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}
}
}