⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mod_proxy_ajp.html.en

📁 Apache2.2.4 with OpenSSL 0.9.8e 提供HTTP及HTTPS服务。 带QuickUsage
💻 EN
📖 第 1 页 / 共 2 页
字号:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
              This file is generated from xml source: DO NOT EDIT
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
      -->
<title>mod_proxy_ajp - Apache HTTP Server</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="../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.2</p>
<img alt="" src="../images/feather.gif" /></div>
<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
<div id="path">
<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.2</a> &gt; <a href="./">Modules</a></div>
<div id="page-content">
<div id="preamble"><h1>Apache Module mod_proxy_ajp</h1>
<div class="toplang">
<p><span>Available Languages: </span><a href="../en/mod/mod_proxy_ajp.html" title="English">&nbsp;en&nbsp;</a> |
<a href="../ja/mod/mod_proxy_ajp.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a></p>
</div>
<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>AJP support module for
<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營dentifier:</a></th><td>proxy_ajp_module</td></tr>
<tr><th><a href="module-dict.html#SourceFile">Source燜ile:</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>
<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 
    <code>Apache JServ Protocol version 1.3</code> (hereafter
    <em>AJP13</em>).</p>

    <p>Thus, in order to get the ability of handling <code>AJP13</code>
    protocol, <code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code> and
    <code class="module"><a href="../mod/mod_proxy_ajp.html">mod_proxy_ajp</a></code> have to be present in the server.</p>

    <div class="warning"><h3>Warning</h3>
      <p>Do not enable proxying until you have <a href="mod_proxy.html#access">secured your server</a>. Open proxy
      servers are dangerous both to your network and to the Internet at
      large.</p>
    </div>
</div>
<div id="quickview"><h3 class="directives">Directives</h3>
<p>This module provides no
            directives.</p>
<h3>Topics</h3>
<ul id="topics">
<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 class="seealso">
<li><code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code></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="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
    performance.  The web server communicates with the servlet container over
    TCP connections.  To cut down on the expensive process of socket creation,
    the web server will attempt to maintain persistent TCP connections to the
    servlet container, and to reuse a connection for multiple request/response
    cycles.</p>
    <p>Once a connection is assigned to a particular request, it will not be
    used for any others until the request-handling cycle has terminated.  In
    other words, requests are not multiplexed over connections.  This makes
    for much simpler code at either end of the connection, although it does
    cause more connections to be open at once.</p>
    <p>Once the web server has opened a connection to the servlet container,
    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>
    </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
    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 &gt; 0)</code>, that is sent in a
    separate packet immediately after.</p>
    <p>At this point, the servlet container is presumably ready to start
    processing the request.  As it does so, it can send the
    following messages back to the web server:</p>
    <ul>
    <li>SEND_HEADERS <br />Send a set of headers back to the browser.</li>
    <li>SEND_BODY_CHUNK <br />Send a chunk of body data back to the browser.
    </li>
    <li>GET_BODY_CHUNK <br />Get further data from the request if it hasn't all
    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>
    <li>END_RESPONSE <br /> Finish the request-handling cycle.</li>
    </ul>
    <p>Each message is accompanied by a differently formatted packet of data.
    See Response Packet Structures below for details.</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<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>There are four data types in the protocol: bytes, booleans,
    integers and strings.</p>
    <dl>
    <dt><strong>Byte</strong></dt><dd>A single byte.</dd>
    <dt><strong>Boolean</strong></dt>
      <dd>A single byte, <code>1 = true</code>, <code>0 = false</code>.
      Using other non-zero values as true (i.e. C-style) may work in some places,
      but it won't in others.</dd>
    <dt><strong>Integer</strong></dt>
      <dd>A number in the range of <code>0 to 2^16 (32768)</code>.  Stored in
      2 bytes with the high-order byte first.</dd>
    <dt><strong>String</strong></dt>
      <dd>A variable-sized string (length bounded by 2^16). Encoded with
      the length packed into two bytes first, followed by the string
      (including the terminating '\0').  Note that the encoded length does
      <strong>not</strong> include the trailing '\0' -- it is like
      <code>strlen</code>.  This is a touch confusing on the Java side, which
      is littered with odd autoincrement statements to skip over these
      terminators.  I believe the reason this was done was to allow the C
      code to be extra efficient when reading strings which the servlet
      container is sending back -- with the terminating \0 character, the
      C code can pass around references into a single buffer, without copying.
      if the \0 was missing, the C code would have to copy things out in order
      to get its notion of a string.</dd>
    </dl>

  <h3>Packet Size</h3>
    <p>According to much of the code, the max packet size is <code>
    8 * 1024 bytes (8K)</code>.  The actual length of the packet is encoded in
    the header.</p>
  
  <h3>Packet Headers</h3>
    <p>Packets sent from the server to the container begin with
    <code>0x1234</code>.  Packets sent from the container to the server
    begin with <code>AB</code> (that's the ASCII code for A followed by the
    ASCII code for B).  After those first two bytes, there is an integer
    (encoded as above) with the length of the payload.  Although this might
    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-&gt;Container)</em></td>
      </tr>
      <tr>
        <td>Byte</td>
        <td>0</td>
        <td>1</td>
        <td>2</td>
        <td>3</td>
        <td>4...(n+3)</td>
      </tr>
      <tr>
        <td>Contents</td>
        <td>0x12</td>
        <td>0x34</td>
        <td colspan="2">Data Length (n)</td>
        <td>Data</td>
      </tr>
    </table>
    <table>
      <tr>
        <td colspan="6"><em>Packet Format (Container-&gt;Server)</em></td>
      </tr>
      <tr>
        <td>Byte</td>
        <td>0</td>
        <td>1</td>
        <td>2</td>
        <td>3</td>
        <td>4...(n+3)</td>
      </tr>
      <tr>
        <td>Contents</td>
        <td>A</td>
        <td>B</td>
        <td colspan="2">Data Length (n)</td>
        <td>Data</td>
      </tr>
    </table>
    <p>For most packets, the first byte of the payload encodes the type of
     message.  The exception is for request body packets sent from the server to
     the container -- they are sent with a standard packet header (<code>
     0x1234</code> and then length of the packet), but without any prefix code
     after that.</p>
     <p>The web server can send the following messages to the servlet
     container:</p>
    <table>
      <tr>
        <td>Code</td>
        <td>Type of Packet</td>
        <td>Meaning</td>
      </tr>
      <tr>
        <td>2</td>
        <td>Forward Request</td>
        <td>Begin the request-processing cycle with the following data</td>
      </tr>
      <tr>
        <td>7</td>
        <td>Shutdown</td>
        <td>The web server asks the container to shut itself down.</td>
      </tr>
      <tr>
        <td>8</td>
        <td>Ping</td>
        <td>The web server asks the container to take control
        (secure login phase).</td>
      </tr>
      <tr>
        <td>10</td>
        <td>CPing</td>
        <td>The web server asks the container to respond quickly with a CPong.
        </td>
      </tr>
      <tr>
        <td>none</td>
        <td>Data</td>
        <td>Size (2 bytes) and corresponding body data.</td>
      </tr>
    </table>
    <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
    <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>
        <td>Meaning</td>
      </tr>
      <tr>
        <td>3</td>
        <td>Send Body Chunk</td>
        <td>Send a chunk of the body from the servlet container to the web
        server (and presumably, onto the browser). </td>
      </tr>
      <tr>
        <td>4</td>
        <td>Send Headers</td>
        <td>Send the response headers from the servlet container to the web
        server (and presumably, onto the browser).</td>
      </tr>
      <tr>
        <td>5</td>
        <td>End Response</td>
        <td>Marks the end of the response (and thus the request-handling cycle).
        </td>
      </tr>
      <tr>
        <td>6</td>
        <td>Get Body Chunk</td>
        <td>Get further data from the request if it hasn't all been
        transferred yet.</td>
      </tr>
      <tr>
        <td>9</td>
        <td>CPong Reply</td>
        <td>The reply to a CPing request</td>
      </tr>
    </table>
    <p>Each of the above messages has a different internal structure, detailed

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -