mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 14:08:06 +08:00
feat: 适配 证书 HTTP 模式
This commit is contained in:
parent
ddf6555250
commit
ff575e5963
@ -0,0 +1,13 @@
|
|||||||
|
server {
|
||||||
|
listen 80 default_server;
|
||||||
|
server_name _;
|
||||||
|
charset utf-8;
|
||||||
|
default_type text/html;
|
||||||
|
|
||||||
|
location ~ /.well-known/acme-challenge {
|
||||||
|
allow all;
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
}
|
||||||
|
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
nginx1.23.1:
|
nginx1.23.1:
|
||||||
container_name: ${CONTAINER_NAME}
|
container_name: nginx1.23.1
|
||||||
image: nginx:1.23.1
|
image: nginx:1.23.1
|
||||||
restart: always
|
restart: always
|
||||||
network_mode: host
|
network_mode: host
|
||||||
@ -11,5 +11,6 @@ services:
|
|||||||
- ./conf/conf.d:/etc/nginx/conf.d/
|
- ./conf/conf.d:/etc/nginx/conf.d/
|
||||||
- ./ssl:/etc/nginx/ssl
|
- ./ssl:/etc/nginx/ssl
|
||||||
- ./www:/www/root/
|
- ./www:/www/root/
|
||||||
|
- ./root:/usr/share/nginx/html
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,7 +6,9 @@ import (
|
|||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/model"
|
"github.com/1Panel-dev/1Panel/backend/app/model"
|
||||||
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/ssl"
|
"github.com/1Panel-dev/1Panel/backend/utils/ssl"
|
||||||
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -66,6 +68,16 @@ func (w WebSiteSSLService) Create(create dto.WebsiteSSLCreate) (dto.WebsiteSSLCr
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
case dto.Http:
|
case dto.Http:
|
||||||
|
|
||||||
|
appInstall, err := getAppInstallByKey("nginx")
|
||||||
|
if err != nil {
|
||||||
|
return dto.WebsiteSSLCreate{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := client.UseHTTP(path.Join(constant.AppInstallDir, "nginx", appInstall.Name, "root")); err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
case dto.DnsManual:
|
case dto.DnsManual:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/go-acme/lego/v4/lego"
|
"github.com/go-acme/lego/v4/lego"
|
||||||
"github.com/go-acme/lego/v4/providers/dns/alidns"
|
"github.com/go-acme/lego/v4/providers/dns/alidns"
|
||||||
"github.com/go-acme/lego/v4/providers/dns/dnspod"
|
"github.com/go-acme/lego/v4/providers/dns/dnspod"
|
||||||
|
"github.com/go-acme/lego/v4/providers/http/webroot"
|
||||||
"github.com/go-acme/lego/v4/registration"
|
"github.com/go-acme/lego/v4/registration"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"time"
|
"time"
|
||||||
@ -120,8 +121,17 @@ func (c *AcmeClient) UseManualDns(domains []string) (*Resolve, error) {
|
|||||||
return p.Resolve, nil
|
return p.Resolve, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AcmeClient) UseHTTP() {
|
func (c *AcmeClient) UseHTTP(path string) error {
|
||||||
|
httpProvider, err := webroot.NewHTTPProvider(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = c.Client.Challenge.SetHTTP01Provider(httpProvider)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AcmeClient) ObtainSSL(domains []string) (certificate.Resource, error) {
|
func (c *AcmeClient) ObtainSSL(domains []string) (certificate.Resource, error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user