server { listen 80; server_name localhost; # Thư mục gốc chứa mã nguồn website trong container root /usr/share/nginx/html; index index.html index.htm; add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "DENY" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; add_header Permissions-Policy "camera=(), geolocation=(), microphone=()" always; add_header Strict-Transport-Security "max-age=31536000" always; # Cấu hình nén để website tải nhanh hơn gzip on; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; gzip_min_length 1000; location = /sitemap.xml { types { } default_type application/xml; charset utf-8; charset_types application/xml; try_files $uri =404; } # Xử lý các request chính location / { try_files $uri $uri/ =404; } # Tối ưu cache cho các file tĩnh (hình ảnh, CSS, JS) để tăng tốc độ tải trang location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf)$ { expires 30d; add_header Cache-Control "public, no-transform"; add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "DENY" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; add_header Permissions-Policy "camera=(), geolocation=(), microphone=()" always; add_header Strict-Transport-Security "max-age=31536000" always; } # Trang lỗi tùy chỉnh (tùy chọn) error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }