architecture.html 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>Architecture</title>
  5. <!-- Copyright Embedthis Software. All Rights Reserved. -->
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  7. <meta charset="utf-8" />
  8. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  9. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  10. <meta name="description" content="Simple, fast, secure embedded web server" />
  11. <link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Open+Sans:300italic,400,300,700'
  12. rel='stylesheet' type='text/css'>
  13. <link href='https://fonts.googleapis.com/css?family=Julius+Sans+One' rel='stylesheet' type='text/css'>
  14. <link href="../images/favicon.ico" rel="shortcut icon" />
  15. <link href="../lib/semantic-ui/semantic.min.css" rel="stylesheet" type="text/css" />
  16. <link href="../css/all.min.css" rel="stylesheet" type="text/css" />
  17. <link href="../css/api.min.css" rel="stylesheet" type="text/css" />
  18. </head>
  19. <body class="show-sidebar">
  20. <div class="sidebar">
  21. <div class="ui large left vertical inverted labeled menu">
  22. <div class="item">
  23. <a href="../" class="logo">GoAhead Docs</a>
  24. </div>
  25. <div class="item">
  26. <a href="../">
  27. <b>General</b>
  28. </a>
  29. <div class="menu">
  30. <a class="item" href="../">GoAhead Overview</a>
  31. <a class="item" href="../users/features.html">GoAhead Features</a>
  32. <a class="item" href="https://embedthis.com/goahead/download.html">Download</a>
  33. <a class="item" href="../licensing/">Licensing</a>
  34. </div>
  35. </div>
  36. <div class="item">
  37. <a href="../start/">
  38. <b>Getting Started</b>
  39. </a>
  40. <div class="menu">
  41. <a class="item" href="../start/quick.html">Quick Start</a>
  42. <a class="item" href="../start/installing.html">Installing GoAhead</a>
  43. <a class="item" href="../start/running.html">Running GoAhead</a>
  44. <a class="item" href="../start/releaseNotes.html">Release Notes</a>
  45. <a class="item" href="../start/faq.html">GoAhead FAQ</a>
  46. <a class="item" href="../start/source.html">Building from Source</a>
  47. </div>
  48. </div>
  49. <div class="item">
  50. <a href="../users/"><b>User's Guide</b></a>
  51. <div class="menu">
  52. <a class="item" href="../users/ports.html">Ports and Binding</a>
  53. <a class="item" href="../users/routing.html">Routing Requests</a>
  54. <a class="item" href="../users/handlers.html">Request Handlers</a>
  55. <a class="item" href="../users/js.html">Embedded Javascript</a>
  56. <a class="item" href="../users/jst.html">Javascript Templates</a>
  57. <a class="item" href="../users/goactions.html">GoActions</a>
  58. <a class="item" href="../users/cgi.html">CGI Programs</a>
  59. <a class="item" href="../users/authentication.html">User Authentication</a>
  60. <a class="item" href="../users/logFiles.html">Log Files</a>
  61. <a class="item" href="../users/ssl.html">Secure Sockets (SSL)</a>
  62. <a class="item" href="../users/security.html">Security Considerations</a>
  63. <a class="item" href="../users/man.html">Man Pages</a>
  64. </div>
  65. </div>
  66. <div class="item">
  67. <a href="../developers/">Developer's Guide</a>
  68. <div class="menu">
  69. <a class="item" href="../developers/embedding.html">Embedding GoAhead</a>
  70. <a class="item" href="../developers/handlers.html">Creating GoAhead Handlers</a>
  71. <a class="item" href="../developers/authstore.html">Creating Password Verifiers</a>
  72. <a class="item" href="../developers/migrating.html">Migrating to GoAhead 3</a>
  73. <a class="item" href="../developers/rom.html">Serving Pages from ROM</a>
  74. </div>
  75. </div>
  76. <div class="item">
  77. <a href="../ref/">Reference Guide</a>
  78. <div class="menu">
  79. <a class="item" href="../ref/compatibility.html">Compatibility</a>
  80. <a class="item" href="../ref/native.html">API Library</a>
  81. <a class="item" href="../ref/architecture.html">GoAhead Architecture</a>
  82. <a class="item" href="../standards/http.html">HTTP References</a>
  83. </div>
  84. </div>
  85. <div class="item">
  86. <a href="../developers/project.html">Project Resources</a>
  87. <div class="menu">
  88. <a class="item" href="http://goo.gl/IGbiio">Official GoAhead News</a>
  89. <a class="item" href="https://embedthis.com/goahead/">GoAhead Web Site</a>
  90. <a class="item" href="https://github.com/embedthis/goahead">Source Code Repository</a>
  91. <a class="item" href="https://github.com/embedthis/goahead/issues/99">GoAhead Security Alerts</a>
  92. <a class="item" href="https://github.com/embedthis/goahead/issues">Project Issue Database</a>
  93. <a class="item" href="https://github.com/embedthis/goahead/releases">Change Log</a>
  94. <a class="item" href="https://github.com/embedthis/goahead/milestones">Roadmap</a>
  95. <a class="item" href="https://embedthis.com/developers/contributors.html">Contributors Agreement</a>
  96. </div>
  97. </div>
  98. <div class="item">
  99. <b>Links</b>
  100. <div class="menu">
  101. <a class="item" href="https://embedthis.com/">Embedthis Web Site</a>
  102. <a class="item" href="https://embedthis.com/blog/">Embedthis Blog</a>
  103. <a class="item" href="http://twitter.com/embedthat">Twitter</a>
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. <div class="ui inverted masthead">
  109. <div class="ui fixed inverted menu">
  110. <div class="ui sidebar-launch button">
  111. <i class="icon list layout"></i>
  112. </div>
  113. <div class="right menu">
  114. <a class="item" href="https://embedthis.com/">Embedthis</a>
  115. <a class="item" href="https://embedthis.com/goahead/">GoAhead Site</a>
  116. <span class="desktop-only">
  117. <a class="item" href="http://goo.gl/9bL9rM">GoAhead News</a>
  118. <a class="item" href="https://github.com/embedthis/goahead">Repository</a>
  119. <a class="item" href="https://embedthis.com/blog/">Blog</a>
  120. <a class="item" href="https://twitter.com/embedthat">Twitter</a>
  121. </span>
  122. </div>
  123. </div>
  124. <div class="ui breadcrumb">
  125. <a class="section" href="../">Home</a>
  126. <div class="divider">/</div>
  127. <a class="section" href="../ref/">
  128. Reference Guide
  129. </a>
  130. <div class="divider">/</div>
  131. <a class="active section" href="architecture.html">Architecture</a>
  132. </div>
  133. <iframe class="version desktop-only" src="../version.html"></iframe>
  134. </div>
  135. <div class="content">
  136. <h1>GoAhead Architecture</h1>
  137. <p>The GoAhead web server is the worlds most popular embedded web server and has been embedded in
  138. hundreds of different products and hundreds of millions of devices. GoAhead is a compact and efficient
  139. webserver with simple clean code and APIs.</p>
  140. <p>GoAhead has an strong feature set including:</p>
  141. <ul>
  142. <li>HTTP/1.1</li>
  143. <li>IPv4 and IPv6</li>
  144. <li>TLS/SSL</li>
  145. <li>32 and 64-bit support</li>
  146. <li>HTTP Keep-Alive</li>
  147. <li>Transfer chunk encoding</li>
  148. <li>Server-side Javascript</li>
  149. <li>Basic, Digest and Form-based Authentication</li>
  150. <li>Session state storage</li>
  151. <li>URI routing and rewriting</li>
  152. <li>Logging</li>
  153. <li>Security sandboxing</li>
  154. </ul>
  155. <p>GoAhead is extremely efficient. It runs as a single-threaded, event driven, non-blocking process.
  156. GoAhead is very small (from 600K) and very fast. On a PC class system, it will serve over 10,000 requests per
  157. second.</p>
  158. <a id="components"></a>
  159. <h2 >Core Components</h2>
  160. <p>GoAhead has a modular architecture and clean source code. The key components of GoAhead are:</p>
  161. <table title="Components" class="ui table segment">
  162. <thead>
  163. <tr>
  164. <th class="four wide">Component</th>
  165. <th>Description</th>
  166. </tr>
  167. </thead>
  168. <tbody>
  169. <tr>
  170. <td>GoAhead HTTP Core</td>
  171. <td>Core HTTP server. Includes services for HTTP protocol handling, socket connection
  172. management and logging.</td>
  173. </tr>
  174. <tr>
  175. <td class="nowrap">Request Router</td>
  176. <td>The request router directs client requests to the appropriate request handler. It
  177. enforces user authentication and general redirection and URI rewriting instructions.</td>
  178. </tr>
  179. <tr>
  180. <td class="nowrap">Portable Runtime</td>
  181. <td>Cross-platform, single-threaded, non-blocking event-based portable runtime. Includes services for
  182. memory allocation, safe string handling, lists, hashing, command execution, socket
  183. communications, events, timers, debug trace and logging.</td>
  184. </tr>
  185. <tr>
  186. <td>Authentication Framework</td>
  187. <td>Pluggable authentication. Supports Basic, Digest and Web Form-based authentication schemes.
  188. This includes a Role-based authorization scheme to access to resources can be controlled on
  189. a granular basis.</td>
  190. </tr>
  191. <tr>
  192. <td>Session State</td>
  193. <td>Session state storage. This stores per-user state and cookie management.</td>
  194. </tr>
  195. <tr>
  196. <td>Action Handler</td>
  197. <td>The Action handler binds URIs to C functions for simple, easy access to C-language code.</td>
  198. </tr>
  199. <tr>
  200. <td>File Handler</td>
  201. <td>The File handler serves static content such as HTML pages, images and PDF files.</td>
  202. </tr>
  203. <tr>
  204. <td>Javascript Handler</td>
  205. <td>The Javascript web framework is supports embedded server-side javascript.</td>
  206. </tr>
  207. <tr>
  208. <td>CGI Handler</td>
  209. <td>Common Gateway Interface handler for serving pages by running external CGI programs.</td>
  210. </tr>
  211. <tr>
  212. <td>Secure Sockets Layer (SSL)</td>
  213. <td>Secure Socket Layer protocol stack. This is a virtual interface that can selectively support a
  214. variety of SSL providers including: the MbedTLS and OpenSSL stacks.</td>
  215. </tr>
  216. </tbody>
  217. </table>
  218. <a id="core"></a>
  219. <h2>HTTP Core</h2>
  220. <p>The GoAhead HTTP core is responsible for parsing client HTTP requests and directing
  221. how the request will be processed. The HTTP core reads client requests and parses the request headers.
  222. It then invokes the GoAhead request router to process the request.</p>
  223. <p>The HTTP core includes services for: the main HTTP processing, socket communications, and logging.
  224. The HTTP core server also manages and enforces the sandbox resource limits that have been
  225. defined at build time. These limits enable GoAhead to be more deterministic in its use of system resources and
  226. to be a good system citizen.</p>
  227. <a id="router"></a>
  228. <h2>Request Router</h2>
  229. <p>GoAhead includes a powerful request router that manages how client HTTP requests are processed. The
  230. router is configured with a set of routes from the <i>route.txt</i> configuration.
  231. When a request is received, the router tests various routes and selects the best route to handle
  232. the request. In the process, routes may redirect or rewrite the request as required.</p>
  233. <p>A GoAhead configuration will typically have many routes. The configured routes are tested in-order by
  234. matching the route URI pattern against the request URL. A route may require that further preconditions be met
  235. before it is suitable to process the request. If the required conditions are not met, the next route in the
  236. configuration will be tested. There is always a catch-all route that will process the request if all prior
  237. routes fail to qualify.</p>
  238. <p>Once a route is selected, the specified request handler is invoked to service the request.
  239. GoAhead has handlers for CGI, Javascript and static file data.</p>
  240. <a id="runtime"></a>
  241. <h2>Portable Runtime</h2>
  242. <p>GoAhead is built upon a portable runtime layer that insulates the rest of the
  243. product from the underlying platform and allows it to be highly portable to new operating systems or
  244. hardware.</p>
  245. <p>The GoAhead runtime provides a suite of services that facilitate the creation of secure,
  246. embedded applications including: events, networking, safe string handling, timers, hashing, lists and
  247. logging.</p> <p>The runtime also provides a safer environment in which to program as it replaces 'C' APIs that
  248. are prone to buffer overflows and other similar security exploits. The runtime includes a high performance, safe
  249. string library that supports a secure programming style.</p>
  250. <p>The runtime's event processing can be easily integrated into existing applications. It supports
  251. single and multi-threaded architectures, polled or async event notification. This flexibility means that
  252. GoAhead can be easily integrated into most C/C++ applications.</p>
  253. <p>The runtime includes an optional high performance memory allocator.
  254. This allocator is useful when the native operating system allocator suffers from memory fragmentation.</p>
  255. <a id="dynamic"></a>
  256. <h2 >Dynamic Content</h2>
  257. <a id="cgi"></a>
  258. <h3>CGI</h3>
  259. <p>The Common Gateway Interface (CGI) is a standard for interfacing external applications with web servers. CGI
  260. was originally developed as part of the NCSA HTTP server and is an old standard for interfacing external
  261. applications with HTTP servers. It still enjoys considerable use.</p>
  262. <p>CGI scripts are written in any language that can read from the standard-input, write to the standard-output,
  263. and access environment variables. This means that virtually any programming language can be used, including C,
  264. Perl, or even Unix shell scripting.
  265. See <a href="../users/cgi.html">CGI</a> for more details.</p>
  266. <a id="goactions"></a>
  267. <h3>GoActions</h3>
  268. <p>CGI is a slow technique for creating dynamic web pages as it creates a new process for every request. This is
  269. slow and cumbersome. GoAhead provides a high-performance replacement called GoActions&trade; that is a more
  270. suitable solution for embedded systems that demand compact and efficient solutions.</p>
  271. <p>GoActions are "C" language functions that are bound directly to specific URIs. They respond to client
  272. requests without creating a new process for each request. By sharing the address space with GoAhead, GoActions
  273. can directly access the full request context and device/application specific data.</p>
  274. <p>GoActions are bound to URIs that begin with <i>/action/</i>. When a client requests a URI beginning with
  275. /action, the action handler looks for a defined GoAction of the correct name. Then the bound C function is
  276. invoked to service the request.
  277. See <a href="../users/goactions.html">GoActions</a> for more details.</p>
  278. <a id="jst"></a>
  279. <h3>Javascript Templates</h3>
  280. <p>Javascript Templates (JST) use Javascript code directly embedded in HTML web pages.
  281. The Javascript is run on the server and the result when the code executes is substituted back into the
  282. web page before it is sent to the client.</p>
  283. <p>JST allows the binding of C functions to Javascript functions, so that a JST web page can
  284. easily access device or system data.</p>
  285. <p>See <a href="../users/jst.html">Javascript Templates</a> for more details.</p>
  286. <a id="security"></a>
  287. <h2 >Security</h2>
  288. <p>GoAhead provides a suite of measures designed to increase the security of your web server:</p>
  289. <ul>
  290. <li>Secure Sockets Layer</li>
  291. <li>Authorization directives</li>
  292. <li>Sandbox directives</li>
  293. <li>Secure portable runtime</li>
  294. </ul>
  295. <h3>Secure Sockets</h3>
  296. <p>GoAhead supports the MbedTLS and OpenSSL stacks. You can configure both server and/or client
  297. authentication of certificates. SSL and TLS are supported. Other 3rd party SSL stacks are also available
  298. via the <a href="https://embedthis.com/catalog/">Pak online catalog</a></p>
  299. <h3>Authentication</h3>GoAhead provides Basic, Digest and Web-Form based authentication mechanisms. It
  300. supports both file and PAM-based password backends.
  301. <h3>Sandboxing</h3>
  302. <p>Sandboxing is the term applied to running GoAhead in a confined environment. GoAhead has a set of
  303. build-time directives that define a sandbox which limits the resources that GoAhead may
  304. used.</p>
  305. <a name="apis"></a>
  306. <h2 >Embedding APIs</h2>
  307. <p>GoAhead also provides a detailed API so you can create an embedded web server instance and control
  308. virtual hosts, port binding, directory and location blocks and every other part of GoAhead. See the <a href=
  309. "../ref/api/goahead.html">GoAhead API</a> for full details.</p>
  310. <a id="dirs"></a>
  311. <h2 >GoAhead Directories</h2>
  312. <p>Here is the list of top level directories in the GoAhead source code distribution.</p>
  313. <table title="dirs" class="ui table segment">
  314. <thead><tr><th class="three wide">Name</th><th>Purpose</th></tr></thead>
  315. <tbody>
  316. <tr><td>doc</td><td>Documentation</td></tr>
  317. <tr><td>package</td><td>Packaging scripts</td></tr>
  318. <tr><td>projects</td><td>IDE and Makefile projects</td></tr>
  319. <tr><td>releases</td><td>Release packages</td></tr>
  320. <tr><td>test</td><td>Unit test directory</td></tr>
  321. <tr><td>test/web</td><td>Unit test web documents</td></tr>
  322. <tr><td>utils</td><td>Utility programs</td></tr>
  323. <tr><td>web</td><td>Web documents directory</td></tr>
  324. <tr><td>*/inc</td><td>Master include directory</td></tr>
  325. <tr><td>*/bin</td><td>Output for binaries</td></tr>
  326. <tr><td>*/obj</td><td>Output directory for objects</td></tr>
  327. </tbody>
  328. </table>
  329. <a id="files"></a>
  330. <h2 >GoAhead Files</h2>
  331. <p>Here is a list of the major files in the GoAhead source code distribution.</p>
  332. <table title="files" class="ui table segment">
  333. <thead><tr><th class="three wide">Name</th><th>Purpose</th></tr></thead>
  334. <tbody>
  335. <tr><td>auth.c</td><td>Authorization management</td></tr>
  336. <tr><td>cgi.c</td><td>CGI handler</td></tr>
  337. <tr><td>crypt.c</td><td>Crypto routines</td></tr>
  338. <tr><td>file.c</td><td>File handler for static documents</td></tr>
  339. <tr><td>galloc.c</td><td>Optional fast memory allocator</td></tr>
  340. <tr><td>goahead.c</td><td>GoAhead server main program</td></tr>
  341. <tr><td>goahead.h</td><td>GoAhead master include header</td></tr>
  342. <tr><td>http.c</td><td>HTTP core engine</td></tr>
  343. <tr><td>js.c</td><td>GoAhead Javascript language</td></tr>
  344. <tr><td>js.h</td><td>Javascript header</td></tr>
  345. <tr><td>jst.c</td><td>Javascript Templates handler</td></tr>
  346. <tr><td>options.c</td><td>Options and Trace method handlers</td></tr>
  347. <tr><td>rom-documents.c</td><td>Compiled web pages into C code</td></tr>
  348. <tr><td>rom.c</td><td>ROM file system</td></tr>
  349. <tr><td>route.c</td><td>Request router</td></tr>
  350. <tr><td>route.txt</td><td>Route configuration</td></tr>
  351. <tr><td>runtime.c</td><td>Portable runtime layer</td></tr>
  352. <tr><td>socket.c</td><td>Socket management</td></tr>
  353. <tr><td>upload.c</td><td>File upload handler</td></tr>
  354. </tbody>
  355. </table>
  356. <a id="additional"></a>
  357. <h3 >GoAhead Additional Files</h3>
  358. <table title="additional" class="ui table segment">
  359. <thead><tr><th class="three wide">Name</th><th>Purpose</th></tr></thead>
  360. <tbody>
  361. <tr><td>configure</td><td>Configuration script</td></tr>
  362. <tr><td>Makefile</td><td>Top-level Makefile</td></tr>
  363. <tr><td>main.me</td><td>Primary MakeMe configuration</td></tr>
  364. <tr><td>*/inc/me.h</td><td>Generated MakeMe include header</td></tr>
  365. <tr><td>build/OS-ARCH-PROFILE/platform.me</td><td>Generated MakeMe configuration file</td></tr>
  366. <tr><td>server.key.pem</td><td>Test SSL private key</td></tr>
  367. <tr><td>server.crt</td><td>Test SSL certificate</td></tr>
  368. </tbody>
  369. </table>
  370. </div>
  371. <div class="terms ui basic center aligned segment">
  372. <p>&copy; Embedthis Software, 2003-2015. All rights reserved.</p>
  373. </div>
  374. <script src="../lib/jquery/jquery.min.js"></script>
  375. <script src="../lib/semantic-ui/semantic.min.js"></script>
  376. <script src="../scripts/sidebar.min.js"></script>
  377. </body>
  378. </html>