1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/TR/xhtml1/strict">
<head>
<title>AJPv13 extensions Proposal</title>
<meta content="1999-2003 The Apache Software Foundation" name="copyright"/>
<meta content="$Date: 2002/09/20 21:35:31 $" name="last-changed"/>
<meta content="Henri Gomez" name="author"/>
<meta content="hgomez@apache.org" name="email"/>
<link href="..//style.css" type="text/css" rel="stylesheet"/>
<link href="../images/tomcat.ico" rel="shortcut icon"/>
</head>
<body link="#525D76" vlink="#525D76" alink="#525D76" text="#000000" bgcolor="#ffffff">
<a name="TOP"/>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr height="1">
<td class="nil" height="1" bgcolor="#ffffff" width="150">
<img hspace="0" vspace="0" height="1" width="150" border="0" src="../images/pixel.gif"/>
</td>
<td class="nil" height="1" bgcolor="#ffffff" width="*">
<img hspace="0" vspace="0" height="1" width="370" border="0" src="../images/pixel.gif"/>
</td>
</tr>
<tr>
<td width="*" colspan="2" class="logo" bgcolor="#ffffff">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left">
<img align="left" height="48" width="505" border="0" src="../images/jakarta.gif"/>
</td>
<td align="right">
<img align="right" border="0" src="../images/mod_jk.jpg"/>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2" width="*" align="right" class="head" bgcolor="#999999">
<nobr>
<a href="http://www.apache.org/" class="head">Apache Software Foundation</a> |
<a href="http://jakarta.apache.org/" class="head">Jakarta Project</a> |
<a href="http://jakarta.apache.org/tomcat/" class="head">Apache Tomcat</a>
</nobr>
</td>
</tr>
<tr>
<td valign="top" width="150" bgcolor="#ffffff">
<table class="menu" cellpadding="0" cellspacing="0" width="150" border="0">
<tr height="1">
<td class="nil" height="1" bgcolor="#cccccc" width="10">
<img hspace="0" vspace="0" height="1" width="10" border="0" src="../images/pixel.gif"/>
</td>
<td class="nil" height="1" bgcolor="#cccccc" width="140">
<img hspace="0" vspace="0" height="1" width="140" border="0" src="../images/pixel.gif"/>
</td>
</tr>
<tr height="6">
<td colspan="2" width="150" bgcolor="#d0d0d0">Presentation</td>
</tr>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../index.html">Overview</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr height="6"/>
<tr height="6">
<td colspan="2" width="150" bgcolor="#d0d0d0">Commons</td>
</tr>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../common/AJPv13.html">AJPv13</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../common/AJPv13-extensions-proposal.html">AJPv13 extensions Proposal</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td width="10" bgcolor="#cccccc"/>
<td width="140" bgcolor="#cccccc">
<a href="#Introduction" class="menu">Introduction</a>
</td>
</tr>
<tr height="1"/>
<tr>
<td width="10" bgcolor="#cccccc"/>
<td width="140" bgcolor="#cccccc">
<a href="#Conclusion" class="menu">Conclusion</a>
</td>
</tr>
<tr height="1"/>
<tr>
<td width="10" bgcolor="#cccccc"/>
<td width="140" bgcolor="#cccccc">
<a href="#Commands and IDs in extended AJP13 Index" class="menu">Commands and IDs in extended AJP13 Index</a>
</td>
</tr>
<tr height="1"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../common/doccontrib.html">How to Contribute to the Documentation</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../common/tools.html">Tools</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../faq.html">FAQ</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr height="6"/>
<tr height="6">
<td colspan="2" width="150" bgcolor="#d0d0d0">JK</td>
</tr>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk/quickhowto.html">Quick Start HowTo</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk/aphowto.html">Apache HowTo</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk/domhowto.html">Domino HowTo</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk/iishowto.html">IIS HowTo</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk/neshowto.html">Netscape/iPlanet HowTo</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk/workershowto.html">Workers HowTo</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr height="6"/>
<tr height="6">
<td colspan="2" width="150" bgcolor="#d0d0d0">JK2</td>
</tr>
<tr height="6"/>
<tr height="6">
<td colspan="2" width="150" bgcolor="#d0d0d0">Configuration in the Tomcat</td>
</tr>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk2/configtc.html">Configuration options</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk2/configtccom.html">Coyote/JK2 Handlers</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk2/configtcex.html">Examples</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr height="6"/>
<tr height="6">
<td colspan="2" width="150" bgcolor="#d0d0d0">Configuration in the Web Server</td>
</tr>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk2/configweb.html">Configuration file</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk2/configwebcom.html">Components</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk2/configwebex.html">Examples</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr height="6"/>
<tr height="6">
<td colspan="2" width="150" bgcolor="#d0d0d0">Installation</td>
</tr>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk2/installhowto.html">Installation of jk2 in the Web Server</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr height="6"/>
<tr height="6">
<td colspan="2" width="150" bgcolor="#d0d0d0">Howto</td>
</tr>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk2/confighowto.html">Quick Start JK2 Configuration Guide</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk2/vhosthowto.html">Apache 2.0.43 - Tomcat 4.1.12 - jk2 - virtual host HOWTO</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr height="6"/>
</table>
</td>
<td class="body" valign="top" width="*" bgcolor="#ffffff">
<a name="Introduction">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="section" bgcolor="#525D76">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Introduction</td>
</tr>
</table>
</a>
<p class="section">
This document is a proposal of evolution of the current
Apache JServ Protocol version 1.3, also known as ajp13.
I'll not cover here the full protocol but only the add-on from ajp13.
This nth pass include comments from the tomcat-dev list and
misses discovered during developpment.
</p>
<a name="sub_Missing features in AJP13">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Missing features in AJP13</td>
</tr>
</table>
</a>
<p class="section">
ajp13 is a good protocol to link a servlet engine like tomcat to a web server like Apache:
<ul>
<li>
use persistants connections to avoid reconnect time at each request
</li>
<li>
encode many http commands to reduce stream size
</li>
<li>
send to servlet engine many info from web server (like SSL certs)
</li>
</ul>
<ul>
<li>
security between web server and servlet engine.
Anybody can connect to an ajp13 port (no login mecanism used)
You could connect, for example with telnet, and keep the remote thread
up by not sending any data (no timeout in connection)
</li>
<li>
context information passed from servlet engine to web server.
Part of the configuration of JK, the web server connector, is to
indicate to the web server which URI to handle.
The mod_jk JkMount directive, told to web server which URI must be
forwarded to servlet engine.
A servlet engine allready knows which URI it handle and TC 3.3 is
allready capable to generate a config file for JK from the list
of available contexts.
</li>
<li>
state update of contexts from servlet engine to web server.
Big site with farm of Tomcat, like ISP and virtuals hosters,
may need to stop a context for admin purposes. In that case the front
web server must know that the context is currently down, to eventually
relay the request to another Tomcat
</li>
<li>
verify state of connection before sending request.
Actually JK send the request to the servlet engine and next wait
for the answer. But one of the beauty of the socket API, is you that
you could write() to a closed connection without any error reporting,
but a read() to a closed connection return you the error code.
</li>
</ul>
</p>
<br/>
<a name="sub_Proposed add-ons to AJP13">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Proposed add-ons to AJP13</td>
</tr>
</table>
</a>
<p class="section">
Let's descrive here the features and add-on that could be added to AJP13.
Since this document is a proposal, a reasonable level of chaos must be expected at first.
Be sure that discussion on tomcat list will help clarify points, add
features but the current list seems to be a 'minimun vital'
<ul>
<li>
Advanced login features at connect time
</li>
<li>
Basic authorisation system, where a shared secret key is
present in web server and servlet engine.
</li>
<li>
Basic protocol negociation, just to be sure that if functionnalities are added
to AJP13 in the future, current implementations will still works.
</li>
<li>
Clean handling of 'Unknown packets'
</li>
<li>
Extended env vars passed from web-server to servlet engine.
</li>
<li>
Add extra SSL informations needed by Servlet 2.3 API (like SSL_KEY_SIZE)
</li>
</ul>
</p>
<br/>
<a name="sub_Advanced login">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Advanced login</td>
</tr>
</table>
</a>
<p class="section">
<ol>
<li>
WEB-SERVER send LOGIN INIT CMD + NEGOCIATION DATA + WEB SERVER INFO
</li>
<li>
TOMCAT respond with LOGIN SEED CMD + RANDOM DATA
</li>
<li>
WEB-SERVER calculted the MD5 of RANDOM DATA+SECRET DATA
</li>
<li>
WEB-SERVER send LOGIN COMP CMD + MD5 (SECRET DATA + RANDOM DATA)
</li>
<li>
TOMCAT respond with LOGIN STATUS CMD + NEGOCIED DATA + SERVLET ENGINE INFO
</li>
</ol>
To prevent DOS attack, the servlet engine will wait
the LOGIN CMD only 15/30 seconds and reports the
timeout exception for admins investigation.
The login command will contains basic protocol
negociation information like compressing ability,
crypto, context info (at start up), context update at
run-time (up/down), level of SSL env vars, AJP protocol
level supported (level1/level2/level3...)
The Web server info will contain web server info and
connector name (ie Apache 1.3.26 + mod_ssl 2.8.8 + mod_jk 1.2.1 + mod_perl 1.25).
The servlet engine will mask the negociation mask with it's own
mask (what it can do) and return it when loggin is accepted.
This will help having a basic AJP13 implementation (level 1)
on a web-server working with a more advanced protocol handler on
the servlet engine side or vice-versa.
AJP13 was designed to be small and fast and so many
SSL informations present in the web-server are not
forwarded to the servlet engine.
We add here four negociations flags to provide more
informations on client SSL data (certs), server SSL datas,
crypto used, and misc datas (timeout...).
</p>
<br/>
<a name="sub_Messages Stream">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Messages Stream</td>
</tr>
</table>
</a>
<p class="section">
<pre class="section">
+----------------+------------------+-----------------+
| LOGIN INIT CMD | NEGOCIATION DATA | WEB SERVER INFO |
+----------------+------------------+-----------------+
+----------------+----------------+
| LOGIN SEED CMD | MD5 of entropy |
+----------------+----------------+
+----------------+----------------------------+
| LOGIN COMP CMD | MD5 of RANDOM + SECRET KEY |
+----------------+----------------------------+
+-----------+---------------+---------------------+
| LOGOK CMD | NEGOCIED DATA | SERVLET ENGINE INFO |
+-----------+---------------+---------------------+
+------------+--------------+
| LOGNOK CMD | FAILURE CODE |
+------------+--------------+
</pre>
<ul>
<li>
LOGIN INIT CMD, LOGIN SEED CMD, LOGIN COMP CMD, LOGOK CMD, LOGNOK CMD are 1 byte long.
</li>
<li>
MD5, MD5 of RANDOM + SECRET KEY are 32 chars long.
</li>
<li>
NEGOCIATION DATA, NEGOCIED DATA, FAILURE CODE are 32 bits long.
</li>
<li>
WEB SERVER INFO, SERVLET ENGINE INFO are CString.
</li>
</ul>
The secret key will be set by a new propertie in
workers.properties : secretkey
<pre class="section">
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.secretkey=myverysecretkey
</pre>
</p>
<br/>
<a name="sub_Shutdown feature">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Shutdown feature</td>
</tr>
</table>
</a>
<p class="section">
AJP13 miss a functionnality of AJP12, which is shutdown command.
A logout will tell servlet engine to shutdown itself.
<pre class="section">
+--------------+----------------------------+
| SHUTDOWN CMD | MD5 of RANDOM + SECRET KEY |
+--------------+----------------------------+
+------------+
| SHUTOK CMD |
+------------+
+-------------+--------------+
| SHUTNOK CMD | FAILURE CODE |
+-------------+--------------+
</pre>
<ul>
<li>
SHUTDOWN CMD, SHUTOK CMD, SHUTNOK CMD are 1 byte long.
</li>
<li>
MD5 of RANDOM + SECRET KEY are 32 chars long.
</li>
<li>
FAILURE CODE is 32 bits long.
</li>
</ul>
</p>
<br/>
<a name="sub_Extended Env Vars feature">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Extended Env Vars feature</td>
</tr>
</table>
</a>
<p class="section">
NOTA:
While working on AJP13 in JK, I really discovered "JkEnvVar".
The following "Extended Env Vars feature" description may not
be implemented in extended AJP13 since allready available in original
implementation.
DESC:
Many users will want to see some of their web-server env vars
passed to their servlet engine.
To reduce the network traffic, the web-servlet will send a
table to describing the external vars in a shorter fashion.
We'll use there a functionnality allready present in AJP13,
attributes list :
In the AJP13, we've got :
<pre class="section">
AJP13_FORWARD_REQUEST :=
prefix_code 2
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)
?context (byte string)
?servlet_path (byte string)
?remote_user (byte string)
?auth_type (byte string)
?query_string (byte string)
?jvm_route (byte string)
?ssl_cert (byte string)
?ssl_cipher (byte string)
?ssl_session (byte string)
?attributes *(attribute_name attribute_value)
request_terminator (byte)
</pre>
Using short 'web server attribute name' will reduce the
network traffic.
<pre class="section">
+-------------------+---------------------------+-------------------------------+----+
| EXTENDED VARS CMD | WEB SERVER ATTRIBUTE NAME | SERVLET ENGINE ATTRIBUTE NAME | ES |
+-------------------+---------------------------+-------------------------------+----+
</pre>
ie :
<pre class="section">
JkExtVars S1 SSL_CLIENT_V_START javax.servlet.request.ssl_start_cert_date
JkExtVars S2 SSL_CLIENT_V_END javax.servlet.request.ssl_end_cert_date
JkExtVars S3 SSL_SESSION_ID javax.servlet.request.ssl_session_id
+-------------------+----+-------------------------------------------+
| EXTENDED VARS CMD | S1 | javax.servlet.request.ssl_start_cert_date |
+-------------------+----+-------------------------------------------+
+----+-----------------------------------------+
| S2 | javax.servlet.request.ssl_end_cert_date |
+----+-----------------------------------------+
+----+-----------------------------------------+
| S3 | javax.servlet.request.ssl_end_cert_date |
+----+-----------------------------------------+
</pre>
During transmission in extended AJP13 we'll see attributes name
containing S1, S2, S3 and attributes values of
2001/01/03, 2002/01/03, 0123AFE56.
This example showed the use of extended SSL vars but
any 'personnal' web-server vars like custom authentification
vars could be reused in the servlet engine.
The cost will be only some more bytes in the AJP traffic.
<ul>
<li>
EXTENDED VARS CMD is 1 byte long.
</li>
<li>
WEB SERVER ATTRIBUTE NAME, SERVLET ENGINE ATTRIBUTE NAME are CString.
</li>
<li>
ES is an empty CString.
</li>
</ul>
</p>
<br/>
<a name="sub_Context informations forwarding for Servlet engine to Web Server">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Context informations forwarding for Servlet engine to Web Server</td>
</tr>
</table>
</a>
<p class="section">
Just after the LOGON PHASE, the web server will ask for the list of contexts
and URLs/URIs handled by the servlet engine.
It will ease installation in many sites, reduce questions about configuration
on tomcat-user list, and be ready for servlet API 2.3.
This mode will be activated by a new directive JkAutoMount
ie: JkAutoMount examples myworker1 /examples/
If we want to get ALL the contexts handled by the servlet engine, willcard
could be used :
ie: JkAutoMount * myworker1 *
A servlet engine could have many contexts, /examples, /admin, /test.
We may want to use only some contexts for a given worker. It was
done previously, in apache HTTP server for example, by setting by
hand the JkMount accordingly in each [virtual] area of Apache.
If you web-server support virtual hosting, we'll forward also that
information to servlet engine which will only return contexts for
that virtual host.
In that case the servlet engine will only return the URL/URI matching
these particular virtual server (defined in server.xml).
This feature will help ISP and big sites which mutualize large farm
of Tomcat in load-balancing configuration.
<pre class="section">
+-----------------+-------------------+----------+----------+----+
| CONTEXT QRY CMD | VIRTUAL HOST NAME | CONTEXTA | CONTEXTB | ES |
+-----------------+-------------------+----------+----------+----+
+------------------+-------------------+----------+-------------------+----------+---------------+----+
| CONTEXT INFO CMD | VIRTUAL HOST NAME | CONTEXTA | URL1 URL2 URL3 ES | CONTEXTB | URL1 URL2 ... | ES |
+------------------+-------------------+----------+-------------------+----------+---------------+----+
</pre>
We'll discover via context-query, the list of URL/MIMES handled by the remove servlet engine
for a list of contextes.
In wildcard mode, CONTEXTA will contains just '*'.
<ul>
<li>
CONTEXT QRY CMD and CONTEXT INFO CMD are 1 byte long.
</li>
<li>
VIRTUAL HOST NAME is a CString, ie an array of chars terminated by a null byte (/0).
</li>
<li>
An empty string is just a null byte (/0).
</li>
<li>
ES is an empty CString. Indicate end of URI/URLs or end of CONTEXTs.
</li>
</ul>
NB:<br/>
When VirtualMode is not to be used, the VIRTUAL HOST NAME is '*'.
In that case the servlet engine will send all contexts handled.
</p>
<br/>
<a name="sub_Context informations updates from Servlet engine to Web Server">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Context informations updates from Servlet engine to Web Server</td>
</tr>
</table>
</a>
<p class="section">
Context update are messages caming from the servlet engine each time a context
is desactivated/reactivated. The update will be in use when the directive JkUpdateMount.
This directive will set the AJP13_CONTEXT_UPDATE_NEG flag.
ie: JkUpdateMount myworker1
<pre class="section">
+--------------------+-------------------+----------+--------+----------+--------+----+
| CONTEXT UPDATE CMD | VIRTUAL HOST NAME | CONTEXTA | STATUS | CONTEXTB | STATUS | ES |
+--------------------+-------------------+----------+--------+----------+--------+----+
</pre>
<ul>
<li>
CONTEXT UPDATE CMD, STATUS are 1 byte long.
</li>
<li>
VIRTUAL HOST NAME, CONTEXTS are CString.
</li>
<li>
ES is an empty CString. Indicate end of CONTEXTs.
</li>
</ul>
NB:<br/>
When VirtualMode is not in use, the VIRTUAL HOST NAME is '*'.
STATUS is one byte indicating if context is UP/DOWN/INVALID
</p>
<br/>
<a name="sub_Context status query to Servlet engine">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Context status query to Servlet engine</td>
</tr>
</table>
</a>
<p class="section">
This query will be used by the web-server to determine if a given
contexts are UP, DOWN or INVALID (and should be removed).
<pre class="section">
+-------------------+--------------------+----------+----------+----+
| CONTEXT STATE CMD | VIRTUAL HOST NAME | CONTEXTA | CONTEXTB | ES |
+-------------------+--------------------+----------+----------+----+
+-------------------------+-------------------+----------+--------+----------+--------+----+
| CONTEXT STATE REPLY CMD | VIRTUAL HOST NAME | CONTEXTA | STATUS | CONTEXTB | STATUS | ES |
+-------------------------+-------------------+----------+-------------------+--------+----+
</pre>
<ul>
<li>
CONTEXT STATE CMD, CONTEXT STATE REPLY CMD, STATUS are 1 byte long.
</li>
<li>
VIRTUAL HOST NAME, CONTEXTs are CString
</li>
<li>
ES is an empty CString
</li>
</ul>
NB:<br/>
When VirtualMode is not in use, the VIRTUAL HOST NAME is an empty string.
</p>
<br/>
<a name="sub_Handling of unknown packets">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Handling of unknown packets</td>
</tr>
</table>
</a>
<p class="section">
Sometimes even with a well negocied protocol, we may be in a situation
where one end (web server or servlet engine), will receive a message it
couldn't understand. In that case the receiver will send an
'UNKNOW PACKET CMD' with attached the unhandled message.
<pre class="section">
+--------------------+------------------------+-------------------+
| UNKNOWN PACKET CMD | UNHANDLED MESSAGE SIZE | UNHANDLED MESSAGE |
+--------------------+------------------------+-------------------+
</pre>
Depending on the message, the sender will report an error and if
possible will try to forward the message to another endpoint.
<ul>
<li>
UNKNOWN PACKET CMD is 1 byte long.
</li>
<li>
UNHANDLED MESSAGE SIZE is 16bits long.
</li>
<li>
UNHANDLED MESSAGE is an array of byte (length is contained in UNHANDLED MESSAGE SIZE)
</li>
</ul>
NB:<br/>
added UNHANDLED MESSAGE SIZE (development)
</p>
<br/>
<a name="sub_Verification of connection before sending request">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Verification of connection before sending request</td>
</tr>
</table>
</a>
<p class="section">
NOTA: This fonctionality may never be used, since it may slow up the normal process
since requiring on the web-server side an extra IO (read) before forwarding
the request.....
One of the beauty of socket APIs, is that you could write on a half closed socket.
When servlet engine close the socket, the web server will discover it only at the
next read() to the socket.
Basically, in the AJP13 protocol, the web server send the HTTP HEADER and HTTP BODY
(POST by chunk of 8K) to the servlet engine and then try to receive the reply.
If the connection was broken the web server will learn it only at receive time.
We could use a buffering scheme but what happen when you use the servlet engine
for upload operations with more than 8ko of datas ?
The hack in the AJP13 protocol is to add some bytes to read after the end of the
service :
<pre class="section">
EXAMPLE OF DISCUSSION BETWEEN WEB SERVER AND SERVLET ENGINE
AJP HTTP-HEADER (+ HTTP-POST) (WEB->SERVLET)
AJP HTTP-REPLY (SERVLET->WEB)
AJP END OF DISCUSSION (SERVLET->WEB)
---> AJP STATUS (SERVLET->WEB AJP13)
</pre>
The AJP STATUS will not be read by the servlet engine at the end of
the request/response #N but at the begining of the next session.
More at that time the web server could also use OS dependants functions
(or better APR functions) to determine if there is also more data
to read. And that datas could be CONTEXT Updates.
This will avoid the web server sending a request to a
desactivated context. In that case, if the load-balancing is used,
it will search for another servlet engine to handle the request.
And that feature will help ISP and big sites with farm of tomcat,
to updates their servlet engine without any service interruption.
<pre class="section">
+------------+-------------+
| STATUS CMD | STATUS DATA |
+------------+-------------+
</pre>
<ul>
<li>
STATUS CMD and STATUS DATA are one byte long.
</li>
</ul>
</p>
<br/>
<br/>
<a name="Conclusion">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="section" bgcolor="#525D76">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Conclusion</td>
</tr>
</table>
</a>
<p class="section">
The goal of the extended AJP13 protocol is to overcome some of the original AJP13 limitation.
An easier configuration, a better support for large site and farm of Tomcat,
a simple authentification system and provision for protocol updates.
Using the stable ajp13 implementation in JK (native) and in servlet
engine (java), it's a reasonable evolution of the well known ajp13.
</p>
<br/>
<a name="Commands and IDs in extended AJP13 Index">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="section" bgcolor="#525D76">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Commands and IDs in extended AJP13 Index</td>
</tr>
</table>
</a>
<p class="section">
Index of Commands and ID to be added in AJP13 Protocol
</p>
<a name="sub_Commands IDs">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Commands IDs</td>
</tr>
</table>
</a>
<p class="section">
<table border="0">
<tr>
<td align="middle" valign="top" bgcolor="#039acc">Command Name</td>
<td align="middle" valign="top" bgcolor="#039acc">Command Number</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_LOGINIT_CMD</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x10</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_LOGSEED_CMD</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x11</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_LOGCOMP_CMD</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x12</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_LOGOK_CMD</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x13</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_LOGNOK_CMD</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x14</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_CONTEXT_QRY_CMD</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x15</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_CONTEXT_INFO_CMD</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x16</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_CONTEXT_UPDATE_CMD</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x17</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_STATUS_CMD</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x18</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_SHUTDOWN_CMD</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x19</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_SHUTOK_CMD</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x1A</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_SHUTNOK_CMD</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x1B</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_CONTEXT_STATE_CMD</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x1C</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_CONTEXT_STATE_REP_CMD</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x1D</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_UNKNOW_PACKET_CMD</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x1E</td>
</tr>
</table>
</p>
<br/>
<a name="sub_Negociations Flags">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Negociations Flags</td>
</tr>
</table>
</a>
<p class="section">
<table border="0">
<tr>
<td align="middle" valign="top" bgcolor="#039acc">Command Name</td>
<td align="middle" valign="top" bgcolor="#039acc">Number</td>
<td align="middle" valign="top" bgcolor="#039acc">Description</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_CONTEXT_INFO_NEG</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x80000000</td>
<td align="left" valign="top" bgcolor="#a0ddf0">web-server want context info after login</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_CONTEXT_UPDATE_NEG</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x40000000</td>
<td align="left" valign="top" bgcolor="#a0ddf0">web-server want context updates</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_GZIP_STREAM_NEG</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x20000000</td>
<td align="left" valign="top" bgcolor="#a0ddf0">web-server want compressed stream</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_DES56_STREAM_NEG</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x10000000</td>
<td align="left" valign="top" bgcolor="#a0ddf0">web-server want crypted DES56 stream with secret key</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_SSL_VSERVER_NEG</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x08000000</td>
<td align="left" valign="top" bgcolor="#a0ddf0">Extended info on server SSL vars</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_SSL_VCLIENT_NEG</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x04000000</td>
<td align="left" valign="top" bgcolor="#a0ddf0">Extended info on client SSL vars</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_SSL_VCRYPTO_NEG</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x02000000</td>
<td align="left" valign="top" bgcolor="#a0ddf0">Extended info on crypto SSL vars</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_SSL_VMISC_NEG</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x01000000</td>
<td align="left" valign="top" bgcolor="#a0ddf0">Extended info on misc SSL vars</td>
</tr>
</table>
<br/>
<table border="0">
<tr>
<td align="middle" valign="top" bgcolor="#039acc">Negociation ID</td>
<td align="middle" valign="top" bgcolor="#039acc">Number</td>
<td align="middle" valign="top" bgcolor="#039acc">Description</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_PROTO_SUPPORT_AJPXX_NEG</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x00FF0000</td>
<td align="left" valign="top" bgcolor="#a0ddf0">mask of protocol supported</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_PROTO_SUPPORT_AJP13L1_NEG</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x00010000</td>
<td align="left" valign="top" bgcolor="#a0ddf0">communication could use AJP13 Level 1</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_PROTO_SUPPORT_AJP13L2_NEG</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x00020000</td>
<td align="left" valign="top" bgcolor="#a0ddf0">communication could use AJP13 Level 2</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_PROTO_SUPPORT_AJP13L3_NEG</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x00040000</td>
<td align="left" valign="top" bgcolor="#a0ddf0">communication could use AJP13 Level 3</td>
</tr>
</table>
<br/>
All others flags must be set to 0 since they are reserved for future use.
</p>
<br/>
<a name="sub_Failure IDs">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Failure IDs</td>
</tr>
</table>
</a>
<p class="section">
<table border="0">
<tr>
<td align="middle" valign="top" bgcolor="#039acc">Failure Id</td>
<td align="middle" valign="top" bgcolor="#039acc">Number</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_BAD_KEY_ERR</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0xFFFFFFFF</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_ENGINE_DOWN_ERR</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0xFFFFFFFE</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_RETRY_LATER_ERR</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0xFFFFFFFD</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_SHUT_AUTHOR_FAILED_ERR</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0xFFFFFFFC</td>
</tr>
</table>
</p>
<br/>
<a name="sub_Status">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Status</td>
</tr>
</table>
</a>
<p class="section">
<table border="0">
<tr>
<td align="middle" valign="top" bgcolor="#039acc">Failure Id</td>
<td align="middle" valign="top" bgcolor="#039acc">Number</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_CONTEXT_DOWN</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x01</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_CONTEXT_UP</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x02</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">AJP13_CONTEXT_OK</td>
<td align="left" valign="top" bgcolor="#a0ddf0">0x03</td>
</tr>
</table>
</p>
<br/>
<br/>
</td>
</tr>
</table>
</body>
</html>
|