upstream innerdjango {
    server backend:8001;
}

upstream innerreact {
    server frontend:3001;
}

server {
    listen 8001 ssl;
    ssl_certificate /etc/ssl/private/local-cert.pem;
    ssl_certificate_key /etc/ssl/private/local-key.pem;
    server_name localhost;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_pass http://innerdjango;
        proxy_redirect default;
    }
    location /static/ {
        alias /var/www/static/;
    }
    location /media/ {
        alias /var/www/media/;
   }
}

server {
    listen 3001 ssl;
    ssl_certificate /etc/ssl/private/local-cert.pem;
    ssl_certificate_key /etc/ssl/private/local-key.pem;
    server_name localhost;
    
    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_pass http://innerreact;
        proxy_redirect default;
    }
}