limit_req_zone $binary_remote_addr zone=imprint_api:10m rate=12r/m;
limit_req_status 429;

server {
    listen 80;
    server_name _;
    client_max_body_size 64k;

    location /api/ {
        limit_req zone=imprint_api burst=5 nodelay;
        proxy_pass http://app:8791;
        proxy_http_version 1.1;
        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_connect_timeout 10s;
        proxy_read_timeout 110s;
        proxy_send_timeout 110s;
    }

    location / {
        proxy_pass http://app:8791;
        proxy_http_version 1.1;
        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_read_timeout 30s;
    }
}
