server { listen 80; server_name localhost; # Direktori tempat file index.html dan assets berada root /usr/share/nginx/html; index index.html; # Mengaktifkan kompresi gzip untuk aset teks gzip on; gzip_types text/css application/javascript image/svg+xml; # Konfigurasi untuk uji Download location = /downloading { # Menonaktifkan pencatatan log untuk menghindari polusi berkas log access_log off; # Konfigurasi CORS add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, HEAD' always; add_header 'Access-Control-Allow-Headers' 'Content-Type, X-Requested-With' always; # Hindari penyimpanan cache agar pengukuran bandwidth akurat add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, max-age=0' always; try_files /downloading =404; } # Konfigurasi untuk mendapatkan IP client location = /getIP { access_log off; default_type text/plain; add_header 'Access-Control-Allow-Origin' '*' always; return 200 $remote_addr; } # Konfigurasi untuk uji Upload location = /upload { # Menonaktifkan pencatatan log access_log off; # Konfigurasi CORS add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, HEAD' always; add_header 'Access-Control-Allow-Headers' 'Content-Type, X-Requested-With' always; # Batasan ukuran payload upload (30MB+ untuk kebutuhan speedtest) client_max_body_size 50m; # Selalu kembalikan 200 OK untuk metode POST (agar upload speedtest berhasil) if ($request_method = POST) { return 200; } # Selalu kembalikan 200 OK untuk metode OPTIONS (Preflight request) if ($request_method = OPTIONS) { return 200; } try_files /upload =200; } }