Files

53 lines
1.2 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
server {
listen 80;
server_name _;
root /var/www/html;
index index.html;
charset utf-8;
sendfile on;
tcp_nopush on;
client_max_body_size 200m;
server_tokens off;
# 禁止点开隐藏文件/目录及运行日志
location ~ /\. {
deny all;
}
# 静态资源长缓存(uploads/css/js/libs)
location ~* \.(?:css|js|png|jpg|jpeg|gif|svg|ico|woff2?)$ {
expires 7d;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
# 上传目录允许写入(由 php-fpm 侧保证写入者权限)
location /static/uploads {
access_log off;
expires 30d;
try_files $uri =404;
}
# PHP 交给 php-fpm
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass app:9000;
fastcgi_index index.php;
fastcgi_read_timeout 300;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
}
# 其余静态页面
location / {
try_files $uri $uri/ =404;
}
error_page 404 =404 /index.html;
gzip on;
gzip_types text/plain text/css application/json application/javascript image/svg+xml;
}