Initial commit
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm index.php;
|
||||
|
||||
# 开启Gzip压缩,提升页面加载速度
|
||||
gzip on;
|
||||
gzip_min_length 1k;
|
||||
gzip_buffers 4 16k;
|
||||
gzip_http_version 1.1;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
|
||||
gzip_vary on;
|
||||
|
||||
# PHP解析配置
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass php:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
|
||||
# 优化PHP连接超时、缓冲区
|
||||
fastcgi_connect_timeout 60s;
|
||||
fastcgi_send_timeout 60s;
|
||||
fastcgi_read_timeout 60s;
|
||||
fastcgi_buffer_size 128k;
|
||||
fastcgi_buffers 4 128k;
|
||||
fastcgi_busy_buffers_size 256k;
|
||||
fastcgi_temp_file_write_size 256k;
|
||||
}
|
||||
|
||||
# 首页通用路由
|
||||
location / {
|
||||
try_files $uri $uri/;
|
||||
}
|
||||
|
||||
# API目录
|
||||
location /api/ {
|
||||
try_files $uri $uri/;
|
||||
}
|
||||
|
||||
# 静态资源长期缓存(本地static目录js/css/图片)
|
||||
location ~* \.(jpg|jpeg|png|gif|webp|ico)$ {
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, max-age=604800";
|
||||
access_log off;
|
||||
}
|
||||
location ~* \.(js|css|woff|woff2|ttf)$ {
|
||||
expires 3d;
|
||||
add_header Cache-Control "public, max-age=259200";
|
||||
access_log off;
|
||||
}
|
||||
|
||||
# 禁止访问缓存目录cache,防止外部直接下载缓存文件
|
||||
location ^~ /cache/ {
|
||||
deny all;
|
||||
return 403;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user