One of attractive characteristics of
The Apache HTTP Server,
is its modular design.
This enables a high degree of flexibility in the functionality that
is provided. mod_rewrite is a module that ships with
Apache that allows URLs to be matched and rewritten. The module
allows the map used for rewriting URLs to be an external programme
that reads keys from stdin and returns the corresponding
value to stdout. By using
supersparrow as the
external map, Apache can be tied directly into Super Sparrow.
To do, this the configuration files /etc/httpd/conf/access.conf, /etc/httpd/conf/httpd.conf, /etc/httpd/conf/magic and /etc/httpd/conf/srm.conf are used.
These configuration files were tested to work with Apache 1.3.12 and are
based on those shipping with the apache-1.3.12-2 RPM from Red Hat, Inc.
Of particular note in the configuration file is:
This sets up two virtual services www.apache-test.supersparrow
and www.x.apache-test.supersparrow. These are name based
virtuals and are both bound to the IP address 192.168.193.11. The
RewriteMap line names a map, ss_map that is an external
programme, /usr/bin/supersparrow. The following
RewriteRule line uses this map to rewrite all URLs to a
corresponding URL in either www.x.apache-test.supersparrow or
www.x.apache-test.supersparrow depending on the output if
/usr/bin/supersparrow.
RewriteLogLevel 9 sets logging of the Rewrite Engine to
maximum verbosity, the logs can be found in
/var/log/httpd/rewrite_log as per the RewriteLog line.
Once the configuration is verified to be working it is suggested that the
debugging level be changed to 0, turning logging off. The
Apache User's Guide advises against directing the logs to
/dev/null as a way of suppressing unwanted messages as Apache
has to do additional work to produce the logs. It is best to just turn the
logs off instead.
If an RPM was used to install Apache it may be started using its
init script. Restart is used as Apache may already
be running and it is important that the new configuration files
are read.
Otherwise Apache may be stopped and started manually:
To ensure that Apache is started on system boot init needs
to run httpd. If Apache was installed from an RPM this should
be configured automatically. To verify this use chkconfig.
If httpd is not listed as being on for run-levels 3, 4 and 5
then run the following command. The output from the previous command
should then indicate that Apache will run at these run-levels:
If Apache was not installed from an RPM, then you should edit
the init scripts in /etc/rc.d/. To ensure
that is is run on system boot something along the lines of
the following should appear in on of the init scripts.
The paths should be modified to match the installation.
To verify that Apache is running use lynx. The following should
produce return the root page for your server:
For reference the resulting configuration files for
Apache are available.
POP X Router:
/etc/httpd/conf/access.conf,
/etc/httpd/conf/httpd.conf,
/etc/httpd/conf/magic,
/etc/httpd/conf/srm.conf
A complete set of configuration files for this network setup
can be found here.
Please see references.
Copyright © 2000 HormsRunning named
NameVirtualHost 192.168.193.11
<VirtualHost 192.168.193.11>
ServerName www.apache-test.supersparrow
ServerAlias apache-test.supersparrow
DocumentRoot /home/httpd/html/
RewriteEngine on
RewriteLog /var/log/httpd/rewrite_log
RewriteLogLevel 9
RewriteMap ss_map prg:/usr/bin/supersparrow
RewriteRule ^/(.*) http://${ss_map:%{REMOTE_ADDR}}/$1 [R,L]
</VirtualHost>
<VirtualHost 192.168.193.11>
ServerName www.x.apache-test.supersparrow
DocumentRoot /home/httpd/html/
</VirtualHost>
Starting on System Boot
$ /etc/rc.d/init.d/named start
Shutting down httpd: [ OK ]
Starting httpd: [ OK ]
killall httpd
/usr/sbin/httpd
$ chkconfig --list httpd
httpd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
$ /sbin/chkconfig --level 345 httpd on
$ /sbin/chkconfig --level 0126 httpd off
if [ -x /usr/sbin/httpd -a -e /etc/httpd/conf/httpd.conf ]; then
echo Starting httpd
/usr/sbin/httpd
fi
Testing
$ lynx -dump http://127.0.0.1/
Configuration Files
References
Notes on Commands
Commands shown in paragraphs of preformated text are prefixed by the shell
prompt $ to avoid confusion between commands and their output. An
instruction to run the command echo flim is formated as:
$ echo flim
flim
Last Updated: Tue May 17 17:37:17 2005