madebymode/traefik-modsecurity-plugin

custom error page

Opened this issue · 1 comments

49-3 commented

hi, have an esay way to have a custom error page?
i have try to put my custom 403 page on the owasp container but get no success
regards.

hi @49-3, right now this isn't possible bc this plugin caches the response code and then generates the rest of the body per:

func (a *Modsecurity) GetCachedResponse(req *http.Request, options CacheKeyOptions) (*http.Response, error) {
cacheKey := generateCacheKey(req, options)
if cachedErrorCode, found := a.cache.Get(cacheKey); found {
cachedCode := cachedErrorCode.(int)
// convert cachedCode to a 3-digit code
statusCode := cachedCode % 1000
body := []byte(http.StatusText(statusCode))
// create a new *http.Response with the given status code and body using the response pool
resp := newPooledCacheResponse(statusCode, body)
// Defer the call to putResponse to return the response object to the pool when done
defer putResponse(resp)
return resp, nil
}

but i'll keep this issue open and keep it in mind for the future