worker_processes auto;
events { worker_connections 1024; }

http {
  include       /etc/nginx/mime.types;
  default_type  application/octet-stream;
  sendfile      on;
  keepalive_timeout 65;
  gzip on;
  gzip_types text/plain text/css application/javascript application/json image/svg+xml;
  gzip_min_length 1024;

  server {
    listen 80 default_server;
    server_name _;

    root /usr/share/nginx/html;
    index index.html;

    auth_basic "Figma 模板库";
    auth_basic_user_file /etc/nginx/.htpasswd;

    # cache immutable assets
    location ~* \.(jpg|jpeg|png|gif|webp|svg|woff2?|ttf|eot)$ {
      expires 30d;
      add_header Cache-Control "public, immutable";
    }
    location ~* \.(css|js)$ {
      expires 7d;
    }
    location ~* \.json$ {
      add_header Cache-Control "no-cache";
    }

    location / {
      try_files $uri $uri/ =404;
    }
  }
}
