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