# Fastest fix if you already have a gitea.wixur.ir server { } block: add only
#   client_max_body_size 0;
#   proxy_request_buffering off;
# inside that server (or its location /), then nginx -t && nginx -s reload.
# Do not add a second server_name gitea.wixur.ir — duplicate listen/ssl will fail.
#
# Full vhost (only if that host is not already in nginx.conf): paste inside http { }
# of C:\tools\nginx-1.29.5\conf\nginx.conf. Needs the $connection_upgrade map from
# windows-edge-http.conf.
#
# Certs: keep the ssl_certificate paths you already use for gitea.wixur.ir
# (the names below are placeholders).
#
# After save: nginx -t   then   nginx -s reload

server {
    listen       80;
    listen       [::]:80;
    server_name  gitea.wixur.ir;

    location /.well-known/acme-challenge/ {
        root html;
    }

    location / {
        return 301 https://$host$request_uri;
    }
}

server {
    listen       443 ssl;
    listen       [::]:443 ssl;
    server_name  gitea.wixur.ir;

    ssl_certificate      ssl/gitea-chain.pem;
    ssl_certificate_key  ssl/gitea-key.pem;
    ssl_protocols        TLSv1.2 TLSv1.3;

    # 0 = unlimited (Docker registry blob PUT)
    client_max_body_size 0;
    client_body_timeout 600s;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_request_buffering off;
        proxy_buffering off;
        proxy_set_header Host $host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        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 600;
        proxy_connect_timeout 60;
        proxy_send_timeout 600;
    }
}
