upstream django {
    server backend-django:8001;
}


server {
 
    listen       80;
    #listen  [::]:80;
    server_name  localhost;
 
    proxy_read_timeout      7200;
    proxy_connect_timeout   7200;
    proxy_send_timeout      7200;
 
    # backend-django #1
    location ^~ /staticfiles/ {
        alias staticfiles/;
    }


    # backend-django #2
    location ~ ^/(api|accounts|admin)/? {
        proxy_pass http://django;
        proxy_set_header Host $host;
        proxy_redirect off;
    }
 
    # frontend-react
    location / {
        root /usr/share/nginx/html/static/frontend;
        index  index.html index.htm;
        try_files $uri $uri/ /index.html;
        gzip on;
        gzip_comp_level 3;
        gzip_vary on;
        gzip_types application/javascript application/json application/xml image/bmp image/jpeg image/gif image/png image/svg+xml text/css text/html text/plain;
    }
}
