From 559458a38cbb337b6ddd6187dc3f896cfcdd882c Mon Sep 17 00:00:00 2001 From: William Di Luigi Date: Sun, 3 Nov 2024 22:16:35 +0000 Subject: [PATCH] Add deployment-specific files --- .gitignore | 1 + nginx/itacpc | 62 ++++++++++++++++++++++++++++++++++++++++ systemd/gunicorn.service | 17 +++++++++++ systemd/gunicorn.socket | 8 ++++++ 4 files changed, 88 insertions(+) create mode 100644 nginx/itacpc create mode 100644 systemd/gunicorn.service create mode 100644 systemd/gunicorn.socket diff --git a/.gitignore b/.gitignore index 3c2dbd9..e172ada 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ db.sqlite3 __pycache__/ old_app/ .env* +/static diff --git a/nginx/itacpc b/nginx/itacpc new file mode 100644 index 0000000..c609957 --- /dev/null +++ b/nginx/itacpc @@ -0,0 +1,62 @@ +server { + server_name teams24.itacpc.it; + + location = /favicon.ico { access_log off; log_not_found off; } + location /static/ { + root /home/itacpc/teams; + } + + location / { + include proxy_params; + proxy_pass http://unix:/run/gunicorn.sock; + } + + listen 443 ssl; # managed by Certbot + ssl_certificate /etc/letsencrypt/live/teams24.itacpc.it-0001/fullchain.pem; # managed by Certbot + ssl_certificate_key /etc/letsencrypt/live/teams24.itacpc.it-0001/privkey.pem; # managed by Certbot + include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot + + + +} +server { + if ($host = teams.itacpc.it) { + return 301 https://itacpc.it/; + } + server_name teams.itacpc.it; + + listen 443 ssl; # managed by Certbot + ssl_certificate /etc/letsencrypt/live/teams24.itacpc.it-0001/fullchain.pem; # managed by Certbot + ssl_certificate_key /etc/letsencrypt/live/teams24.itacpc.it-0001/privkey.pem; # managed by Certbot + include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot + +} + +server { + if ($host = teams24.itacpc.it) { + return 301 https://$host$request_uri; + } # managed by Certbot + + + listen 80; + server_name teams24.itacpc.it; + return 404; # managed by Certbot + + +} + +server { + if ($host = teams.itacpc.it) { + return 301 https://$host$request_uri; + } # managed by Certbot + + + + listen 80; + server_name teams.itacpc.it; + return 404; # managed by Certbot + + +} \ No newline at end of file diff --git a/systemd/gunicorn.service b/systemd/gunicorn.service new file mode 100644 index 0000000..35ebc76 --- /dev/null +++ b/systemd/gunicorn.service @@ -0,0 +1,17 @@ +[Unit] +Description=gunicorn daemon +Requires=gunicorn.socket +After=network.target + +[Service] +User=itacpc +Group=www-data +WorkingDirectory=/home/itacpc/teams +ExecStart=/home/itacpc/.local/share/virtualenvs/teams-_GRcvIg0/bin/gunicorn \ + --access-logfile - \ + --workers 3 \ + --bind unix:/run/gunicorn.sock \ + itacpc.wsgi:application + +[Install] +WantedBy=multi-user.target diff --git a/systemd/gunicorn.socket b/systemd/gunicorn.socket new file mode 100644 index 0000000..9283699 --- /dev/null +++ b/systemd/gunicorn.socket @@ -0,0 +1,8 @@ +[Unit] +Description=gunicorn socket + +[Socket] +ListenStream=/run/gunicorn.sock + +[Install] +WantedBy=sockets.target