Into architecture Apache enters: a simple kernel, a platform dependent level (APR), and modules. Any application for
Apache - even the elementary, service page by default Apache "It worked" - uses some modules. Users Apache do
not require knowledge of it, but for the developer of programs, the understanding of modules and API module Apache is
a key to work with Apache. The majority, but not all modules, are connected with various aspects of inquiry processing HTTP.
Seldom enough meets, that it is necessary for module to work with each aspect HTTP: as it does httpd (Apache).
Advantage of the modular approach consists that it allows to focus the module on a specific problem, ignoring thus other
aspects HTTP, not concerning that problem.
In this article we shall tell about architecture of inquiry processing in Apache, and we shall show, how the module
can intercept the control over various parts of an operation cycle of inquiry.
Content generation.
The elementary formulation of a web-server is the program expecting HTTP inquiries and returning answers, at reception
of inquiry. It is the primary goal in Apache, a so-called kernel a web-server.
For everyone HTTP inquiry the generator content should be started. Some modules can register generators content,
defining the functions referring on processor which can be configured by instructions SetHandler or AddHandler in
httpd.conf. Those inquiries for which the generator of some module is not given, are processed by the standard generator
which simply returns the requested file directly from file system. Modules which realize one or more generators content,
are known as generators content or processing modules.
Phases of inquiry processing
Basically, the generator content can use all functions of a web-server: for example, CGI the program receives inquiry
both generates the answer, and can receive the full control what to happen for this time. But, by analogy to other
web-servers, Apache breaks inquiry about different phases. So, for example, it checks, whether the user for work is
authorized before the generator content will give out result.
Here some phases of processing of inquiry till the moment of generation content. They are used for check and is possible
changes of headings of inquiry, and define what to do with inquiry. For example:
URL inquiry it is necessary to compare to data of a configuration to define, what generator content should be used.
It is necessary to define a file to which refers URL inquiry. URL can address both to a statistical file, and to CGI
script, or to something, that can be used for generation content.
If content it is accessible, mod_negotiation will find that version of a resource which approaches to adjustments of a
browser is better. For example, pages of information Apache are deduced in that language on which the inquiry from a
browser has acted.
Rules of access and identification of modules are checked on conformity to rules of access of a server, and is defined,
whether has the right the user to receive that it has requested.
mod_alias Or mod_rewrite can change URL in inquiry.
In addition, there is still a phase loged inquiry which is executed after the generator content will send a
browser the answer.
The module can introduce own processors in any of these hooks. The modules, processing data on phases before generation
content, are known as modules of metadata. What work with loged, are known as log modules.
Data and filters.
That we have described above is in essence architecture of any web-server. A difference only in details, but phases of
processing of inquiry: metadata-> the generator content-> loged are the general.
The main innovation in Apache 2 is its transformation from a simple web-server in the powerful platform representing a
chain of filters. It can be represented as an axis of data, perpendicular axes of processing of inquiry. The requested
data can be processed by entrance filters up to the generator content, and the answer of a server can be processed by
target filters before sending to the client. Filters allow to make a preliminary filtration and more effectively to submit
data processings, separating these phases from generation content. An example of filters: inclusion on the party of a
server (SSI), XML and XSLT processing, gzip a compression and enciphering (SSL).
|