server {
    listen 80;

    # Redirect all HTTP requests to HTTPS
    return 301 https://$host$request_uri;
}

server {

    listen 443 ssl;

    # Path to SSL certificate and key
    ssl_certificate /mnt/data/certs/barix.pem;
    ssl_certificate_key /mnt/data/certs/barix.pem;

    # Security settings (optional, but recommended)

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    ssl_ciphers HIGH:!aNULL:!MD5;

    # Upload files max size limit
    client_max_body_size 256M;

    location /api/paging/v1 {
        proxy_pass http://localhost:4000;      
        proxy_set_header Host $host; 
        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 requests to Flask app running on Gunicorn
    location / {
        proxy_pass http://localhost:5000;
        proxy_set_header Host $host;
        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;
    }
}
