events {}

http {
    upstream backend {
        server backend-b:8000;
    }

    server {

        listen 8080 ssl;
        server_name localhost;

        ssl_certificate /etc/nginx/nginx.crt;
        ssl_certificate_key /etc/nginx/nginx.key;

        location /api {
            #proxy_set_header X-Forwarded-For "$http_x_forwarded_for, $realip_remote_addr";
            proxy_set_header Host $host:$server_port;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Host $host:$server_port;
            proxy_set_header X-Forwarded-Port $server_port;
            proxy_pass http://backend;
        }

        location /auth {
            #proxy_set_header X-Forwarded-For "$http_x_forwarded_for, $realip_remote_addr";
            proxy_set_header Host $host:$server_port;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Host $host:$server_port;
            proxy_set_header X-Forwarded-Port $server_port;
            proxy_pass http://backend;
        }

        location /docs {
            proxy_pass http://backend/docs;
        }

        location /static {
            proxy_pass http://backend/static;
        }
    }
}