# Windows host nginx.conf — paste over
#   C:\tools\nginx-1.29.5\conf\nginx.conf
#
# :80  — LAN / 127.0.0.1 only (Mobinnet keeps public :80 for the modem)
# :443 — public https://wixur.ir  (router must forward 443 → this PC)
#
# Put Let's Encrypt PEMs in conf\ssl\ (win-acme --pemfilesname wixur):
#   ssl\wixur-chain.pem
#   ssl\wixur-key.pem
#
# After save: nginx -t   then restart nginx
#   curl.exe https://wixur.ir/health   →  healthy
# (curl to 127.0.0.1:443 fails name-check; cert is for wixur.ir)

#user  nobody;
worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;
    # Unlimited at http{} so a gitea.wixur.ir vhost can inherit it (Docker layers
    # 413 with 50M). App server blocks below cap uploads at 50M.
    client_max_body_size 0;

    # Shared proxy to Docker staging
    map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
    }

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  wixur.ir www.wixur.ir localhost 127.0.0.1;

        client_max_body_size 50M;

        location / {
            proxy_pass http://127.0.0.1:18088;
            proxy_http_version 1.1;
            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 300;
            proxy_connect_timeout 300;
        }
    }

    server {
        listen       443 ssl;
        listen       [::]:443 ssl;
        server_name  wixur.ir www.wixur.ir localhost 127.0.0.1;

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

        client_max_body_size 50M;

        location / {
            proxy_pass http://127.0.0.1:18088;
            proxy_http_version 1.1;
            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 300;
            proxy_connect_timeout 300;
        }
    }

    # Gitea + container registry (https://gitea.wixur.ir). Optional include —
    # copy windows-gitea.wixur.snippet.conf next to this file and uncomment:
    # include windows-gitea.wixur.snippet.conf;
}
