# Qoder OTA HTTP File Distribution Service
# Server: 8.211.182.157
# Root: /var/www/ota

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;

    root /var/www/ota;
    index index.html;

    # OTA packages directory - enable directory listing
    location /packages/ {
        alias /var/www/ota/packages/;
        autoindex on;
        autoindex_exact_size off;
        autoindex_localtime on;
        autoindex_format html;
    }

    # Main location
    location / {
        try_files $uri $uri/ =404;
        autoindex on;
    }

    # Security headers
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-XSS-Protection "1; mode=block" always;

    # Logging
    access_log /var/log/nginx/ota_access.log;
    error_log /var/log/nginx/ota_error.log;
}

# ============================================================
# HTTPS placeholder (uncomment after obtaining domain and SSL certificate)
# ============================================================
# server {
#     listen 443 ssl http2;
#     listen [::]:443 ssl http2;
#     server_name your-domain.com;
#
#     ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
#     ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;
#     ssl_protocols TLSv1.2 TLSv1.3;
#     ssl_ciphers HIGH:!aNULL:!MD5;
#     ssl_prefer_server_ciphers on;
#
#     root /var/www/ota;
#     index index.html;
#
#     location /packages/ {
#         alias /var/www/ota/packages/;
#         autoindex on;
#         autoindex_exact_size off;
#         autoindex_localtime on;
#     }
#
#     location / {
#         try_files $uri $uri/ =404;
#         autoindex on;
#     }
# }
