github.com/krum110487/go-htaccess@v0.0.0-20240316004156-60641c8e7598/tests/data/apache_2_2_34/manual/mod/mod_proxy_ajp.html.en (about) 1 <?xml version="1.0" encoding="ISO-8859-1"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head> 4 <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" /> 5 <!-- 6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 7 This file is generated from xml source: DO NOT EDIT 8 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 9 --> 10 <title>mod_proxy_ajp - Apache HTTP Server Version 2.2</title> 11 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> 12 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> 13 <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" /> 14 <script src="../style/scripts/prettify.min.js" type="text/javascript"> 15 </script> 16 17 <link href="../images/favicon.ico" rel="shortcut icon" /><link href="http://httpd.apache.org/docs/current/mod/mod_proxy_ajp.html" rel="canonical" /></head> 18 <body> 19 <div id="page-header"> 20 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.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> 21 <p class="apache">Apache HTTP Server Version 2.2</p> 22 <img alt="" src="../images/feather.gif" /></div> 23 <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> 24 <div id="path"> 25 <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.2</a> > <a href="./">Modules</a></div> 26 <div id="page-content"> 27 <div class="retired"><h4>Please note</h4> 28 <p> This document refers to a legacy release (<strong>2.2</strong>) of Apache httpd. The active release (<strong>2.4</strong>) is documented <a href="http://httpd.apache.org/docs/current">here</a>. If you have not already upgraded, please follow <a href="http://httpd.apache.org/docs/current/upgrading.html">this link</a> for more information.</p> 29 <p>You may follow <a href="http://httpd.apache.org/docs/current/mod/mod_proxy_ajp.html">this link</a> to go to the current version of this document.</p></div><div id="preamble"><h1>Apache Module mod_proxy_ajp</h1> 30 <div class="toplang"> 31 <p><span>Available Languages: </span><a href="../en/mod/mod_proxy_ajp.html" title="English"> en </a> | 32 <a href="../ja/mod/mod_proxy_ajp.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a></p> 33 </div> 34 <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>AJP support module for 35 <code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code></td></tr> 36 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr> 37 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>proxy_ajp_module</td></tr> 38 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_proxy_ajp.c</td></tr> 39 <tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td>Available in version 2.1 and later</td></tr></table> 40 <h3>Summary</h3> 41 42 <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 43 <code>Apache JServ Protocol version 1.3</code> (hereafter 44 <em>AJP13</em>).</p> 45 46 <p>Thus, in order to get the ability of handling <code>AJP13</code> 47 protocol, <code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code> and 48 <code class="module"><a href="../mod/mod_proxy_ajp.html">mod_proxy_ajp</a></code> have to be present in the server.</p> 49 50 <div class="warning"><h3>Warning</h3> 51 <p>Do not enable proxying until you have <a href="mod_proxy.html#access">secured your server</a>. Open proxy 52 servers are dangerous both to your network and to the Internet at 53 large.</p> 54 </div> 55 </div> 56 <div id="quickview"><h3>Topics</h3> 57 <ul id="topics"> 58 <li><img alt="" src="../images/down.gif" /> <a href="#usage">Usage</a></li> 59 <li><img alt="" src="../images/down.gif" /> <a href="#env">Environment Variables</a></li> 60 <li><img alt="" src="../images/down.gif" /> <a href="#overviewprotocol">Overview of the protocol</a></li> 61 <li><img alt="" src="../images/down.gif" /> <a href="#basppacketstruct">Basic Packet Structure</a></li> 62 <li><img alt="" src="../images/down.gif" /> <a href="#rpacetstruct">Request Packet Structure</a></li> 63 <li><img alt="" src="../images/down.gif" /> <a href="#resppacketstruct">Response Packet Structure</a></li> 64 </ul><h3 class="directives">Directives</h3> 65 <p>This module provides no 66 directives.</p> 67 <h3>See also</h3> 68 <ul class="seealso"> 69 <li><code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code></li> 70 <li><a href="../env.html">Environment Variable documentation</a></li> 71 </ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div> 72 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> 73 <div class="section"> 74 <h2><a name="usage" id="usage">Usage</a></h2> 75 <p>This module is used to reverse proxy to a backend application server 76 (e.g. Apache Tomcat) using the AJP13 protocol. The usage is similar to 77 an HTTP reverse proxy, but uses the <code>ajp://</code> prefix:</p> 78 79 <div class="example"><h3>Simple Reverse Proxy</h3><p><code> 80 ProxyPass /app ajp://backend.example.com:8009/app 81 </code></p></div> 82 83 <p>Balancers may also be used:</p> 84 <div class="example"><h3>Balancer Reverse Proxy</h3><p><code> 85 <Proxy balancer://cluster><br /> 86 <span class="indent"> 87 BalancerMember ajp://app1.example.com:8009 loadfactor=1<br /> 88 BalancerMember ajp://app2.example.com:8009 loadfactor=2<br /> 89 ProxySet lbmethod=bytraffic<br /> 90 </span> 91 </Proxy><br /> 92 ProxyPass /app balancer://cluster/app 93 </code></p></div> 94 <p>Note that usually no 95 <code class="directive"><a href="../mod/mod_proxy.html#proxypassreverse">ProxyPassReverse</a></code> 96 directive is necessary. The AJP request includes the original host 97 header given to the proxy, and the application server can be expected 98 to generate self-referential headers relative to this host, so no 99 rewriting is necessary. 100 </p> 101 102 <p>The main exception is when the URL path on the proxy differs from that 103 on the 104 backend. In this case, a redirect header can be rewritten relative to the 105 original host URL (not the backend <code>ajp://</code> URL), for 106 example:</p> 107 <div class="example"><h3>Rewriting Proxied Path</h3><p><code> 108 ProxyPass /apps/foo ajp://backend.example.com:8009/foo<br /> 109 ProxyPassReverse /apps/foo http://www.example.com/foo 110 </code></p></div> 111 112 <p>However, it is usually better to deploy the application on the backend 113 server at the same path as the proxy rather than to take this approach. 114 </p> 115 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> 116 <div class="section"> 117 <h2><a name="env" id="env">Environment Variables</a></h2> 118 <p>Environment variables whose names have the prefix <code>AJP_</code> 119 are forwarded to the origin server as AJP request attributes 120 (with the AJP_ prefix removed from the name of the key).</p> 121 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> 122 <div class="section"> 123 <h2><a name="overviewprotocol" id="overviewprotocol">Overview of the protocol</a></h2> 124 <p>The <code>AJP13</code> protocol is packet-oriented. A binary format 125 was presumably chosen over the more readable plain text for reasons of 126 performance. The web server communicates with the servlet container over 127 TCP connections. To cut down on the expensive process of socket creation, 128 the web server will attempt to maintain persistent TCP connections to the 129 servlet container, and to reuse a connection for multiple request/response 130 cycles.</p> 131 <p>Once a connection is assigned to a particular request, it will not be 132 used for any others until the request-handling cycle has terminated. In 133 other words, requests are not multiplexed over connections. This makes 134 for much simpler code at either end of the connection, although it does 135 cause more connections to be open at once.</p> 136 <p>Once the web server has opened a connection to the servlet container, 137 the connection can be in one of the following states:</p> 138 <ul> 139 <li> Idle <br /> No request is being handled over this connection. </li> 140 <li> Assigned <br /> The connection is handling a specific request.</li> 141 </ul> 142 <p>Once a connection is assigned to handle a particular request, the basic 143 request information (e.g. HTTP headers, etc) is sent over the connection in 144 a highly condensed form (e.g. common strings are encoded as integers). 145 Details of that format are below in Request Packet Structure. If there is a 146 body to the request <code>(content-length > 0)</code>, that is sent in a 147 separate packet immediately after.</p> 148 <p>At this point, the servlet container is presumably ready to start 149 processing the request. As it does so, it can send the 150 following messages back to the web server:</p> 151 <ul> 152 <li>SEND_HEADERS <br />Send a set of headers back to the browser.</li> 153 <li>SEND_BODY_CHUNK <br />Send a chunk of body data back to the browser. 154 </li> 155 <li>GET_BODY_CHUNK <br />Get further data from the request if it hasn't all 156 been transferred yet. This is necessary because the packets have a fixed 157 maximum size and arbitrary amounts of data can be included the body of a 158 request (for uploaded files, for example). (Note: this is unrelated to 159 HTTP chunked transfer).</li> 160 <li>END_RESPONSE <br /> Finish the request-handling cycle.</li> 161 </ul> 162 <p>Each message is accompanied by a differently formatted packet of data. 163 See Response Packet Structures below for details.</p> 164 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> 165 <div class="section"> 166 <h2><a name="basppacketstruct" id="basppacketstruct">Basic Packet Structure</a></h2> 167 <p>There is a bit of an XDR heritage to this protocol, but it differs 168 in lots of ways (no 4 byte alignment, for example).</p> 169 <p>AJP13 uses network byte order for all data types.</p> 170 <p>There are four data types in the protocol: bytes, booleans, 171 integers and strings.</p> 172 <dl> 173 <dt><strong>Byte</strong></dt><dd>A single byte.</dd> 174 <dt><strong>Boolean</strong></dt> 175 <dd>A single byte, <code>1 = true</code>, <code>0 = false</code>. 176 Using other non-zero values as true (i.e. C-style) may work in some places, 177 but it won't in others.</dd> 178 <dt><strong>Integer</strong></dt> 179 <dd>A number in the range of <code>0 to 2^16 (32768)</code>. Stored in 180 2 bytes with the high-order byte first.</dd> 181 <dt><strong>String</strong></dt> 182 <dd>A variable-sized string (length bounded by 2^16). Encoded with 183 the length packed into two bytes first, followed by the string 184 (including the terminating '\0'). Note that the encoded length does 185 <strong>not</strong> include the trailing '\0' -- it is like 186 <code>strlen</code>. This is a touch confusing on the Java side, which 187 is littered with odd autoincrement statements to skip over these 188 terminators. I believe the reason this was done was to allow the C 189 code to be extra efficient when reading strings which the servlet 190 container is sending back -- with the terminating \0 character, the 191 C code can pass around references into a single buffer, without copying. 192 if the \0 was missing, the C code would have to copy things out in order 193 to get its notion of a string.</dd> 194 </dl> 195 196 <h3>Packet Size</h3> 197 <p>According to much of the code, the max packet size is <code> 198 8 * 1024 bytes (8K)</code>. The actual length of the packet is encoded in 199 the header.</p> 200 201 <h3>Packet Headers</h3> 202 <p>Packets sent from the server to the container begin with 203 <code>0x1234</code>. Packets sent from the container to the server 204 begin with <code>AB</code> (that's the ASCII code for A followed by the 205 ASCII code for B). After those first two bytes, there is an integer 206 (encoded as above) with the length of the payload. Although this might 207 suggest that the maximum payload could be as large as 2^16, in fact, the 208 code sets the maximum to be 8K.</p> 209 <table> 210 211 <tr> 212 <th colspan="6"><em>Packet Format (Server->Container)</em></th> 213 </tr> 214 <tr> 215 <th>Byte</th> 216 <td>0</td> 217 <td>1</td> 218 <td>2</td> 219 <td>3</td> 220 <td>4...(n+3)</td> 221 </tr> 222 <tr> 223 <th>Contents</th> 224 <td>0x12</td> 225 <td>0x34</td> 226 <td colspan="2">Data Length (n)</td> 227 <td>Data</td> 228 </tr> 229 </table> 230 <table> 231 232 <tr> 233 <th colspan="6"><em>Packet Format (Container->Server)</em></th> 234 </tr> 235 <tr> 236 <th>Byte</th> 237 <td>0</td> 238 <td>1</td> 239 <td>2</td> 240 <td>3</td> 241 <td>4...(n+3)</td> 242 </tr> 243 <tr> 244 <th>Contents</th> 245 <td>A</td> 246 <td>B</td> 247 <td colspan="2">Data Length (n)</td> 248 <td>Data</td> 249 </tr> 250 </table> 251 <p>For most packets, the first byte of the payload encodes the type of 252 message. The exception is for request body packets sent from the server to 253 the container -- they are sent with a standard packet header (<code> 254 0x1234</code> and then length of the packet), but without any prefix code 255 after that.</p> 256 <p>The web server can send the following messages to the servlet 257 container:</p> 258 <table> 259 260 <tr> 261 <td>Code</td> 262 <td>Type of Packet</td> 263 <td>Meaning</td> 264 </tr> 265 <tr> 266 <td>2</td> 267 <td>Forward Request</td> 268 <td>Begin the request-processing cycle with the following data</td> 269 </tr> 270 <tr> 271 <td>7</td> 272 <td>Shutdown</td> 273 <td>The web server asks the container to shut itself down.</td> 274 </tr> 275 <tr> 276 <td>8</td> 277 <td>Ping</td> 278 <td>The web server asks the container to take control 279 (secure login phase).</td> 280 </tr> 281 <tr> 282 <td>10</td> 283 <td>CPing</td> 284 <td>The web server asks the container to respond quickly with a CPong. 285 </td> 286 </tr> 287 <tr> 288 <td>none</td> 289 <td>Data</td> 290 <td>Size (2 bytes) and corresponding body data.</td> 291 </tr> 292 </table> 293 <p>To ensure some basic security, the container will only actually do the 294 <code>Shutdown</code> if the request comes from the same machine on which 295 it's hosted.</p> 296 <p>The first <code>Data</code> packet is send immediately after the 297 <code>Forward Request</code> by the web server.</p> 298 <p>The servlet container can send the following types of messages to the 299 webserver:</p> 300 <table> 301 302 <tr> 303 <td>Code</td> 304 <td>Type of Packet</td> 305 <td>Meaning</td> 306 </tr> 307 <tr> 308 <td>3</td> 309 <td>Send Body Chunk</td> 310 <td>Send a chunk of the body from the servlet container to the web 311 server (and presumably, onto the browser). </td> 312 </tr> 313 <tr> 314 <td>4</td> 315 <td>Send Headers</td> 316 <td>Send the response headers from the servlet container to the web 317 server (and presumably, onto the browser).</td> 318 </tr> 319 <tr> 320 <td>5</td> 321 <td>End Response</td> 322 <td>Marks the end of the response (and thus the request-handling cycle). 323 </td> 324 </tr> 325 <tr> 326 <td>6</td> 327 <td>Get Body Chunk</td> 328 <td>Get further data from the request if it hasn't all been 329 transferred yet.</td> 330 </tr> 331 <tr> 332 <td>9</td> 333 <td>CPong Reply</td> 334 <td>The reply to a CPing request</td> 335 </tr> 336 </table> 337 <p>Each of the above messages has a different internal structure, detailed 338 below.</p> 339 340 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> 341 <div class="section"> 342 <h2><a name="rpacetstruct" id="rpacetstruct">Request Packet Structure</a></h2> 343 <p>For messages from the server to the container of type 344 <em>Forward Request</em>:</p> 345 <div class="example"><pre>AJP13_FORWARD_REQUEST := 346 prefix_code (byte) 0x02 = JK_AJP13_FORWARD_REQUEST 347 method (byte) 348 protocol (string) 349 req_uri (string) 350 remote_addr (string) 351 remote_host (string) 352 server_name (string) 353 server_port (integer) 354 is_ssl (boolean) 355 num_headers (integer) 356 request_headers *(req_header_name req_header_value) 357 attributes *(attribut_name attribute_value) 358 request_terminator (byte) OxFF</pre></div> 359 <p>The <code>request_headers</code> have the following structure: 360 </p><div class="example"><pre>req_header_name := 361 sc_req_header_name | (string) [see below for how this is parsed] 362 363 sc_req_header_name := 0xA0xx (integer) 364 365 req_header_value := (string)</pre></div> 366 <p>The <code>attributes</code> are optional and have the following 367 structure:</p> 368 <div class="example"><pre>attribute_name := sc_a_name | (sc_a_req_attribute string) 369 370 attribute_value := (string)</pre></div> 371 <p>Not that the all-important header is <code>content-length</code>, 372 because it determines whether or not the container looks for another 373 packet immediately.</p> 374 <h3>Detailed description of the elements of Forward Request 375 </h3> 376 <h3>Request prefix</h3> 377 <p>For all requests, this will be 2. See above for details on other Prefix 378 codes.</p> 379 380 <h3>Method</h3> 381 <p>The HTTP method, encoded as a single byte:</p> 382 <table> 383 <tr><td>Command Name</td><td>Code</td></tr> 384 <tr><td>OPTIONS</td><td>1</td></tr> 385 <tr><td>GET</td><td>2</td></tr> 386 <tr><td>HEAD</td><td>3</td></tr> 387 <tr><td>POST</td><td>4</td></tr> 388 <tr><td>PUT</td><td>5</td></tr> 389 <tr><td>DELETE</td><td>6</td></tr> 390 <tr><td>TRACE</td><td>7</td></tr> 391 <tr><td>PROPFIND</td><td>8</td></tr> 392 <tr><td>PROPPATCH</td><td>9</td></tr> 393 <tr><td>MKCOL</td><td>10</td></tr> 394 <tr><td>COPY</td><td>11</td></tr> 395 <tr><td>MOVE</td><td>12</td></tr> 396 <tr><td>LOCK</td><td>13</td></tr> 397 <tr><td>UNLOCK</td><td>14</td></tr> 398 <tr><td>ACL</td><td>15</td></tr> 399 <tr><td>REPORT</td><td>16</td></tr> 400 <tr><td>VERSION-CONTROL</td><td>17</td></tr> 401 <tr><td>CHECKIN</td><td>18</td></tr> 402 <tr><td>CHECKOUT</td><td>19</td></tr> 403 <tr><td>UNCHECKOUT</td><td>20</td></tr> 404 <tr><td>SEARCH</td><td>21</td></tr> 405 <tr><td>MKWORKSPACE</td><td>22</td></tr> 406 <tr><td>UPDATE</td><td>23</td></tr> 407 <tr><td>LABEL</td><td>24</td></tr> 408 <tr><td>MERGE</td><td>25</td></tr> 409 <tr><td>BASELINE_CONTROL</td><td>26</td></tr> 410 <tr><td>MKACTIVITY</td><td>27</td></tr> 411 </table> 412 <p>Later version of ajp13, will transport 413 additional methods, even if they are not in this list.</p> 414 415 <h3>protocol, req_uri, remote_addr, remote_host, server_name, 416 server_port, is_ssl</h3> 417 <p>These are all fairly self-explanatory. Each of these is required, and 418 will be sent for every request.</p> 419 420 <h3>Headers</h3> 421 <p>The structure of <code>request_headers</code> is the following: 422 First, the number of headers <code>num_headers</code> is encoded. 423 Then, a series of header name <code>req_header_name</code> / value 424 <code>req_header_value</code> pairs follows. 425 Common header names are encoded as integers, 426 to save space. If the header name is not in the list of basic headers, 427 it is encoded normally (as a string, with prefixed length). The list of 428 common headers <code>sc_req_header_name</code>and their codes 429 is as follows (all are case-sensitive):</p> 430 <table> 431 <tr><td>Name</td><td>Code value</td><td>Code name</td></tr> 432 <tr><td>accept</td><td>0xA001</td><td>SC_REQ_ACCEPT</td></tr> 433 <tr><td>accept-charset</td><td>0xA002</td><td>SC_REQ_ACCEPT_CHARSET 434 </td></tr> 435 <tr><td>accept-encoding</td><td>0xA003</td><td>SC_REQ_ACCEPT_ENCODING 436 </td></tr> 437 <tr><td>accept-language</td><td>0xA004</td><td>SC_REQ_ACCEPT_LANGUAGE 438 </td></tr> 439 <tr><td>authorization</td><td>0xA005</td><td>SC_REQ_AUTHORIZATION</td> 440 </tr> 441 <tr><td>connection</td><td>0xA006</td><td>SC_REQ_CONNECTION</td></tr> 442 <tr><td>content-type</td><td>0xA007</td><td>SC_REQ_CONTENT_TYPE</td> 443 </tr> 444 <tr><td>content-length</td><td>0xA008</td><td>SC_REQ_CONTENT_LENGTH</td> 445 </tr> 446 <tr><td>cookie</td><td>0xA009</td><td>SC_REQ_COOKIE</td></tr> 447 <tr><td>cookie2</td><td>0xA00A</td><td>SC_REQ_COOKIE2</td></tr> 448 <tr><td>host</td><td>0xA00B</td><td>SC_REQ_HOST</td></tr> 449 <tr><td>pragma</td><td>0xA00C</td><td>SC_REQ_PRAGMA</td></tr> 450 <tr><td>referer</td><td>0xA00D</td><td>SC_REQ_REFERER</td></tr> 451 <tr><td>user-agent</td><td>0xA00E</td><td>SC_REQ_USER_AGENT</td></tr> 452 </table> 453 <p>The Java code that reads this grabs the first two-byte integer and if 454 it sees an <code>'0xA0'</code> in the most significant 455 byte, it uses the integer in the second byte as an index into an array of 456 header names. If the first byte is not <code>0xA0</code>, it assumes that 457 the two-byte integer is the length of a string, which is then read in.</p> 458 <p>This works on the assumption that no header names will have length 459 greater than <code>0x9FFF (==0xA000 - 1)</code>, which is perfectly 460 reasonable, though somewhat arbitrary.</p> 461 <div class="note"><h3>Note:</h3> 462 The <code>content-length</code> header is extremely 463 important. If it is present and non-zero, the container assumes that 464 the request has a body (a POST request, for example), and immediately 465 reads a separate packet off the input stream to get that body. 466 </div> 467 468 <h3>Attributes</h3> 469 <p>The attributes prefixed with a <code>?</code> 470 (e.g. <code>?context</code>) are all optional. For each, there is a 471 single byte code to indicate the type of attribute, and then its value 472 (string or integer). They can be sent in any order (though the C code 473 always sends them in the order listed below). A special terminating code 474 is sent to signal the end of the list of optional attributes. The list of 475 byte codes is:</p> 476 <table> 477 <tr><td>Information</td><td>Code Value</td><td>Type Of Value</td><td>Note</td></tr> 478 <tr><td>?context</td><td>0x01</td><td>-</td><td>Not currently implemented 479 </td></tr> 480 <tr><td>?servlet_path</td><td>0x02</td><td>-</td><td>Not currently implemented 481 </td></tr> 482 <tr><td>?remote_user</td><td>0x03</td><td>String</td><td /></tr> 483 <tr><td>?auth_type</td><td>0x04</td><td>String</td><td /></tr> 484 <tr><td>?query_string</td><td>0x05</td><td>String</td><td /></tr> 485 <tr><td>?jvm_route</td><td>0x06</td><td>String</td><td /></tr> 486 <tr><td>?ssl_cert</td><td>0x07</td><td>String</td><td /></tr> 487 <tr><td>?ssl_cipher</td><td>0x08</td><td>String</td><td /></tr> 488 <tr><td>?ssl_session</td><td>0x09</td><td>String</td><td /></tr> 489 <tr><td>?req_attribute</td><td>0x0A</td><td>String</td><td>Name (the name of the 490 attribute follows)</td></tr> 491 <tr><td>?ssl_key_size</td><td>0x0B</td><td>Integer</td><td /></tr> 492 <tr><td>are_done</td><td>0xFF</td><td>-</td><td>request_terminator</td></tr> 493 </table> 494 <p>The <code>context</code> and <code>servlet_path</code> are not 495 currently set by the C code, and most of the Java code completely ignores 496 whatever is sent over for those fields (and some of it will actually break 497 if a string is sent along after one of those codes). I don't know if this 498 is a bug or an unimplemented feature or just vestigial code, but it's 499 missing from both sides of the connection.</p> 500 <p>The <code>remote_user</code> and <code>auth_type</code> presumably 501 refer to HTTP-level authentication, and communicate the remote user's 502 username and the type of authentication used to establish their identity 503 (e.g. Basic, Digest).</p> 504 <p>The <code>query_string</code>, <code>ssl_cert</code>, 505 <code>ssl_cipher</code>, and <code>ssl_session</code> refer to the 506 corresponding pieces of HTTP and HTTPS.</p> 507 <p>The <code>jvm_route</code>, is used to support sticky 508 sessions -- associating a user's sesson with a particular Tomcat instance 509 in the presence of multiple, load-balancing servers.</p> 510 <p>Beyond this list of basic attributes, any number of other attributes 511 can be sent via the <code>req_attribute</code> code <code>0x0A</code>. 512 A pair of strings to represent the attribute name and value are sent 513 immediately after each instance of that code. Environment values are passed 514 in via this method.</p> 515 <p>Finally, after all the attributes have been sent, the attribute 516 terminator, <code>0xFF</code>, is sent. This signals both the end of the 517 list of attributes and also then end of the Request Packet.</p> 518 519 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> 520 <div class="section"> 521 <h2><a name="resppacketstruct" id="resppacketstruct">Response Packet Structure</a></h2> 522 <p>for messages which the container can send back to the server.</p> 523 <div class="example"><pre>AJP13_SEND_BODY_CHUNK := 524 prefix_code 3 525 chunk_length (integer) 526 chunk *(byte) 527 chunk_terminator (byte) Ox00 528 529 AJP13_SEND_HEADERS := 530 prefix_code 4 531 http_status_code (integer) 532 http_status_msg (string) 533 num_headers (integer) 534 response_headers *(res_header_name header_value) 535 536 res_header_name := 537 sc_res_header_name | (string) [see below for how this is parsed] 538 539 sc_res_header_name := 0xA0 (byte) 540 541 header_value := (string) 542 543 AJP13_END_RESPONSE := 544 prefix_code 5 545 reuse (boolean) 546 547 548 AJP13_GET_BODY_CHUNK := 549 prefix_code 6 550 requested_length (integer)</pre></div> 551 <h3>Details:</h3> 552 <h3>Send Body Chunk</h3> 553 <p>The chunk is basically binary data, and is sent directly back to the 554 browser.</p> 555 556 <h3>Send Headers</h3> 557 <p>The status code and message are the usual HTTP things 558 (e.g. <code>200</code> and <code>OK</code>). The response header names are 559 encoded the same way the request header names are. See header_encoding above 560 for details about how the codes are distinguished from the strings.<br /> 561 The codes for common headers are:</p> 562 <table> 563 <tr><td>Name</td><td>Code value</td></tr> 564 <tr><td>Content-Type</td><td>0xA001</td></tr> 565 <tr><td>Content-Language</td><td>0xA002</td></tr> 566 <tr><td>Content-Length</td><td>0xA003</td></tr> 567 <tr><td>Date</td><td>0xA004</td></tr> 568 <tr><td>Last-Modified</td><td>0xA005</td></tr> 569 <tr><td>Location</td><td>0xA006</td></tr> 570 <tr><td>Set-Cookie</td><td>0xA007</td></tr> 571 <tr><td>Set-Cookie2</td><td>0xA008</td></tr> 572 <tr><td>Servlet-Engine</td><td>0xA009</td></tr> 573 <tr><td>Status</td><td>0xA00A</td></tr> 574 <tr><td>WWW-Authenticate</td><td>0xA00B</td></tr> 575 </table> 576 <p> After the code or the string header name, the header value is 577 immediately encoded.</p> 578 579 <h3>End Response</h3> 580 <p>Signals the end of this request-handling cycle. If the 581 <code>reuse</code> flag is true <code>(anything other than 0 in the actual 582 C code)</code>, this TCP connection can now be used to handle new incoming 583 requests. If <code>reuse</code> is false (==0), the connection should 584 be closed.</p> 585 586 <h3>Get Body Chunk</h3> 587 <p>The container asks for more data from the request (If the body was 588 too large to fit in the first packet sent over or when the request is 589 chunked). The server will send a body packet back with an amount of data 590 which is the minimum of the <code>request_length</code>, the maximum send 591 body size <code>(8186 (8 Kbytes - 6))</code>, and the number of bytes 592 actually left to send from the request body.<br /> 593 If there is no more data in the body (i.e. the servlet container is 594 trying to read past the end of the body), the server will send back an 595 <em>empty</em> packet, which is a body packet with a payload length of 0. 596 <code>(0x12,0x34,0x00,0x00)</code></p> 597 598 </div> 599 </div> 600 <div class="bottomlang"> 601 <p><span>Available Languages: </span><a href="../en/mod/mod_proxy_ajp.html" title="English"> en </a> | 602 <a href="../ja/mod/mod_proxy_ajp.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a></p> 603 </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> 604 <script type="text/javascript"><!--//--><![CDATA[//><!-- 605 var comments_shortname = 'httpd'; 606 var comments_identifier = 'http://httpd.apache.org/docs/2.2/mod/mod_proxy_ajp.html'; 607 (function(w, d) { 608 if (w.location.hostname.toLowerCase() == "httpd.apache.org") { 609 d.write('<div id="comments_thread"><\/div>'); 610 var s = d.createElement('script'); 611 s.type = 'text/javascript'; 612 s.async = true; 613 s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; 614 (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); 615 } 616 else { 617 d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); 618 } 619 })(window, document); 620 //--><!]]></script></div><div id="footer"> 621 <p class="apache">Copyright 2017 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> 622 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.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[//><!-- 623 if (typeof(prettyPrint) !== 'undefined') { 624 prettyPrint(); 625 } 626 //--><!]]></script> 627 </body></html>