perf: add some config for website_default.conf (#9278)

Refs https://github.com/1Panel-dev/1Panel/issues/8837
This commit is contained in:
CityFun 2025-06-25 16:23:21 +08:00 committed by GitHub
parent 984985e650
commit 215c082a04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 7 deletions

View file

@ -182,8 +182,8 @@ func configDefaultNginx(website *model.Website, domains []model.WebsiteDomain, a
return err
}
configPath := GetSitePath(*website, SiteConf)
nginxContent := string(nginx_conf.WebsiteDefault)
config, err := parser.NewStringParser(nginxContent).Parse()
nginxContent := nginx_conf.GetWebsiteFile("website_default.conf")
config, err := parser.NewStringParser(string(nginxContent)).Parse()
if err != nil {
return err
}

View file

@ -9,9 +9,6 @@ import (
//go:embed ssl.conf
var SSL []byte
//go:embed website_default.conf
var WebsiteDefault []byte
//go:embed index.html
var Index []byte
@ -48,7 +45,7 @@ var Upstream []byte
//go:embed sse.conf
var SSE []byte
//go:embed *.json
//go:embed *.json *.conf
var websitesFiles embed.FS
func GetWebsiteFile(filename string) []byte {

View file

@ -15,9 +15,16 @@ server {
access_log /www/sites/domain/log/access.log main;
error_log /www/sites/domain/log/error.log;
location ~ ^/(\.user.ini|\.htaccess|\.git|\.env|\.svn|\.project|LICENSE|README.md){
return 404;
}
location ^~ /.well-known{
allow all;
root /usr/share/nginx/html;
}
if ( $uri ~ "^/\.well-known/.*\.(php|jsp|py|js|css|lua|ts|go|zip|tar\.gz|rar|7z|sql|bak)$" ) {
return 403;
}
}