mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
HTTP Server: Serve Grafana with a custom URL path prefix (#17048)
Adds a new [server] setting `serve_from_sub_path`. By enabling this setting and using a subpath in `root_url` setting, e.g. `root_url = http://localhost:3000/grafana`, Grafana will be accessible on `http://localhost:3000/grafana`. By default it is set to `false` for compatibility reasons. Closes #16623
This commit is contained in:
committed by
Marcus Efraimsson
parent
b547a0cb34
commit
04d473b3e5
@@ -30,7 +30,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"gopkg.in/macaron.v1"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -227,6 +227,10 @@ func (hs *HTTPServer) addMiddlewaresAndStaticRoutes() {
|
||||
|
||||
m.Use(middleware.AddDefaultResponseHeaders())
|
||||
|
||||
if setting.ServeFromSubPath && setting.AppSubUrl != "" {
|
||||
m.SetURLPrefix(setting.AppSubUrl)
|
||||
}
|
||||
|
||||
m.Use(macaron.Renderer(macaron.RenderOptions{
|
||||
Directory: path.Join(setting.StaticRootPath, "views"),
|
||||
IndentJSON: macaron.Env != macaron.PROD,
|
||||
|
||||
Reference in New Issue
Block a user