static
server {
listen 80;
server_name example.com;
gzip on;
gzip_types text/plain text/css application/json application/javascript;
root /var/www/html;
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}工具说明
線上 Nginx 設定產生器,支援靜態檔案服務、反向代理、HTTPS 重定向、負載均衡等場景,一鍵產生 nginx.conf 設定程式碼。
nginxconfig配置反向代理httpsweb server