mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
HttpServer: Make read timeout configurable but disabled by default (#31575)
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
This commit is contained in:
parent
fb337e5c1d
commit
862cd473eb
@ -69,6 +69,10 @@ socket = /tmp/grafana.sock
|
|||||||
# CDN Url
|
# CDN Url
|
||||||
cdn_url =
|
cdn_url =
|
||||||
|
|
||||||
|
# Sets the maximum time in minutes before timing out read of an incoming request and closing idle connections.
|
||||||
|
# `0` means there is no timeout for reading the request.
|
||||||
|
read_timeout = 0
|
||||||
|
|
||||||
#################################### Database ############################
|
#################################### Database ############################
|
||||||
[database]
|
[database]
|
||||||
# You can configure the database connection by specifying type, host, name, user and password
|
# You can configure the database connection by specifying type, host, name, user and password
|
||||||
|
@ -70,6 +70,10 @@
|
|||||||
# CDN Url
|
# CDN Url
|
||||||
;cdn_url =
|
;cdn_url =
|
||||||
|
|
||||||
|
# Sets the maximum time using a duration format (5s/5m/5ms) before timing out read of an incoming request and closing idle connections.
|
||||||
|
# `0` means there is no timeout for reading the request.
|
||||||
|
;read_timeout = 0
|
||||||
|
|
||||||
#################################### Database ####################################
|
#################################### Database ####################################
|
||||||
[database]
|
[database]
|
||||||
# You can configure the database connection by specifying type, host, name, user and password
|
# You can configure the database connection by specifying type, host, name, user and password
|
||||||
|
@ -268,6 +268,11 @@ Specify a full HTTP URL address to the root of your Grafana CDN assets. Grafana
|
|||||||
For example, given a cdn url like `https://cdn.myserver.com` grafana will try to load a javascript file from
|
For example, given a cdn url like `https://cdn.myserver.com` grafana will try to load a javascript file from
|
||||||
`http://cdn.myserver.com/grafana-oss/7.4.0/public/build/app.<hash>.js`.
|
`http://cdn.myserver.com/grafana-oss/7.4.0/public/build/app.<hash>.js`.
|
||||||
|
|
||||||
|
### read_timeout
|
||||||
|
|
||||||
|
Sets the maximum time using a duration format (5s/5m/5ms) before timing out read of an incoming request and closing idle connections.
|
||||||
|
`0` means there is no timeout for reading the request.
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
## [database]
|
## [database]
|
||||||
|
@ -148,3 +148,13 @@ For more information on Grafana Enterprise licensing and restrictions, refer to
|
|||||||
## Breaking changes
|
## Breaking changes
|
||||||
|
|
||||||
There are no known breaking changes in this release.
|
There are no known breaking changes in this release.
|
||||||
|
|
||||||
|
## Updated configuration
|
||||||
|
|
||||||
|
```
|
||||||
|
[server]
|
||||||
|
read_timeout = 0
|
||||||
|
```
|
||||||
|
|
||||||
|
Sets the maximum time using a duration format (5s/5m/5ms) before timing out read of an incoming request and closing idle connections.
|
||||||
|
`0` means there is no timeout for reading the request.
|
||||||
|
@ -115,8 +115,9 @@ func (hs *HTTPServer) Run(ctx context.Context) error {
|
|||||||
// Remove any square brackets enclosing IPv6 addresses, a format we support for backwards compatibility
|
// Remove any square brackets enclosing IPv6 addresses, a format we support for backwards compatibility
|
||||||
host := strings.TrimSuffix(strings.TrimPrefix(hs.Cfg.HTTPAddr, "["), "]")
|
host := strings.TrimSuffix(strings.TrimPrefix(hs.Cfg.HTTPAddr, "["), "]")
|
||||||
hs.httpSrv = &http.Server{
|
hs.httpSrv = &http.Server{
|
||||||
Addr: net.JoinHostPort(host, hs.Cfg.HTTPPort),
|
Addr: net.JoinHostPort(host, hs.Cfg.HTTPPort),
|
||||||
Handler: hs.macaron,
|
Handler: hs.macaron,
|
||||||
|
ReadTimeout: hs.Cfg.ReadTimeout,
|
||||||
}
|
}
|
||||||
switch hs.Cfg.Protocol {
|
switch hs.Cfg.Protocol {
|
||||||
case setting.HTTP2Scheme:
|
case setting.HTTP2Scheme:
|
||||||
|
@ -202,6 +202,7 @@ type Cfg struct {
|
|||||||
RouterLogging bool
|
RouterLogging bool
|
||||||
Domain string
|
Domain string
|
||||||
CDNRootURL *url.URL
|
CDNRootURL *url.URL
|
||||||
|
ReadTimeout time.Duration
|
||||||
EnableGzip bool
|
EnableGzip bool
|
||||||
EnforceDomain bool
|
EnforceDomain bool
|
||||||
|
|
||||||
@ -1368,6 +1369,8 @@ func (cfg *Cfg) readServerSettings(iniFile *ini.File) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cfg.ReadTimeout = server.Key("read_timeout").MustDuration(0)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user