Skip SSL check for the destination host (#170)

by @themagic314 

* skip ssl check on dest host
* nolint directive
* readme explanation
This commit is contained in:
Eli
2024-01-07 22:19:50 +04:00
committed by GitHub
parent 5b5b04243f
commit 7d4394f1c8
3 changed files with 8 additions and 1 deletions

View File

@@ -247,6 +247,7 @@ supported codes:
- `--gzip` enables gzip compression for responses. - `--gzip` enables gzip compression for responses.
- `--max=N` allows to set the maximum size of request (default 64k). Setting it to `0` disables the size check. - `--max=N` allows to set the maximum size of request (default 64k). Setting it to `0` disables the size check.
- `--timeout.*` various timeouts for both server and proxy transport. See `timeout` section in [All Application Options](#all-application-options). A zero or negative value means there will be no timeout. - `--timeout.*` various timeouts for both server and proxy transport. See `timeout` section in [All Application Options](#all-application-options). A zero or negative value means there will be no timeout.
- `--insecure` disables SSL verification on the destination host. This is useful for the self-signed certificates.
## Default ports ## Default ports
@@ -366,7 +367,8 @@ This is the list of all options supporting multiple elements:
--basic-htpasswd= htpasswd file for basic auth [$BASIC_HTPASSWD] --basic-htpasswd= htpasswd file for basic auth [$BASIC_HTPASSWD]
--lb-type=[random|failover|roundrobin] load balancer type (default: random) [$LB_TYPE] --lb-type=[random|failover|roundrobin] load balancer type (default: random) [$LB_TYPE]
--signature enable reproxy signature headers [$SIGNATURE] --signature enable reproxy signature headers [$SIGNATURE]
--remote-lookup-headers enable remote lookup headers [$REMOTE_LOOKUP_HEADERS] --remote-lookup-headers enable remote lookup headers [$REMOTE_LOOKUP_HEADERS]
--insecure skip SSL verification on destination host [$INSECURE]
--dbg debug mode [$DEBUG] --dbg debug mode [$DEBUG]
ssl: ssl:

View File

@@ -36,6 +36,7 @@ var opts struct {
AuthBasicHtpasswd string `long:"basic-htpasswd" env:"BASIC_HTPASSWD" description:"htpasswd file for basic auth"` AuthBasicHtpasswd string `long:"basic-htpasswd" env:"BASIC_HTPASSWD" description:"htpasswd file for basic auth"`
RemoteLookupHeaders bool `long:"remote-lookup-headers" env:"REMOTE_LOOKUP_HEADERS" description:"enable remote lookup headers"` RemoteLookupHeaders bool `long:"remote-lookup-headers" env:"REMOTE_LOOKUP_HEADERS" description:"enable remote lookup headers"`
LBType string `long:"lb-type" env:"LB_TYPE" description:"load balancer type" choice:"random" choice:"failover" choice:"roundrobin" default:"random"` // nolint LBType string `long:"lb-type" env:"LB_TYPE" description:"load balancer type" choice:"random" choice:"failover" choice:"roundrobin" default:"random"` // nolint
Insecure bool `long:"insecure" env:"INSECURE" description:"skip SSL certificate verification for the destination host"`
SSL struct { SSL struct {
Type string `long:"type" env:"TYPE" description:"ssl (auto) support" choice:"none" choice:"static" choice:"auto" default:"none"` // nolint Type string `long:"type" env:"TYPE" description:"ssl (auto) support" choice:"none" choice:"static" choice:"auto" default:"none"` // nolint
@@ -248,6 +249,7 @@ func run() error {
CacheControl: cacheControl, CacheControl: cacheControl,
GzEnabled: opts.GzipEnabled, GzEnabled: opts.GzipEnabled,
SSLConfig: sslConfig, SSLConfig: sslConfig,
Insecure: opts.Insecure,
ProxyHeaders: proxyHeaders, ProxyHeaders: proxyHeaders,
DropHeader: opts.DropHeaders, DropHeader: opts.DropHeaders,
AccessLog: accessLog, AccessLog: accessLog,

View File

@@ -3,6 +3,7 @@ package proxy
import ( import (
"bytes" "bytes"
"context" "context"
"crypto/tls"
"fmt" "fmt"
"io" "io"
"net" "net"
@@ -37,6 +38,7 @@ type Http struct { // nolint golint
ProxyHeaders []string ProxyHeaders []string
DropHeader []string DropHeader []string
SSLConfig SSLConfig SSLConfig SSLConfig
Insecure bool
Version string Version string
AccessLog io.Writer AccessLog io.Writer
StdOutEnabled bool StdOutEnabled bool
@@ -223,6 +225,7 @@ func (h *Http) proxyHandler() http.HandlerFunc {
IdleConnTimeout: h.Timeouts.IdleConn, IdleConnTimeout: h.Timeouts.IdleConn,
TLSHandshakeTimeout: h.Timeouts.TLSHandshake, TLSHandshakeTimeout: h.Timeouts.TLSHandshake,
ExpectContinueTimeout: h.Timeouts.ExpectContinue, ExpectContinueTimeout: h.Timeouts.ExpectContinue,
TLSClientConfig: &tls.Config{InsecureSkipVerify: h.Insecure}, //nolint:gosec // G402: User defined option to disable verification for self-signed certificates
}, },
ErrorLog: log.ToStdLogger(log.Default(), "WARN"), ErrorLog: log.ToStdLogger(log.Default(), "WARN"),
} }