You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi folks,
We have created our own plugin and we would like to return the nginx error pages using nginx error_page directive with it, if the upstream returns a server error (basically if upstream http status is >= 500). However, there is a catch. We also use the api-breaker plugin which uses the log phase to increase its error count for enabling the breaker, so we cannot simply use core.response.exit(500) in header_filter phase, because it would circumvent the api breaker log phase.
What we have tried so far:
Use core.response.exit(500) in header_filterphase -> Does everything we want, but renders the api-breaker plugin useless (log phase will not run)
Use ngx.status = 500 and ngx.exit(0) -> Will return upstream response body and content type headers, so not what we need, we need the nginx integrated error_page directive to work
Manually run the log phase of all global rules and all plugins in the current ctx after core.response.exit -> Works, but feels increadibly hacky, so would like to avoid it
Use response-rewrite plugin -> We have template variables in our error pages (e.g. zipkin trace id), how would we be able to make use of the nginx variable interpolation for error pages here?
Use proxy_intercept_errors on with nginx -> We also have error_page directive enabled for other error codes < 500 (in case other plugins exit with such statuses), however, if the upstream returns such a status, we would like to return the original response of the upstream
Of course, we are unsure, if we are even on the right track, so if you have ideas on how to solve this without a custom plugin, we are happy to hear your suggestions.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi folks,
We have created our own plugin and we would like to return the nginx error pages using nginx
error_page
directive with it, if the upstream returns a server error (basically if upstream http status is >= 500). However, there is a catch. We also use theapi-breaker
plugin which uses the log phase to increase its error count for enabling the breaker, so we cannot simply usecore.response.exit(500)
in header_filter phase, because it would circumvent the api breaker log phase.What we have tried so far:
core.response.exit(500)
inheader_filter
phase -> Does everything we want, but renders theapi-breaker
plugin useless (log phase will not run)ngx.status = 500
andngx.exit(0)
-> Will return upstream response body and content type headers, so not what we need, we need the nginx integratederror_page
directive to workctx
aftercore.response.exit
-> Works, but feels increadibly hacky, so would like to avoid itresponse-rewrite plugin
-> We have template variables in our error pages (e.g. zipkin trace id), how would we be able to make use of the nginx variable interpolation for error pages here?proxy_intercept_errors on
with nginx -> We also haveerror_page
directive enabled for other error codes < 500 (in case other plugins exit with such statuses), however, if the upstream returns such a status, we would like to return the original response of the upstreamOf course, we are unsure, if we are even on the right track, so if you have ideas on how to solve this without a custom plugin, we are happy to hear your suggestions.
Thanks and best regards
Gregor
Beta Was this translation helpful? Give feedback.
All reactions