enhance: Force HTTPS #109

Close #109
This commit is contained in:
0xJacky 2023-04-29 23:03:34 +08:00
parent d5fa42da3c
commit c2a3cb622e
No known key found for this signature in database
GPG key ID: B6E4A6E4A561BAF0
2 changed files with 162 additions and 149 deletions

View file

@ -87,11 +87,11 @@ func ParseTemplate(path, name string, bindData map[string]TVariable) (c ConfigDe
custom := ""
content := ""
for {
bytes, _, err := r.ReadLine()
lineBytes, _, err := r.ReadLine()
if err == io.EOF {
break
}
orig := string(bytes)
orig := string(lineBytes)
line := strings.TrimSpace(orig)
switch {
case line == "# Nginx UI Custom Start":

View file

@ -2,5 +2,18 @@
name = "HTTP to HTTPS"
author = "@0xJacky"
description = { en = "HTTP force redirect to HTTPS Config", zh_CN = "HTTP 强制跳转 HTTPS 配置"}
[variables.host]
type = "string"
name = { en = "Host", zh_CN = "主机"}
value = ""
# Nginx UI Template End
{{- if .host }}
if ($host == {{ .host }}) {
return 307 https://$server_name$request_uri;
}
return 404;
{{ else }}
return 307 https://$server_name$request_uri;
{{- end }}