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

📄 mod_proxy_ajp.html

📁 这个是我在web培训时老师提供的手册
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="keywords" content="Apache, 中文, 手册, 中文版, 中文手册, 中文版手册, 参考手册, 中文参考手册, 金步国" />
<meta name="description" content="Apache 2.2 中文版参考手册" />
<meta name="author" content="金步国" />
<link href="../style/css/manual-zip.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
<link href="../style/css/manual-zip-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" />
<title>mod_proxy_ajp - Apache 2.2 中文版参考手册</title>
</head>
<body><div id="page-header">
<p class="menu"><a href="../mod/index.html">模块索引</a> | <a href="../mod/directives.html">指令索引</a> | <a href="../faq/index.html">常见问题</a> | <a href="../glossary.html">词汇表</a> | <a href="../sitemap.html">站点导航</a></p><p class="apache">Apache HTTP Server 版本2.2</p><img alt="" src="../images/feather.gif" /></div>
<div class="up"><a href="./index.html"><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/">文档</a> &gt; <a href="../index.html">版本2.2</a> &gt; <a href="./index.html">模块</a></div>

<div id="translation-info">   <a href="../translator_announcement.html#thanks">致谢</a> | <a href="../translator_announcement.html#announcement">译者声明</a> | 本篇译者:&lt;<a href="../translator_announcement.html#join">虚位以待</a>&gt; | 本篇译稿完成时间:?年?月?日 | <a href="../translator_announcement.html#last_new">获取最新版本</a></div>
<div id="page-content"><div id="preamble"><h1>Apache模块 mod_proxy_ajp</h1>

<table border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA" class="module">
<tr><th><a href="module-dict.html#Description">说明</a></th><td><code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code>的扩展,提供Apache JServ Protocol支持</td></tr>
<tr><th><a href="module-dict.html#Status">状态</a></th><td>扩展(E)</td></tr>
<tr><th><a href="module-dict.html#ModuleIdentifier">模块名</a></th><td>proxy_ajp_module</td></tr>
<tr><th><a href="module-dict.html#SourceFile">源文件</a></th><td>proxy_ajp.c</td></tr>
<tr><th><a href="module-dict.html#Compatibility">兼容性</a></th><td>仅在 Apache 2.1 及以后的版本中可用</td></tr>
</table>
<h3>概述</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>和<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>警告</h3>
      <p>在您没有<a href="mod_proxy.html#access">对您的服务器采取安全措施</a>之前,不要启用代理。开放的代理服务器对你自己的内部网络和大规模的Internet网都是有安全隐患的。</p>
    </div>
</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><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 border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA">
<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 border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA">
<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 border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA">
<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 border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA">
<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
    below.</p>
  
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<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 :=
    prefix_code      (byte) 0x02 = JK_AJP13_FORWARD_REQUEST
    method           (byte)
    protocol         (string)
    req_uri          (string)
    remote_addr      (string)
    remote_host      (string)
    server_name      (string)
    server_port      (integer)
    is_ssl           (boolean)
    num_headers      (integer)
    request_headers *(req_header_name req_header_value)
    attributes      *(attribut_name attribute_value)
    request_terminator (byte) OxFF
    </pre></div>
    <p><code>request_headers</code> have the following structure:
    </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>
    <p><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)

    </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>
  <h3>Detailed description of the elements of Forward Request
  </h3>
  <h3>Request prefix</h3>
    <p>For all requests, this will be 2. See above for details on other Prefix

⌨️ 快捷键说明

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