upstream django_stage {
    server 127.0.0.1:8002;
}

server {
    listen 80;
    server_name stage.crm-poizonstore.ru;
    return 301 https://$host$request_uri;
}

server {
    set $APP_HOME /var/www/poizonstore-stage;

    listen 443 ssl;
    server_name stage.crm-poizonstore.ru;
    charset utf-8;

    # === Add here SSL config ===
    ssl_certificate /etc/letsencrypt/live/crm-poizonstore.ru/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/crm-poizonstore.ru/privkey.pem;

    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

    # max upload size
    client_max_body_size 75M;   # adjust to taste

    # Django media
    location /media  {
        autoindex on;
        alias $APP_HOME/media;
    }

    location /static {
        autoindex on;
        alias $APP_HOME/assets;
    }

    location / {
        uwsgi_pass django_stage;
        uwsgi_read_timeout 300;
        keepalive_timeout 70;
        proxy_read_timeout 1200s;

        include /etc/nginx/uwsgi_params;
        include /etc/nginx/proxy_params;
    }

    location /flower/ {
        proxy_pass http://localhost:5556/flower/;
    }
}