From 503fca16e1dcfe4fd1680a9edce6af6de9a2bdca Mon Sep 17 00:00:00 2001 From: AdrienLSH Date: Wed, 15 May 2024 15:28:29 +0200 Subject: [PATCH] HTTPSSSSSSSSSSSSSSSSS --- docker-compose.yml | 14 ++++++++++++-- nginx/Dockerfile | 10 ++++++++++ nginx/nginx.conf | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 nginx/Dockerfile create mode 100644 nginx/nginx.conf diff --git a/docker-compose.yml b/docker-compose.yml index fbeba5e..e866394 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,8 +8,6 @@ services: image: django networks: - network - ports: - - "8000:8000" container_name: django restart: always env_file: .env @@ -36,6 +34,18 @@ services: timeout: 5s retries: 5 + nginx: + build: nginx/ + image: nginx + networks: + - network + ports: + - '1443:443' + container_name: nginx + restart: always + depends_on: + - django + volumes: db: diff --git a/nginx/Dockerfile b/nginx/Dockerfile new file mode 100644 index 0000000..1e5a1e1 --- /dev/null +++ b/nginx/Dockerfile @@ -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 diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..09bc4c4 --- /dev/null +++ b/nginx/nginx.conf @@ -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; + + } + } +}