Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion agent/app/service/website_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@ func applySSL(website *model.Website, websiteSSL model.WebsiteSSL, req request.W
}
httpPorts := make(map[int]struct{})
httpsPorts := make(map[int]struct{})
sslPort := 0

hasDefaultPort := false
for _, domain := range domains {
Expand Down Expand Up @@ -769,6 +770,7 @@ func applySSL(website *model.Website, websiteSSL model.WebsiteSSL, req request.W
defaultHttpPortIPV6 := "[::]:" + defaultHttpPort

for port := range httpsPorts {
sslPort = port
portStr := strconv.Itoa(port)
server.RemoveListenByBind(portStr)
server.RemoveListenByBind("[::]:" + portStr)
Expand All @@ -789,7 +791,7 @@ func applySSL(website *model.Website, websiteSSL model.WebsiteSSL, req request.W
server.UpdateListen(defaultHttpPortIPV6, website.DefaultServer)
}
}
server.AddHTTP2HTTPS()
server.AddHTTP2HTTPS(sslPort)
case constant.HTTPAlso:
if hasDefaultPort {
server.UpdateListen(defaultHttpPort, website.DefaultServer)
Expand Down
21 changes: 15 additions & 6 deletions agent/utils/nginx/components/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package components

import (
"errors"
"fmt"
)

type Server struct {
Expand Down Expand Up @@ -466,19 +467,27 @@ func (s *Server) RemoveListenByBind(bind string) {
s.Listens = listens
}

func (s *Server) AddHTTP2HTTPS() {
func (s *Server) AddHTTP2HTTPS(httpsPort int) {
newDir := Directive{
Name: "if",
Parameters: []string{"($scheme = http)"},
Block: &Block{},
}
block := &Block{}
block.AppendDirectives(&Directive{
Name: "return",
Parameters: []string{"301", "https://$host$request_uri"},
})
if httpsPort == 443 {
block.AppendDirectives(&Directive{
Name: "return",
Parameters: []string{"301", "https://$host$request_uri"},
})
} else {
block.AppendDirectives(&Directive{
Name: "return",
Parameters: []string{"301", fmt.Sprintf("https://$host$request_uri:%d", httpsPort)},
})
}

newDir.Block = block
s.UpdateDirectiveBySecondKey("if", "($scheme", newDir)
s.UpdateDirectiveBySecondKey("if", " ($scheme", newDir)
}

func (s *Server) UpdateAllowIPs(ips []string) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/website/website/create/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
:validate-on-rule-change="false"
v-loading="loading"
>
<el-form-item :label="$t('commons.table.type')">
<el-form-item>
<el-radio-group v-model="website.type" @change="changeType">
<el-radio-button v-for="item in WebsiteTypes" :key="item.value" :value="item.value">
{{ item.label }}
Expand Down
16 changes: 4 additions & 12 deletions frontend/src/views/website/website/domain-create/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@
:placeholder="index > 0 ? $t('website.domain') : ''"
@blur="handleDomainBlur(index)"
></el-input>
<div
v-if="domainWarnings[index]"
class="el-form-item__error"
style="position: relative; color: #e6a23c"
>
{{ $t('website.domainNotFQDN') }}
</div>
<span class="input-help" v-if="domainWarnings[index]">{{ $t('website.domainNotFQDN') }}</span>
</el-form-item>
</el-col>
<el-col :span="6">
Expand Down Expand Up @@ -64,11 +58,9 @@
</el-form-item>
</el-col>
</el-row>
<div class="mt-1">
<el-button @click="openBatchDialog" type="primary" plain>
{{ $t('website.batchInput') }}
</el-button>
</div>
<el-button @click="openBatchDialog" type="primary" plain>
{{ $t('website.batchInput') }}
</el-button>

<el-dialog v-model="batchDialogVisible" :title="$t('website.batchAdd')" width="600px">
<el-input
Expand Down
Loading