MCPcopy Index your code
hub / github.com/1Panel-dev/1Panel / AddHTTP2HTTPS

Method AddHTTP2HTTPS

agent/utils/nginx/components/server.go:509–530  ·  view source on GitHub ↗
(httpsPort int)

Source from the content-addressed store, hash-verified

507}
508
509func (s *Server) AddHTTP2HTTPS(httpsPort int) {
510 newDir := Directive{
511 Name: "if",
512 Parameters: []string{"($scheme = http)"},
513 Block: &Block{},
514 }
515 block := &Block{}
516 if httpsPort == 443 {
517 block.AppendDirectives(&Directive{
518 Name: "return",
519 Parameters: []string{"301", "https://$host$request_uri"},
520 })
521 } else {
522 block.AppendDirectives(&Directive{
523 Name: "return",
524 Parameters: []string{"301", fmt.Sprintf("https://$host:%d$request_uri", httpsPort)},
525 })
526 }
527
528 newDir.Block = block
529 s.UpdateDirectiveBySecondKey("if", "($scheme", newDir)
530}
531
532func (s *Server) UpdateAllowIPs(ips []string) {
533 index := -1

Callers 1

applySSLFunction · 0.80

Calls 2

AppendDirectivesMethod · 0.95

Tested by

no test coverage detected