server { listen 80; server_name cdn.urmic.org; # Redirect HTTP to HTTPS return 301 https://$host$request_uri; } server { listen 443 ssl http2; server_name cdn.urmic.org; # SSL settings (use certbot or your provider) ssl_certificate /etc/letsencrypt/live/cdn.urmic.org/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/cdn.urmic.org/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; if ($request_method !~ ^(GET|HEAD|POST|OPTIONS)$) { return 444; } # Root CDN content root /var/www/cdn.urmic.org; index index.html; # Rate Limiting (Anti-DDoS) limit_req zone=req_limit_per_ip burst=10 nodelay; # Connection limiting limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m; limit_conn conn_limit_per_ip 10; # Basic 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; add_header Referrer-Policy "no-referrer-when-downgrade"; add_header Content-Security-Policy "default-src 'self' cdn.urmic.org;"; # Protect against large request bodies client_max_body_size 5M; # Logging access_log /var/log/nginx/cdn.urmic.org.access.log; error_log /var/log/nginx/cdn.urmic.org.error.log warn; # Cache Control (for static CDN files) location ~* \.(jpg|jpeg|png|gif|ico|css|js|woff|woff2|ttf|svg|eot|mp4|webm|ogg|avi)$ { expires 30d; access_log off; add_header Cache-Control "public, no-transform"; } # General static file serving location / { try_files $uri $uri/ =404; } # Deny access to hidden files location ~ /\. { deny all; } }