mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-09 13:02:33 +02:00
tuned some http settings, refactor
This commit is contained in:
parent
dd629f516b
commit
245f073350
3 changed files with 12 additions and 11 deletions
|
@ -1,4 +1,4 @@
|
||||||
package common
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
@ -15,8 +15,11 @@ var (
|
||||||
DefaultTransport = &http.Transport{
|
DefaultTransport = &http.Transport{
|
||||||
Proxy: http.ProxyFromEnvironment,
|
Proxy: http.ProxyFromEnvironment,
|
||||||
DialContext: defaultDialer.DialContext,
|
DialContext: defaultDialer.DialContext,
|
||||||
MaxIdleConnsPerHost: 1000,
|
ForceAttemptHTTP2: true,
|
||||||
IdleConnTimeout: 90 * time.Second,
|
MaxIdleConns: 100,
|
||||||
|
MaxIdleConnsPerHost: 10,
|
||||||
|
TLSHandshakeTimeout: 10 * time.Second,
|
||||||
|
ExpectContinueTimeout: 1 * time.Second,
|
||||||
}
|
}
|
||||||
DefaultTransportNoTLS = func() *http.Transport {
|
DefaultTransportNoTLS = func() *http.Transport {
|
||||||
var clone = DefaultTransport.Clone()
|
var clone = DefaultTransport.Clone()
|
|
@ -10,7 +10,6 @@ import (
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/yusing/go-proxy/internal/api/v1/error_page"
|
"github.com/yusing/go-proxy/internal/api/v1/error_page"
|
||||||
"github.com/yusing/go-proxy/internal/common"
|
|
||||||
gpHTTP "github.com/yusing/go-proxy/internal/net/http"
|
gpHTTP "github.com/yusing/go-proxy/internal/net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -47,8 +46,8 @@ func ServeStaticErrorPageFile(w http.ResponseWriter, r *http.Request) bool {
|
||||||
if path != "" && path[0] != '/' {
|
if path != "" && path[0] != '/' {
|
||||||
path = "/" + path
|
path = "/" + path
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(path, common.StaticFilePathPrefix) {
|
if strings.HasPrefix(path, gpHTTP.StaticFilePathPrefix) {
|
||||||
filename := path[len(common.StaticFilePathPrefix):]
|
filename := path[len(gpHTTP.StaticFilePathPrefix):]
|
||||||
file, ok := error_page.GetStaticFile(filename)
|
file, ok := error_page.GetStaticFile(filename)
|
||||||
if !ok {
|
if !ok {
|
||||||
errPageLogger.Errorf("unable to load resource %s", filename)
|
errPageLogger.Errorf("unable to load resource %s", filename)
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/yusing/go-proxy/internal/api/v1/error_page"
|
"github.com/yusing/go-proxy/internal/api/v1/error_page"
|
||||||
"github.com/yusing/go-proxy/internal/common"
|
|
||||||
"github.com/yusing/go-proxy/internal/docker/idlewatcher"
|
"github.com/yusing/go-proxy/internal/docker/idlewatcher"
|
||||||
E "github.com/yusing/go-proxy/internal/error"
|
E "github.com/yusing/go-proxy/internal/error"
|
||||||
. "github.com/yusing/go-proxy/internal/net/http"
|
. "github.com/yusing/go-proxy/internal/net/http"
|
||||||
|
@ -68,9 +67,9 @@ func NewHTTPRoute(entry *P.ReverseProxyEntry) (*HTTPRoute, E.NestedError) {
|
||||||
var unregIdleWatcher func()
|
var unregIdleWatcher func()
|
||||||
|
|
||||||
if entry.NoTLSVerify {
|
if entry.NoTLSVerify {
|
||||||
trans = common.DefaultTransportNoTLS.Clone()
|
trans = DefaultTransportNoTLS.Clone()
|
||||||
} else {
|
} else {
|
||||||
trans = common.DefaultTransport.Clone()
|
trans = DefaultTransport.Clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
rp := NewReverseProxy(entry.URL, trans)
|
rp := NewReverseProxy(entry.URL, trans)
|
||||||
|
|
Loading…
Add table
Reference in a new issue