修改nginx模板
This commit is contained in:
@@ -1,33 +1,66 @@
|
||||
package types
|
||||
|
||||
const NGINX_CONF_TMP = `server {
|
||||
const NGINX_CONF_TMP = `# Nginx 配置 - {{.SiteName}}
|
||||
# 生成时间: {{.CreateTime}}
|
||||
|
||||
server {
|
||||
listen {{.Port}};
|
||||
server_name {{.Host}};
|
||||
root "{{.FilePath}}";
|
||||
index {{.Index}};
|
||||
|
||||
# 字符编码
|
||||
charset utf-8;
|
||||
|
||||
# 访问日志
|
||||
access_log logs/{{.SiteName}}_access.log combined;
|
||||
error_log logs/{{.SiteName}}_error.log warn;
|
||||
|
||||
# 文件上传限制
|
||||
client_max_body_size 50m;
|
||||
|
||||
# Gzip 压缩
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json;
|
||||
|
||||
# 静态文件缓存
|
||||
location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot)$ {
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# 主路由
|
||||
location / {
|
||||
index index.php index.html;
|
||||
error_page 400 /error/400.html;
|
||||
error_page 403 /error/403.html;
|
||||
error_page 404 /error/404.html;
|
||||
error_page 500 /error/500.html;
|
||||
error_page 501 /error/501.html;
|
||||
error_page 502 /error/502.html;
|
||||
error_page 503 /error/503.html;
|
||||
error_page 504 /error/504.html;
|
||||
error_page 505 /error/505.html;
|
||||
error_page 506 /error/506.html;
|
||||
error_page 507 /error/507.html;
|
||||
error_page 509 /error/509.html;
|
||||
error_page 510 /error/510.html;
|
||||
try_files $uri $uri/ /{{.Index}};
|
||||
autoindex off;
|
||||
}
|
||||
location ~ \.php(.*)$ {
|
||||
|
||||
# 错误页面
|
||||
error_page 404 /404.html;
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root html;
|
||||
}
|
||||
|
||||
# 禁止访问隐藏文件
|
||||
location ~ /\. {
|
||||
deny all;
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
}
|
||||
|
||||
# PHP 支持(如果需要)
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
|
||||
include fastcgi_params;
|
||||
}
|
||||
|
||||
# 禁止访问备份文件
|
||||
location ~* \.(bak|config|sql|fla|psd|ini|log|sh|inc|swp|dist)$ {
|
||||
deny all;
|
||||
}
|
||||
}`
|
||||
|
||||
Reference in New Issue
Block a user