allow data source proxy to proxy requests over self signed https connections, Closes #2069
This commit is contained in:
@@ -1,9 +1,12 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/bus"
|
"github.com/grafana/grafana/pkg/bus"
|
||||||
"github.com/grafana/grafana/pkg/middleware"
|
"github.com/grafana/grafana/pkg/middleware"
|
||||||
@@ -11,6 +14,16 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/util"
|
"github.com/grafana/grafana/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var dataProxyTransport = &http.Transport{
|
||||||
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
|
Dial: (&net.Dialer{
|
||||||
|
Timeout: 30 * time.Second,
|
||||||
|
KeepAlive: 30 * time.Second,
|
||||||
|
}).Dial,
|
||||||
|
TLSHandshakeTimeout: 10 * time.Second,
|
||||||
|
}
|
||||||
|
|
||||||
func NewReverseProxy(ds *m.DataSource, proxyPath string) *httputil.ReverseProxy {
|
func NewReverseProxy(ds *m.DataSource, proxyPath string) *httputil.ReverseProxy {
|
||||||
target, _ := url.Parse(ds.Url)
|
target, _ := url.Parse(ds.Url)
|
||||||
|
|
||||||
@@ -56,5 +69,6 @@ func ProxyDataSourceRequest(c *middleware.Context) {
|
|||||||
|
|
||||||
proxyPath := c.Params("*")
|
proxyPath := c.Params("*")
|
||||||
proxy := NewReverseProxy(&query.Result, proxyPath)
|
proxy := NewReverseProxy(&query.Result, proxyPath)
|
||||||
|
proxy.Transport = dataProxyTransport
|
||||||
proxy.ServeHTTP(c.RW(), c.Req.Request)
|
proxy.ServeHTTP(c.RW(), c.Req.Request)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user