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