mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
feat: support proxy settings from env #579
This commit is contained in:
parent
ecb259a154
commit
390eabf3a0
7 changed files with 20 additions and 9 deletions
|
@ -84,6 +84,7 @@ func InitNode(env *model.Environment) (n *Node) {
|
||||||
|
|
||||||
client := http.Client{
|
client := http.Client{
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: settings.ServerSettings.InsecureSkipVerify},
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: settings.ServerSettings.InsecureSkipVerify},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ func IssueCert(payload *ConfigPayload, logChan chan string, errChan chan error)
|
||||||
// Skip TLS check
|
// Skip TLS check
|
||||||
if config.HTTPClient != nil {
|
if config.HTTPClient != nil {
|
||||||
config.HTTPClient.Transport = &http.Transport{
|
config.HTTPClient.Transport = &http.Transport{
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: settings.ServerSettings.InsecureSkipVerify},
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: settings.ServerSettings.InsecureSkipVerify},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,7 @@ type SyncNotificationPayload struct {
|
||||||
func deploy(env *model.Environment, c *model.Cert, payloadBytes []byte) (err error) {
|
func deploy(env *model.Environment, c *model.Cert, payloadBytes []byte) (err error) {
|
||||||
client := http.Client{
|
client := http.Client{
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: settings.ServerSettings.InsecureSkipVerify},
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: settings.ServerSettings.InsecureSkipVerify},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"crypto/elliptic"
|
"crypto/elliptic"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"github.com/0xJacky/Nginx-UI/model"
|
||||||
"github.com/0xJacky/Nginx-UI/settings"
|
"github.com/0xJacky/Nginx-UI/settings"
|
||||||
"github.com/go-acme/lego/v4/certcrypto"
|
"github.com/go-acme/lego/v4/certcrypto"
|
||||||
"github.com/go-acme/lego/v4/certificate"
|
"github.com/go-acme/lego/v4/certificate"
|
||||||
|
@ -28,9 +29,12 @@ func TestTencentCloudDNS(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
myUser := User{
|
myUser := model.AcmeUser{
|
||||||
Email: settings.ServerSettings.Email,
|
Email: settings.ServerSettings.Email,
|
||||||
Key: privateKey,
|
Key: model.PrivateKey{
|
||||||
|
X: privateKey.PublicKey.X,
|
||||||
|
Y: privateKey.PublicKey.Y,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
config := lego.NewConfig(&myUser)
|
config := lego.NewConfig(&myUser)
|
||||||
|
@ -43,6 +47,7 @@ func TestTencentCloudDNS(t *testing.T) {
|
||||||
config.CADirURL = settings.ServerSettings.CADir
|
config.CADirURL = settings.ServerSettings.CADir
|
||||||
if config.HTTPClient != nil {
|
if config.HTTPClient != nil {
|
||||||
config.HTTPClient.Transport = &http.Transport{
|
config.HTTPClient.Transport = &http.Transport{
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +84,7 @@ func TestTencentCloudDNS(t *testing.T) {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
myUser.Registration = reg
|
myUser.Registration = *reg
|
||||||
|
|
||||||
request := certificate.ObtainRequest{
|
request := certificate.ObtainRequest{
|
||||||
Domains: domain,
|
Domains: domain,
|
||||||
|
|
|
@ -124,6 +124,7 @@ type SyncNotificationPayload struct {
|
||||||
func (p *SyncConfigPayload) deploy(env *model.Environment, c *model.Config, payloadBytes []byte) (err error) {
|
func (p *SyncConfigPayload) deploy(env *model.Environment, c *model.Config, payloadBytes []byte) (err error) {
|
||||||
client := http.Client{
|
client := http.Client{
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: settings.ServerSettings.InsecureSkipVerify},
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: settings.ServerSettings.InsecureSkipVerify},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ func Proxy() gin.HandlerFunc {
|
||||||
logger.Debug("Proxy request", proxyUrl.String())
|
logger.Debug("Proxy request", proxyUrl.String())
|
||||||
client := http.Client{
|
client := http.Client{
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: settings.ServerSettings.InsecureSkipVerify},
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: settings.ServerSettings.InsecureSkipVerify},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ func (u *AcmeUser) Register() error {
|
||||||
// Skip TLS check
|
// Skip TLS check
|
||||||
if config.HTTPClient != nil {
|
if config.HTTPClient != nil {
|
||||||
config.HTTPClient.Transport = &http.Transport{
|
config.HTTPClient.Transport = &http.Transport{
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: settings.ServerSettings.InsecureSkipVerify},
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: settings.ServerSettings.InsecureSkipVerify},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue