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

Portal proxy healthcheck #1321

Merged
merged 1 commit into from
Oct 24, 2017
Merged
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
Portal proxy healthcheck
  • Loading branch information
Irfan Habib committed Oct 24, 2017
commit ea1ba63c173085e5b00338fe79c62acf8f610c25
13 changes: 11 additions & 2 deletions components/app-core/backend/setup_console.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,22 +234,31 @@ func (p *portalProxy) SetupMiddleware(setupMiddleware *setupMiddleware) echo.Mid

setupRequestRegex := "/v1/setup$"
setupUpdateRequestRegex := "/v1/setup/update$"
versionRequestRegex := "/v1/version$"
backendRequestRegex := "/v1/"

if inCFMode {
setupRequestRegex = fmt.Sprintf("^/pp%s", setupRequestRegex)
setupUpdateRequestRegex = fmt.Sprintf("^/pp%s", setupUpdateRequestRegex)
versionRequestRegex = fmt.Sprintf("^/pp%s", versionRequestRegex)
backendRequestRegex = fmt.Sprintf("^/pp%s", backendRequestRegex)
}

isSetupRequest, _ = regexp.MatchString(setupRequestRegex, requestURLPath)
if !isSetupRequest {
isSetupRequest, _ = regexp.MatchString("/v1/setup/update$", requestURLPath)
isSetupRequest, _ = regexp.MatchString(setupUpdateRequestRegex, requestURLPath)
}
if isSetupRequest {
return h(c)
}

isVersionRequest, _ := regexp.MatchString(versionRequestRegex, requestURLPath)

if isVersionRequest {
return h(c)
}
// Request is not a setup request, refuse backend requests and allow all others
isBackendRequest, _ := regexp.MatchString("/v1/", requestURLPath)
isBackendRequest, _ := regexp.MatchString(backendRequestRegex, requestURLPath)

if !isBackendRequest {
return h(c)
Expand Down