# 本机 Nginx 只提供 HTTP（端口 80），不在本机终结 HTTPS：
# 证书由“总出口”（线上边缘网关）终结，网关把 https://videoservice.d1kt.cn
# 映射到本机内网 IP 的 80 端口，以 HTTP 回源。本机不需要证书，也不要监听 443。

server {
    listen 80;
    server_name videoservice.d1kt.cn;

    client_max_body_size 12g;
    client_body_timeout 7200s;
    send_timeout 7200s;

    location / {
        proxy_pass http://127.0.0.1:8000;
        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;
        # 透传边缘网关标记的原始协议（https）；若网关不设置该头，可改回 $scheme
        proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
        proxy_request_buffering off;
        proxy_read_timeout 7200s;
        proxy_send_timeout 7200s;
    }

    location ~ "^/api/v1/videos/[0-9a-fA-F]{64}/content$" {
        proxy_pass http://127.0.0.1:8000;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header Range $http_range;
        proxy_set_header If-Range $http_if_range;
        proxy_force_ranges on;
        proxy_buffering off;
    }
}
