ajp_intercept_errors

The `ajp_intercept_errors` directive allows NGINX to intercept error responses from AJP proxied servers for custom handling.

Syntaxajp_intercept_errors on | off;
Defaultoff
Contexthttp, server, location
Argumentsflag

Description

The ajp_intercept_errors directive is designed to manage error handling when proxying requests using the AJP (Apache Jserv Protocol) with NGINX. When enabled, this directive allows NGINX to respond to specific error conditions returned by the backend AJP server instead of passing these error responses directly to the client. This can be particularly useful for maintaining a consistent user experience by enabling custom error pages or logging mechanisms based on the type of error received.

When the ajp_intercept_errors directive is set to on, NGINX will monitor the HTTP status codes returned by the AJP backend. If an error status code (e.g., 404, 500) is returned, NGINX can utilize corresponding error handling configurations specified in the main server block. This flexibility ensures that sites can provide user-friendly error messages and perform any necessary redirects or responses without exposing clients to backend errors directly.

The directive accepts a boolean argument, either on or off, with off signifying that error responses should be passed as-is to the client, bypassing any configurations designed to handle such errors. This capability enhances the robustness of an application by enabling custom error routines without additional configuration for each specific error response.

Config Example

server {
    listen 80;

    location / {
        ajp_pass backend;
        ajp_intercept_errors on;
        error_page 404 /custom_404.html;
    }
}

Ensure proper error handling pages are defined with the error_page directive.

Be mindful of how errors are logged; NGINX's log behavior may change when using this directive.

Not all error codes may be relevant for interception depending on your specific configuration and requirements.

← Back to all directives