Подключение certbot

This commit is contained in:
zakhy 2024-08-06 11:19:15 +07:00
parent fb56ba188d
commit 4f68b75885
4 changed files with 54 additions and 15 deletions

24
README.md Normal file
View File

@ -0,0 +1,24 @@
### Сервер отчетов
#### Развертывание
1. Клонировать репозиторий
```bash
git clone http://git.hronos.su:8080/sabron/repcofkk.git
```
2. Запустить compose
```bash
docker-compose up -d
```
3. Создать суперпользователя
```bash
docker compose exec web python manage.py createsuperuser
```
4. Заполнить переменные в админке
5. Перезапустить сервис `celery` и `gunicorn`

View File

@ -1,11 +0,0 @@
#!/bin/sh
pip install -r req.txt
python ./manage.py migrate --no-input
python ./manage.py collectstatic --no-input
DJANGO_SUPERUSER_PASSWORD=$SUPER_USER_PASSWORD python ./manage.py createsuperuser --username $SUPER_USER_NAME --email $SUPER_USER_EMAIL --noinput
gunicorn ./repcofkk.wsgi:application --bind 0.0.0.0:8000

View File

@ -24,13 +24,22 @@ services:
nginx:
build: ./nginx
volumes:
- static_volume:/home/app/web/static/
- ./certbot/conf:/etc/letsencrypt
- ./certbot/www:/var/www/certbot
ports:
- '80:80'
- "80:80"
- "443:443"
depends_on:
web:
condition: service_started
certbot:
image: certbot/certbot
volumes:
- static_volume:/home/app/web/static/
- ./certbot/conf:/etc/letsencrypt
- ./certbot/www:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
celery:
build: ./app

View File

@ -3,8 +3,26 @@ upstream gunicorn {
}
server {
listen 80;
server_name rp.cofkk.ru;
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
server_name rp.cofkk.ru;
ssl_certificate /etc/letsencrypt/live/rp.cofkk.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/rp.cofkk.ru/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
location / {
proxy_pass http://gunicorn;
@ -16,5 +34,4 @@ server {
location /static/ {
alias /home/app/web/static/;
}
}