mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
Added attribute proxy for mc admin config set ALIAS logger_webhook
(#16657)
Signed-off-by: Shubhendu Ram Tripathi <shubhendu@minio.io>
This commit is contained in:
parent
9202c6e26a
commit
6b65ba1551
@ -43,6 +43,7 @@ const (
|
||||
ClientCert = "client_cert"
|
||||
ClientKey = "client_key"
|
||||
QueueSize = "queue_size"
|
||||
Proxy = "proxy"
|
||||
|
||||
KafkaBrokers = "brokers"
|
||||
KafkaTopic = "topic"
|
||||
@ -62,6 +63,7 @@ const (
|
||||
EnvLoggerWebhookAuthToken = "MINIO_LOGGER_WEBHOOK_AUTH_TOKEN"
|
||||
EnvLoggerWebhookClientCert = "MINIO_LOGGER_WEBHOOK_CLIENT_CERT"
|
||||
EnvLoggerWebhookClientKey = "MINIO_LOGGER_WEBHOOK_CLIENT_KEY"
|
||||
EnvLoggerWebhookProxy = "MINIO_LOGGER_WEBHOOK_PROXY"
|
||||
EnvLoggerWebhookQueueSize = "MINIO_LOGGER_WEBHOOK_QUEUE_SIZE"
|
||||
|
||||
EnvAuditWebhookEnable = "MINIO_AUDIT_WEBHOOK_ENABLE"
|
||||
@ -109,6 +111,10 @@ var (
|
||||
Key: ClientKey,
|
||||
Value: "",
|
||||
},
|
||||
config.KV{
|
||||
Key: Proxy,
|
||||
Value: "",
|
||||
},
|
||||
config.KV{
|
||||
Key: QueueSize,
|
||||
Value: "100000",
|
||||
@ -441,6 +447,7 @@ func lookupLoggerWebhookConfig(scfg config.Config, cfg Config) (Config, error) {
|
||||
if err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
proxyEnv := EnvLoggerWebhookProxy
|
||||
queueSizeEnv := EnvAuditWebhookQueueSize
|
||||
if target != config.Default {
|
||||
queueSizeEnv = EnvAuditWebhookQueueSize + config.Default + target
|
||||
@ -458,6 +465,7 @@ func lookupLoggerWebhookConfig(scfg config.Config, cfg Config) (Config, error) {
|
||||
AuthToken: env.Get(authTokenEnv, ""),
|
||||
ClientCert: env.Get(clientCertEnv, ""),
|
||||
ClientKey: env.Get(clientKeyEnv, ""),
|
||||
Proxy: env.Get(proxyEnv, ""),
|
||||
QueueSize: queueSize,
|
||||
Name: target,
|
||||
}
|
||||
@ -501,6 +509,7 @@ func lookupLoggerWebhookConfig(scfg config.Config, cfg Config) (Config, error) {
|
||||
AuthToken: kv.Get(AuthToken),
|
||||
ClientCert: kv.Get(ClientCert),
|
||||
ClientKey: kv.Get(ClientKey),
|
||||
Proxy: kv.Get(Proxy),
|
||||
QueueSize: queueSize,
|
||||
Name: starget,
|
||||
}
|
||||
|
@ -57,6 +57,12 @@ var (
|
||||
Optional: true,
|
||||
Type: "number",
|
||||
},
|
||||
config.HelpKV{
|
||||
Key: Proxy,
|
||||
Description: "proxy url endpoint e.g. http(s)://proxy",
|
||||
Optional: true,
|
||||
Type: "string",
|
||||
},
|
||||
config.HelpKV{
|
||||
Key: config.Comment,
|
||||
Description: config.DefaultComment,
|
||||
|
@ -24,6 +24,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
@ -51,6 +52,7 @@ type Config struct {
|
||||
ClientCert string `json:"clientCert"`
|
||||
ClientKey string `json:"clientKey"`
|
||||
QueueSize int `json:"queueSize"`
|
||||
Proxy string `json:"string"`
|
||||
Transport http.RoundTripper `json:"-"`
|
||||
|
||||
// Custom logger
|
||||
@ -127,6 +129,15 @@ func (h *Target) Init() error {
|
||||
req.Header.Set("Authorization", h.config.AuthToken)
|
||||
}
|
||||
|
||||
// If proxy available, set the same
|
||||
if h.config.Proxy != "" {
|
||||
proxyURL, _ := url.Parse(h.config.Proxy)
|
||||
transport := h.config.Transport
|
||||
ctransport := transport.(*http.Transport).Clone()
|
||||
ctransport.Proxy = http.ProxyURL(proxyURL)
|
||||
h.config.Transport = ctransport
|
||||
}
|
||||
|
||||
client := http.Client{Transport: h.config.Transport}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user