30 lines
921 B
Nginx Configuration File
30 lines
921 B
Nginx Configuration File
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;
|
|
|
|
# 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;
|
|
|
|
# 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";
|
|
}
|
|
|
|
# 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;
|
|
}
|
|
} |