This file is generated from xml source: DO NOT EDIT
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-->
-<title>mod_proxy_ajp - Apache HTTP Server</title>
+<title>mod_proxy_ajp - Apache HTTP Server Version 2.5</title>
<link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
<link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
-<link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
+<link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" />
+<script src="../style/scripts/prettify.min.js" type="text/javascript">
+</script>
+
<link href="../images/favicon.ico" rel="shortcut icon" /></head>
<body>
<div id="page-header">
-<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
-<p class="apache">Apache HTTP Server Version 2.3</p>
+<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
+<p class="apache">Apache HTTP Server Version 2.5</p>
<img alt="" src="../images/feather.gif" /></div>
<div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
<div id="path">
-<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.3</a> > <a href="./">Modules</a></div>
+<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.5</a> > <a href="./">Modules</a></div>
<div id="page-content">
<div id="preamble"><h1>Apache Module mod_proxy_ajp</h1>
<div class="toplang">
<code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code></td></tr>
<tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr>
<tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>proxy_ajp_module</td></tr>
-<tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>proxy_ajp.c</td></tr>
-<tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td>Available in version 2.1 and later</td></tr></table>
+<tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_proxy_ajp.c</td></tr></table>
<h3>Summary</h3>
- <p>This module <em>requires</em> the service of <code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code>. It provides support for the
+ <p>This module <em>requires</em> the service of <code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code>. It provides support for the
<code>Apache JServ Protocol version 1.3</code> (hereafter
<em>AJP13</em>).</p>
large.</p>
</div>
</div>
-<div id="quickview"><h3 class="directives">Directives</h3>
-<p>This module provides no
- directives.</p>
-<h3>Topics</h3>
+<div id="quickview"><h3>Topics</h3>
<ul id="topics">
+<li><img alt="" src="../images/down.gif" /> <a href="#usage">Usage</a></li>
+<li><img alt="" src="../images/down.gif" /> <a href="#env">Environment Variables</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#overviewprotocol">Overview of the protocol</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#basppacketstruct">Basic Packet Structure</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#rpacetstruct">Request Packet Structure</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#resppacketstruct">Response Packet Structure</a></li>
-</ul><h3>See also</h3>
+</ul><h3 class="directives">Directives</h3>
+<p>This module provides no
+ directives.</p>
+<h3>See also</h3>
<ul class="seealso">
<li><code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code></li>
-</ul></div>
+<li><a href="../env.html">Environment Variable documentation</a></li>
+</ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
+<h2><a name="usage" id="usage">Usage</a></h2>
+ <p>This module is used to reverse proxy to a backend application server
+ (e.g. Apache Tomcat) using the AJP13 protocol. The usage is similar to
+ an HTTP reverse proxy, but uses the <code>ajp://</code> prefix:</p>
+
+ <div class="example"><h3>Simple Reverse Proxy</h3><pre class="prettyprint lang-config">ProxyPass "/app" "ajp://backend.example.com:8009/app"</pre>
+</div>
+
+ <p>Balancers may also be used:</p>
+ <div class="example"><h3>Balancer Reverse Proxy</h3><pre class="prettyprint lang-config"><Proxy balancer://cluster>
+ BalancerMember ajp://app1.example.com:8009 loadfactor=1
+ BalancerMember ajp://app2.example.com:8009 loadfactor=2
+ ProxySet lbmethod=bytraffic
+</Proxy>
+ProxyPass "/app" "balancer://cluster/app"</pre>
+</div>
+
+ <p>Note that usually no
+ <code class="directive"><a href="../mod/mod_proxy.html#proxypassreverse">ProxyPassReverse</a></code>
+ directive is necessary. The AJP request includes the original host
+ header given to the proxy, and the application server can be expected
+ to generate self-referential headers relative to this host, so no
+ rewriting is necessary.</p>
+
+ <p>The main exception is when the URL path on the proxy differs from that
+ on the
+ backend. In this case, a redirect header can be rewritten relative to the
+ original host URL (not the backend <code>ajp://</code> URL), for
+ example:</p>
+ <div class="example"><h3>Rewriting Proxied Path</h3><pre class="prettyprint lang-config">ProxyPass "/apps/foo" "ajp://backend.example.com:8009/foo"
+ProxyPassReverse "/apps/foo" "http://www.example.com/foo"</pre>
+</div>
+ <p>However, it is usually better to deploy the application on the backend
+ server at the same path as the proxy rather than to take this approach.
+ </p>
+</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="section">
+<h2><a name="env" id="env">Environment Variables</a></h2>
+ <p>Environment variables whose names have the prefix <code>AJP_</code>
+ are forwarded to the origin server as AJP request attributes
+ (with the AJP_ prefix removed from the name of the key).</p>
+</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="section">
<h2><a name="overviewprotocol" id="overviewprotocol">Overview of the protocol</a></h2>
<p>The <code>AJP13</code> protocol is packet-oriented. A binary format
was presumably chosen over the more readable plain text for reasons of
the connection can be in one of the following states:</p>
<ul>
<li> Idle <br /> No request is being handled over this connection. </li>
- <li> Assigned <br /> The connecton is handling a specific request.</li>
+ <li> Assigned <br /> The connection is handling a specific request.</li>
</ul>
<p>Once a connection is assigned to handle a particular request, the basic
- request informaton (e.g. HTTP headers, etc) is sent over the connection in
+ request information (e.g. HTTP headers, etc) is sent over the connection in
a highly condensed form (e.g. common strings are encoded as integers).
Details of that format are below in Request Packet Structure. If there is a
body to the request <code>(content-length > 0)</code>, that is sent in a
been transferred yet. This is necessary because the packets have a fixed
maximum size and arbitrary amounts of data can be included the body of a
request (for uploaded files, for example). (Note: this is unrelated to
- HTTP chunked tranfer).</li>
+ HTTP chunked transfer).</li>
<li>END_RESPONSE <br /> Finish the request-handling cycle.</li>
</ul>
<p>Each message is accompanied by a differently formatted packet of data.
<h2><a name="basppacketstruct" id="basppacketstruct">Basic Packet Structure</a></h2>
<p>There is a bit of an XDR heritage to this protocol, but it differs
in lots of ways (no 4 byte alignment, for example).</p>
- <p>Byte order: I am not clear about the endian-ness of the individual
- bytes. I'm guessing the bytes are little-endian, because that's what
- XDR specifies, and I'm guessing that sys/socket library is magically
- making that so (on the C side). If anyone with a better knowledge of
- socket calls can step in, that would be great.</p>
+ <p>AJP13 uses network byte order for all data types.</p>
<p>There are four data types in the protocol: bytes, booleans,
integers and strings.</p>
<dl>
suggest that the maximum payload could be as large as 2^16, in fact, the
code sets the maximum to be 8K.</p>
<table>
+
<tr>
- <td colspan="6"><em>Packet Format (Server->Container)</em></td>
+ <th colspan="6"><em>Packet Format (Server->Container)</em></th>
</tr>
<tr>
- <td>Byte</td>
+ <th>Byte</th>
<td>0</td>
<td>1</td>
<td>2</td>
<td>4...(n+3)</td>
</tr>
<tr>
- <td>Contents</td>
+ <th>Contents</th>
<td>0x12</td>
<td>0x34</td>
<td colspan="2">Data Length (n)</td>
</tr>
</table>
<table>
+
<tr>
- <td colspan="6"><em>Packet Format (Container->Server)</em></td>
+ <th colspan="6"><em>Packet Format (Container->Server)</em></th>
</tr>
<tr>
- <td>Byte</td>
+ <th>Byte</th>
<td>0</td>
<td>1</td>
<td>2</td>
<td>4...(n+3)</td>
</tr>
<tr>
- <td>Contents</td>
+ <th>Contents</th>
<td>A</td>
<td>B</td>
<td colspan="2">Data Length (n)</td>
<p>The web server can send the following messages to the servlet
container:</p>
<table>
+
<tr>
<td>Code</td>
<td>Type of Packet</td>
<p>To ensure some basic security, the container will only actually do the
<code>Shutdown</code> if the request comes from the same machine on which
it's hosted.</p>
- <p>The first <code>Data</code> packet is send immediatly after the
+ <p>The first <code>Data</code> packet is send immediately after the
<code>Forward Request</code> by the web server.</p>
<p>The servlet container can send the following types of messages to the
webserver:</p>
<table>
+
<tr>
<td>Code</td>
<td>Type of Packet</td>
<h2><a name="rpacetstruct" id="rpacetstruct">Request Packet Structure</a></h2>
<p>For messages from the server to the container of type
<em>Forward Request</em>:</p>
- <div class="example"><pre>
-AJP13_FORWARD_REQUEST :=
+ <div class="example"><pre>AJP13_FORWARD_REQUEST :=
prefix_code (byte) 0x02 = JK_AJP13_FORWARD_REQUEST
method (byte)
protocol (string)
num_headers (integer)
request_headers *(req_header_name req_header_value)
attributes *(attribut_name attribute_value)
- request_terminator (byte) OxFF
- </pre></div>
+ request_terminator (byte) OxFF</pre></div>
<p>The <code>request_headers</code> have the following structure:
- </p><div class="example"><pre>
-req_header_name :=
+ </p><div class="example"><pre>req_header_name :=
sc_req_header_name | (string) [see below for how this is parsed]
sc_req_header_name := 0xA0xx (integer)
-req_header_value := (string)
-</pre></div>
+req_header_value := (string)</pre></div>
<p>The <code>attributes</code> are optional and have the following
structure:</p>
- <div class="example"><pre>
-attribute_name := sc_a_name | (sc_a_req_attribute string)
-
-attribute_value := (string)
+ <div class="example"><pre>attribute_name := sc_a_name | (sc_a_req_attribute string)
- </pre></div>
+attribute_value := (string)</pre></div>
<p>Not that the all-important header is <code>content-length</code>,
because it determines whether or not the container looks for another
packet immediately.</p>
<tr><td>BASELINE_CONTROL</td><td>26</td></tr>
<tr><td>MKACTIVITY</td><td>27</td></tr>
</table>
- <p>Later version of ajp13, will transport
+ <p>Later version of ajp13, will transport
additional methods, even if they are not in this list.</p>
<h3>protocol, req_uri, remote_addr, remote_host, server_name,
header names. If the first byte is not <code>0xA0</code>, it assumes that
the two-byte integer is the length of a string, which is then read in.</p>
<p>This works on the assumption that no header names will have length
- greater than <code>0x9999 (==0xA000 - 1)</code>, which is perfectly
+ greater than <code>0x9FFF (==0xA000 - 1)</code>, which is perfectly
reasonable, though somewhat arbitrary.</p>
<div class="note"><h3>Note:</h3>
The <code>content-length</code> header is extremely
<div class="section">
<h2><a name="resppacketstruct" id="resppacketstruct">Response Packet Structure</a></h2>
<p>for messages which the container can send back to the server.</p>
- <div class="example"><pre>
-AJP13_SEND_BODY_CHUNK :=
+ <div class="example"><pre>AJP13_SEND_BODY_CHUNK :=
prefix_code 3
chunk_length (integer)
chunk *(byte)
AJP13_GET_BODY_CHUNK :=
prefix_code 6
- requested_length (integer)
- </pre></div>
+ requested_length (integer)</pre></div>
<h3>Details:</h3>
<h3>Send Body Chunk</h3>
<p>The chunk is basically binary data, and is sent directly back to the
<p>The status code and message are the usual HTTP things
(e.g. <code>200</code> and <code>OK</code>). The response header names are
encoded the same way the request header names are. See header_encoding above
- for details about how the the codes are distinguished from the strings.<br />
+ for details about how the codes are distinguished from the strings.<br />
The codes for common headers are:</p>
<table>
<tr><td>Name</td><td>Code value</td></tr>
<h3>End Response</h3>
<p>Signals the end of this request-handling cycle. If the
- <code>reuse</code> flag is true <code>(==1)</code>, this TCP connection can
- now be used to handle new incoming requests. If <code>reuse</code> is false
- (anything other than 1 in the actual C code), the connection should
+ <code>reuse</code> flag is true <code>(anything other than 0 in the actual
+ C code)</code>, this TCP connection can now be used to handle new incoming
+ requests. If <code>reuse</code> is false (==0), the connection should
be closed.</p>
<h3>Get Body Chunk</h3>
<p>The container asks for more data from the request (If the body was
too large to fit in the first packet sent over or when the request is
- chuncked). The server will send a body packet back with an amount of data
+ chunked). The server will send a body packet back with an amount of data
which is the minimum of the <code>request_length</code>, the maximum send
body size <code>(8186 (8 Kbytes - 6))</code>, and the number of bytes
actually left to send from the request body.<br />
<div class="bottomlang">
<p><span>Available Languages: </span><a href="../en/mod/mod_proxy_ajp.html" title="English"> en </a> |
<a href="../ja/mod/mod_proxy_ajp.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a></p>
-</div><div id="footer">
-<p class="apache">Copyright 2006 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
-<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div>
+</div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
+<script type="text/javascript"><!--//--><![CDATA[//><!--
+var comments_shortname = 'httpd';
+var comments_identifier = 'http://httpd.apache.org/docs/trunk/mod/mod_proxy_ajp.html';
+(function(w, d) {
+ if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
+ d.write('<div id="comments_thread"><\/div>');
+ var s = d.createElement('script');
+ s.type = 'text/javascript';
+ s.async = true;
+ s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
+ (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
+ }
+ else {
+ d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
+ }
+})(window, document);
+//--><!]]></script></div><div id="footer">
+<p class="apache">Copyright 2015 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
+<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
+if (typeof(prettyPrint) !== 'undefined') {
+ prettyPrint();
+}
+//--><!]]></script>
</body></html>
\ No newline at end of file