fix(converter): 没有 root/alias/try_files 的 location 继承 server root
- classifyLocation 增加 serverRoot 参数 - 当 location 没有显式 root/alias/try_files 但有 server 级别 root 时,分类为 static - 正则 location 正确继承 server root 并设置 location_type Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
07acfad146
commit
02265331d4
@ -254,7 +254,7 @@ func convertServerBlock(d *Directive, upstreams map[string]*upstreamInfo, result
|
|||||||
case "rewrite":
|
case "rewrite":
|
||||||
parseRewrite(bd, &server)
|
parseRewrite(bd, &server)
|
||||||
case "location":
|
case "location":
|
||||||
classification := classifyLocation(bd, result)
|
classification := classifyLocation(bd, serverRoot, result)
|
||||||
convertLocation(classification, &server, upstreams, result)
|
convertLocation(classification, &server, upstreams, result)
|
||||||
case "error_page":
|
case "error_page":
|
||||||
parseErrorPage(bd, &server)
|
parseErrorPage(bd, &server)
|
||||||
@ -506,7 +506,7 @@ func parseAuthBasic(d *Directive, server *config.ServerConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// classifyLocation classifies a location block based on its directives.
|
// classifyLocation classifies a location block based on its directives.
|
||||||
func classifyLocation(d *Directive, result *ConvertResult) locationClassification {
|
func classifyLocation(d *Directive, serverRoot string, result *ConvertResult) locationClassification {
|
||||||
class := locationClassification{
|
class := locationClassification{
|
||||||
Directives: d.Block,
|
Directives: d.Block,
|
||||||
}
|
}
|
||||||
@ -570,8 +570,14 @@ func classifyLocation(d *Directive, result *ConvertResult) locationClassificatio
|
|||||||
case hasRedirect:
|
case hasRedirect:
|
||||||
class.LocType = redirectType
|
class.LocType = redirectType
|
||||||
default:
|
default:
|
||||||
|
// If no explicit root/alias/try_files but server-level root exists,
|
||||||
|
// classify as static (will inherit server root)
|
||||||
|
if serverRoot != "" {
|
||||||
|
class.LocType = "static"
|
||||||
|
} else {
|
||||||
class.LocType = "unsupported"
|
class.LocType = "unsupported"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return class
|
return class
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user