Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow operator console to be hosted at subpath #1611

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions api/configure_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func replaceBaseInIndex(indexPageBytes []byte, basePath string) []byte {

// handleSPA handles the serving of the React Single Page Application
func handleSPA(w http.ResponseWriter, r *http.Request) {
basePath := "/"
basePath := getSubPath()
// For SPA mode we will replace root base with a sub path if configured unless we received cp=y and cpb=/NEW/BASE
if v := r.URL.Query().Get("cp"); v == "y" {
if base := r.URL.Query().Get("cpb"); base != "" {
Expand Down Expand Up @@ -363,7 +363,7 @@ func handleSPA(w http.ResponseWriter, r *http.Request) {
// wrapHandlerSinglePageApplication handles a http.FileServer returning a 404 and overrides it with index.html
func wrapHandlerSinglePageApplication(h http.Handler) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/" {
if match, _ := regexp.MatchString(fmt.Sprintf("^%s/?$", getSubPath()), r.URL.Path); match {
handleSPA(w, r)
return
}
Expand All @@ -381,8 +381,9 @@ func wrapHandlerSinglePageApplication(h http.Handler) http.HandlerFunc {
func FileServerMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Server", globalAppName) // do not add version information
basePath := getSubPath()
switch {
case strings.HasPrefix(r.URL.Path, "/api"):
case strings.HasPrefix(r.URL.Path, basePath+"/api"):
next.ServeHTTP(w, r)
default:
buildFs, err := fs.Sub(webApp.GetStaticAssets(), "build")
Expand Down
3 changes: 2 additions & 1 deletion docs/env-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ Operator behavior can be customized using environment variables in the `minio-op
|OPERATOR_STS_ENABLED| This toggles the STS Service on or off | `on`, `off` | `off` |
|MINIO_CONSOLE_DEPLOYMENT_NAME| This is the default name of the console deployment | | `console` |
|MINIO_CONSOLE_TLS_ENABLE| This toggles the Console TLS on or off | `on`, `off` | `off` |
|WATCHED_NAMESPACE| The namespaces which the operator watches for MinIO tenants. Defaults to `""` for all namespaces. | | |
|WATCHED_NAMESPACE| The namespaces which the operator watches for MinIO tenants. Defaults to `""` for all namespaces.
|OPERATOR_SUBPATH| the subpath that the operator console is served from.