mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-01-08 10:45:04 +02:00
IMGPROXY_IGNORE_SSL_VERIFICATION option
This commit is contained in:
parent
4208756321
commit
b9cf4a054a
31
config.go
31
config.go
@ -98,6 +98,8 @@ type config struct {
|
|||||||
|
|
||||||
AllowOrigin string
|
AllowOrigin string
|
||||||
|
|
||||||
|
IgnoreSslVerification bool
|
||||||
|
|
||||||
LocalFileSystemRoot string
|
LocalFileSystemRoot string
|
||||||
|
|
||||||
ETagEnabled bool
|
ETagEnabled bool
|
||||||
@ -106,17 +108,18 @@ type config struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var conf = config{
|
var conf = config{
|
||||||
Bind: ":8080",
|
Bind: ":8080",
|
||||||
ReadTimeout: 10,
|
ReadTimeout: 10,
|
||||||
WriteTimeout: 10,
|
WriteTimeout: 10,
|
||||||
DownloadTimeout: 5,
|
DownloadTimeout: 5,
|
||||||
Concurrency: runtime.NumCPU() * 2,
|
Concurrency: runtime.NumCPU() * 2,
|
||||||
TTL: 3600,
|
TTL: 3600,
|
||||||
MaxSrcDimension: 8192,
|
IgnoreSslVerification: false,
|
||||||
MaxSrcResolution: 16800000,
|
MaxSrcDimension: 8192,
|
||||||
Quality: 80,
|
MaxSrcResolution: 16800000,
|
||||||
GZipCompression: 5,
|
Quality: 80,
|
||||||
ETagEnabled: false,
|
GZipCompression: 5,
|
||||||
|
ETagEnabled: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -161,6 +164,8 @@ func init() {
|
|||||||
|
|
||||||
strEnvConfig(&conf.AllowOrigin, "IMGPROXY_ALLOW_ORIGIN")
|
strEnvConfig(&conf.AllowOrigin, "IMGPROXY_ALLOW_ORIGIN")
|
||||||
|
|
||||||
|
boolEnvConfig(&conf.IgnoreSslVerification, "IMGPROXY_IGNORE_SSL_VERIFICATION")
|
||||||
|
|
||||||
strEnvConfig(&conf.LocalFileSystemRoot, "IMGPROXY_LOCAL_FILESYSTEM_ROOT")
|
strEnvConfig(&conf.LocalFileSystemRoot, "IMGPROXY_LOCAL_FILESYSTEM_ROOT")
|
||||||
|
|
||||||
boolEnvConfig(&conf.ETagEnabled, "IMGPROXY_USE_ETAG")
|
boolEnvConfig(&conf.ETagEnabled, "IMGPROXY_USE_ETAG")
|
||||||
@ -222,6 +227,10 @@ func init() {
|
|||||||
log.Fatalf("GZip compression can't be greater than 9, now - %d\n", conf.GZipCompression)
|
log.Fatalf("GZip compression can't be greater than 9, now - %d\n", conf.GZipCompression)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if conf.IgnoreSslVerification {
|
||||||
|
log.Println("Ignoring SSL verification is very unsafe. Hope you know what you're doing")
|
||||||
|
}
|
||||||
|
|
||||||
if conf.LocalFileSystemRoot != "" {
|
if conf.LocalFileSystemRoot != "" {
|
||||||
stat, err := os.Stat(conf.LocalFileSystemRoot)
|
stat, err := os.Stat(conf.LocalFileSystemRoot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
@ -59,9 +60,15 @@ func initDownloading() {
|
|||||||
transport := &http.Transport{
|
transport := &http.Transport{
|
||||||
Proxy: http.ProxyFromEnvironment,
|
Proxy: http.ProxyFromEnvironment,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if conf.IgnoreSslVerification {
|
||||||
|
transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||||
|
}
|
||||||
|
|
||||||
if conf.LocalFileSystemRoot != "" {
|
if conf.LocalFileSystemRoot != "" {
|
||||||
transport.RegisterProtocol("local", http.NewFileTransport(http.Dir(conf.LocalFileSystemRoot)))
|
transport.RegisterProtocol("local", http.NewFileTransport(http.Dir(conf.LocalFileSystemRoot)))
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadClient = &http.Client{
|
downloadClient = &http.Client{
|
||||||
Timeout: time.Duration(conf.DownloadTimeout) * time.Second,
|
Timeout: time.Duration(conf.DownloadTimeout) * time.Second,
|
||||||
Transport: transport,
|
Transport: transport,
|
||||||
|
Loading…
Reference in New Issue
Block a user