diff --git a/apps/minio/versions/RELEASE.2022-08-13T21-54-44Z/docker-compose.yml b/apps/minio/versions/RELEASE.2022-08-13T21-54-44Z/docker-compose.yml index 73b0d3e90..2b1609739 100644 --- a/apps/minio/versions/RELEASE.2022-08-13T21-54-44Z/docker-compose.yml +++ b/apps/minio/versions/RELEASE.2022-08-13T21-54-44Z/docker-compose.yml @@ -5,7 +5,7 @@ services: container_name: 1panel_minio ports: - ${PANEL_APP_PORT_HTTP}:9000 - - "9001:9001" + - ${API_ROOT}:9001 restart: always command: server /data --console-address ":9001" environment: diff --git a/backend/app/service/website.go b/backend/app/service/website.go index 5466c7154..fa42735db 100644 --- a/backend/app/service/website.go +++ b/backend/app/service/website.go @@ -490,50 +490,8 @@ func (w WebsiteService) OpWebsiteHTTPS(ctx context.Context, req request.WebsiteH websiteSSL model.WebsiteSSL ) res.Enable = req.Enable - if req.Enable { - if req.Type == constant.SSLExisted { - websiteSSL, err = websiteSSLRepo.GetFirst(commonRepo.WithByID(req.WebsiteSSLID)) - if err != nil { - return response.WebsiteHTTPS{}, err - } - website.WebsiteSSLID = websiteSSL.ID - res.SSL = websiteSSL - } - if req.Type == constant.SSLManual { - certBlock, _ := pem.Decode([]byte(req.Certificate)) - cert, err := x509.ParseCertificate(certBlock.Bytes) - if err != nil { - return response.WebsiteHTTPS{}, err - } - websiteSSL.ExpireDate = cert.NotAfter - websiteSSL.StartDate = cert.NotBefore - websiteSSL.Type = cert.Issuer.CommonName - websiteSSL.Organization = cert.Issuer.Organization[0] - websiteSSL.PrimaryDomain = cert.Subject.CommonName - if len(cert.Subject.Names) > 0 { - var domains []string - for _, name := range cert.Subject.Names { - if v, ok := name.Value.(string); ok { - if v != cert.Subject.CommonName { - domains = append(domains, v) - } - } - } - if len(domains) > 0 { - websiteSSL.Domains = strings.Join(domains, "") - } - } - websiteSSL.Provider = constant.Manual - websiteSSL.PrivateKey = req.PrivateKey - websiteSSL.Pem = req.Certificate - res.SSL = websiteSSL - } - website.Protocol = constant.ProtocolHTTPS - if err := applySSL(website, websiteSSL, req.HttpConfig); err != nil { - return response.WebsiteHTTPS{}, err - } - website.HttpConfig = req.HttpConfig - } else { + + if !req.Enable { website.Protocol = constant.ProtocolHTTP website.WebsiteSSLID = 0 if err := deleteListenAndServerName(website, []int{443}, []string{}); err != nil { @@ -542,8 +500,55 @@ func (w WebsiteService) OpWebsiteHTTPS(ctx context.Context, req request.WebsiteH if err := deleteNginxConfig(constant.NginxScopeServer, getKeysFromStaticFile(dto.SSL), &website); err != nil { return response.WebsiteHTTPS{}, err } + if err := websiteRepo.Save(ctx, &website); err != nil { + return response.WebsiteHTTPS{}, err + } + return res, nil } + if req.Type == constant.SSLExisted { + websiteSSL, err = websiteSSLRepo.GetFirst(commonRepo.WithByID(req.WebsiteSSLID)) + if err != nil { + return response.WebsiteHTTPS{}, err + } + website.WebsiteSSLID = websiteSSL.ID + res.SSL = websiteSSL + } + if req.Type == constant.SSLManual { + certBlock, _ := pem.Decode([]byte(req.Certificate)) + cert, err := x509.ParseCertificate(certBlock.Bytes) + if err != nil { + return response.WebsiteHTTPS{}, err + } + websiteSSL.ExpireDate = cert.NotAfter + websiteSSL.StartDate = cert.NotBefore + websiteSSL.Type = cert.Issuer.CommonName + websiteSSL.Organization = cert.Issuer.Organization[0] + websiteSSL.PrimaryDomain = cert.Subject.CommonName + if len(cert.Subject.Names) > 0 { + var domains []string + for _, name := range cert.Subject.Names { + if v, ok := name.Value.(string); ok { + if v != cert.Subject.CommonName { + domains = append(domains, v) + } + } + } + if len(domains) > 0 { + websiteSSL.Domains = strings.Join(domains, "") + } + } + websiteSSL.Provider = constant.Manual + websiteSSL.PrivateKey = req.PrivateKey + websiteSSL.Pem = req.Certificate + res.SSL = websiteSSL + } + website.Protocol = constant.ProtocolHTTPS + if err := applySSL(website, websiteSSL, req.HttpConfig); err != nil { + return response.WebsiteHTTPS{}, err + } + website.HttpConfig = req.HttpConfig + if websiteSSL.ID == 0 { if err := websiteSSLRepo.Create(ctx, &websiteSSL); err != nil { return response.WebsiteHTTPS{}, err diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index b67595ca6..4e73b89be 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -925,12 +925,15 @@ export default { manualSSL: '手动导入证书', select: '选择', selectSSL: '选择证书', - privateKey: '密钥代码(pem格式)', - certificate: '密钥代码(pem格式)', + privateKey: '密钥(KEY)', + certificate: '证书(PEM格式)', HTTPConfig: 'HTTP选项', HTTPSOnly: '禁止HTTTP', HTTPToHTTPS: '访问HTTP自动跳转到HTTPS', HTTPAlso: 'HTTP可直接访问', + sslConfig: 'SSL 选项', + disbaleHTTTPS: '禁用 HTTPS', + disbaleHTTTPSHelper: '禁用 HTTPS会删除证书相关配置,是否继续', }, nginx: { serverNamesHashBucketSizeHelper: '服务器名字的hash表大小', diff --git a/frontend/src/views/website/website/config/basic/https/index.vue b/frontend/src/views/website/website/config/basic/https/index.vue index fcb996a63..4bc19b1d0 100644 --- a/frontend/src/views/website/website/config/basic/https/index.vue +++ b/frontend/src/views/website/website/config/basic/https/index.vue @@ -9,65 +9,70 @@ :rules="rules" :loading="loading" > - - - {{ $t('website.enableHTTPS') }} - + + - - - - - - - - - - - - - - - - - - - -
- - +
+ + + + + + - - + + + + + + + + + + + + +
+ + + + + + +
+ + + + {{ websiteSSL.primaryDomain }} + + + {{ websiteSSL.otherDomains }} + + + {{ dateFromat(1, 1, websiteSSL.expireDate) }} + + + + + + {{ $t('commons.button.save') }} +
- - - - {{ websiteSSL.primaryDomain }} - - - {{ websiteSSL.otherDomains }} - - - {{ dateFromat(1, 1, websiteSSL.expireDate) }} - - - - - - {{ $t('commons.button.save') }} - - @@ -75,7 +80,7 @@