Skip to content
beucismis edited this page Jun 18, 2023 · 6 revisions

Generating secrets with OpenSSL

openssl rand -base64 -hex 32

Generating certificate with Certbot

certbot --nginx -d example.com

Nginx config file (/etc/nginx/sites-available/ozgursozluk)

server {
    listen 80;
    server_name example.com www.example.com;
    return 301 https://$host$request_uri;

    location / {
        proxy_pass http://127.0.0.1:8000;
    }
}


server {
    listen 443 ssl;
    server_name example.com www.example.com;

    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/example.com/fullchain.pem;

    location / {
        proxy_pass http://127.0.0.1:8000;
    }
}

Systemd service file (/etc/systemd/system/ozgursozluk.service)

[Unit]
After=network.target
Description=ozgursozluk service

[Service]
User=user
Group=www-data
ExecStart=gunicorn ozgursozluk:app -w 5 --threads 2

[Install]
WantedBy=multi-user.target
Clone this wiki locally