# Nginx config untuk webg.my
# Certbot akan tambah blok SSL (port 443) secara automatik.

server {
    listen 80;
    listen [::]:80;
    server_name webg.my www.webg.my;

    root /var/www/webg/public;
    index index.html index.htm;

    # --- PILIHAN A: Static site (default) ---
    # $uri.html membolehkan URL bersih tanpa .html (cth. /harga -> harga.html).
    # Nota: config live di /etc/nginx/sites-available/webg.my dipatch secara
    # idempotent oleh deploy/deploy.sh (fail ini rujukan untuk setup baru).
    location / {
        try_files $uri $uri/ $uri.html =404;
    }

    # --- PILIHAN B: App Node.js/Python di port 3000 ---
    # Uncomment blok bawah & komen blok "location /" di atas jika
    # app anda berjalan sebagai server (Express, Next.js, Flask, dll.)
    #
    # location / {
    #     proxy_pass http://127.0.0.1:3000;
    #     proxy_http_version 1.1;
    #     proxy_set_header Upgrade $http_upgrade;
    #     proxy_set_header Connection 'upgrade';
    #     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_cache_bypass $http_upgrade;
    # }

    # Sekat akses ke fail sensitif
    location ~ /\.(git|env) {
        deny all;
        return 404;
    }
}
