-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
help request: handle nginx error_pages directives #8628
Comments
Agree +1. We may implement a plugin to support the custom error page. |
@tokers I would like to work on this extension, can you help me to get started. Should i create directly in plugins folder or make it 3rd-party plugin? |
I think submit the pull request to this repo would be better. |
This would be very useful. Currently when using
We need to get rid of both openresty and APISIX lines. It would be even better if we could also send a response based on the Accept header (e.g. JSON response for JSON requests). EDIT: actually this works fine for 429 responses. |
error_page may not work if we use ngx.print or ngx.say, see openresty/lua-nginx-module#1541 For example, when route not found , core.response.exit with message will call ngx.print, in this case, error_page will not work.
|
any updates on this? Anyone know how to implement a custom 404 page when apisix upstream throws a 404? I am trying to write a plugin, but upstream status is only available in header_filter and by that point request processing is done and I am unable to redirect again(through access,rewrite etc) |
Description
I am trying to serve a custom HTML error page when a route is not found in Apisix. I have tried adding the
error_page
directive and a customlocation
block in thehttp_server_location_configuration_snippet
field of the Apisix configuration file, but the custom error page is not being served. Instead, a raw JSON response with a 404 status code is being returned.According to the documentation, the
error_page
directive should handle HTTP errors and serve the specified error page. However, in my case, it seems that theerror_page
directive is not being triggered when a route is not found in Apisix.I have also checked the
http_access_phase
function in the Apisix Lua code, and it appears that a raw JSON response with a 404 status code is being returned when a route is not found. (apisix/apisix/init.lua
Lines 522 to 525 in 37f6f81
I would like to request the ability to serve a custom HTML error page when a route is not found in Apisix, either through the use of the
error_page
directive or through some other means.Environment
The text was updated successfully, but these errors were encountered: