ajp_pass

The `ajp_pass` directive is used to pass requests from NGINX to a backend server using the AJP protocol.

Syntaxajp_pass upstream_name [options];
Defaultnone
Contextlocation, if in location
Arguments1-2

Description

The ajp_pass directive allows NGINX to proxy requests to an upstream AJP server, often used for connecting to application servers such as Apache Tomcat. By specifying an upstream block (e.g., upstream tomcats { server 127.0.0.1:8009; }), multiple AJP servers can be targeted. The directive can take one or two arguments: the upstream server or a URI and an optional value that indicates the connection management behavior (e.g., whether to keep connections alive).

In practice, when NGINX receives an incoming request, it processes the request headers and body according to the specified configuration before forwarding it to the AJP backend. The AJP protocol allows for efficient communication and can improve performance by leveraging connection pooling and minimizing resource usage. The request method, headers, and other attributes are handled appropriately to ensure seamless communication with the AJP server, making it ideal for scenarios involving Java-based applications.

Config Example

http {
    upstream tomcats {
        server 127.0.0.1:8009;
        keepalive 10;
    }
    server {
        listen 80;
        location / {
            ajp_pass tomcats;
        }
    }
}

Ensure that the AJP backend is correctly configured and running at the specified IP:Port.

The AJP protocol requires appropriate HTTP headers, so misconfigurations can lead to unexpected behaviors or errors.

If ajp_keep_conn is not set to 'on', NGINX may open and close connections unnecessarily, impacting performance.

← Back to all directives