<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V3.1//EN"[]>

<book id="managing-ecsc-firewalls">
<bookinfo>
<title>Managing ECSC Linux Firewalls</title>
  
<authorgroup>
<author>
<firstname>John</firstname>
<surname>Leach</surname>
<affiliation>
<address>
<email>john@ecsc.co.uk</email>
</address>
</affiliation>
</author>
<author>
<firstname>Matthew</firstname>
<surname>Hall</surname>
<affiliation>
<address>
<email>matt@ecsc.co.uk</email>
</address>
</affiliation>
</author>
</authorgroup>
    
<revhistory>
<revision>
<revnumber>0.1</revnumber>
<date>30 Sep 2002</date>
<revremark>Initial layout</revremark>
</revision>
</revhistory>

<copyright>
<year>2002, 2003</year>
<holder>ECSC Ltd.</holder>
<holder> John Leach</holder>
<holder> Matthew Hall</holder>
</copyright>

<legalnotice>
<para>All your rights are belong to us.</para>
</legalnotice>

<releaseinfo>Initial release. v0.1</releaseinfo>

</bookinfo>

<toc></toc>

<!-- Introduction ===========================================================-->
<chapter id="introduction">
<title>Introduction</title>
<para>This document covers many aspects of installing and managing ECSC Linux
based firewalls including, but probably not entirely limited to:</para>

<itemizedlist>
<listitem><para>Configuring Squid (Web proxy);</para></listitem>
<listitem><para>Configuring Qmail (Mail system);</para></listitem>
<listitem><para>Configuring Apache (Web server);</para></listitem>
<listitem><para>Configuring FreeSWAN based IPSEC VPNs;</para></listitem>
<listitem><para>Configuring Netfilter using SgtBash;</para></listitem>
<listitem><para>Configuring PPTP based VPNs;</para></listitem>
<listitem><para>Configuring PPP Dial-In Access;</para></listitem>
<listitem><para>Writing firewall policies;</para></listitem>
<listitem><para>Troubleshooting problems;</para></listitem>
<listitem><para>Auditing of configuration.</para></listitem>
</itemizedlist>

<para>As many (read: all) of the packages that make up an ECSC firewall are
open-source and freely available this document will only cover specific
firewall related details, plus anything helpful to troubleshooting.  It is not
designed to be a beginners guide and so expects the reader to have a good
understanding of the underlying technology.  Wherever possible other
documentation will be referenced; we suggest you indulge in further
reading.</para>

<para>This document may also cover peripheral systems, such as Microsoft
Windows, Macromedia Coldfusion and Sophos Anti-virus with regard to making them
operate smoothly alongside, or with, ECSC firewalls.</para>

<sect1 id="layout-and-style">
<title>Layout and Style</title>
<para>The document is mastered in XML using the Docbook style definitions.  The
source should look beautiful, be readable and understandable.</para>

<para>The use of the English language should aim to impress even Oscar Wilde;
oozing grammatical prowess and charm.  Use of character case, anacronyms,
spacing, punctuation, words and bad analogies should be consistent
throughout.</para>

<para>Whilst marginally informal at times, this document should be serious.  The
information presented should be seen as reliable and correct and, if possible,
should actually be reliable and correct.</para>

</sect1>
</chapter>

<!-- Upgrading software =====================================================-->
<chapter id="upgrading-software">
<title>Upgrading Software</title>
<para>ECSC firewalls use the RedHat Package Management system (RPM) to manage
the various versions of software installed and keep track of upgrades.</para>

<para>Lots of things can go wrong whilst upgrading RPMs on a remote
firewall:</para>

<itemizedlist>
<listitem><para>Loss of services;</para></listitem>
<listitem><para>Loss of remote admin access (usually ssh);</para></listitem>
<listitem><para>Machine not booting after upgrades (not often detected until
months later);</para></listitem>
<listitem><para>RPM database corruption;</para></listitem>
<listitem><para>Loss of your job.</para></listitem>
</itemizedlist>

<sect1 id="apt">
<title>APT</title>
<para>The APT utilties help keep RPMs up-to-date by comparing the local list of
installed RPMs and versions with a remote, central database.</para>

<para>This central database, or APT repository, and RPM archive is accessible
via HTTP at http://updates.ecsc.co.uk/apt.  The APT utilities use standard HTTP
to access these files.</para>
</sect1>

<sect1 id="upgrading-glibc">
<title>Upgrading Gnu C Libraries (glibc, glibc-common)</title>
<para>The <filename>glibc</filename> and <filename>glibc-common</filename>
RPMs should be installed with care.  An incomplete C library upgrade can cause
major upset.  Whilst most currently active programs may continue normally they
will be in an unpredictable state.</para>

<para>To minimise the chances of something going terribly wrong do not upgrade
other RPMs in the same transaction.  For example, the following command will
download and upgrade the glibc, glibc-common and tuxracer RPMs:
<screen>
apt-get install tuxracer glibc glibc-common
</screen>
If for some reason, the tuxracer rpm fails in an unpredicted manner after the
<screen>
rpm -e ...
</screen> 
stage, then you'll be left with glibc and glibc-common no longer installed.
<note>
<para>The likelyhood of a necessary tuxracer upgrade is quite low.</para>
</note>
</para>
<para>After a glibc upgrade you should restart currently running programs as
they will still be using the old libraries.  You can see which processes will
need restarting like this:
<screen>
fuser -v /lib/i686/libc-*.so
</screen>
It is particularly important that you restart <filename>sshd</filename> as we
have experienced login problems after glibc upgrades. See FIXME: "safely
upgrading and restarting sshd".</para>

<sect2 id="recovering-borked-glibc">
<title>Recovering from a Borked C Library Upgrade</title>
<para>If something goes wrong upgrading these RPMs and libraries are missing,
no dynamically linked programs will be able to execute until things are fixed,
and fixing problems like these isn't a fun process.  Remember, you can't start
any new programs unless they are statically linked, so no bash, no rpm tools,
no vi, and suprisingly not even cat or echo! (talk about bloat!)  Whilst some
currently active programs may continue normally they will be in an
unpredictable state.</para>

<procedure>
<step><para>Boot disk;</para></step>
<step><para>mount hard disk;</para></step>
<step><para>rpm -r /mnt/harddisk/ -Uvh RedHat/RPMS/glibc*.rpm;</para></step>
<step><para>sync;</para></step>
<step><para>reboot.</para></step>
</procedure>
</sect2>
</sect1>
</chapter>

<!-- Configuring VPN ========================================================-->
<chapter id="configuring-vpn">
<title>Configuring VPNs</title>
<sect1 id="IPSEC-freeswan">
<title>IPSEC</title>
<sect2>
<title>Restarting IPSEC</title>
<screen>
ipsec auto --replace conn_name
ipsec auto --add whatever
ipsec auto --rereadsecrets  - make pluto re-read secrets
</screen>
</sect2>
</sect1>

<sect1 id="services-over-vpn">
<title>Services over VPN</title>

<sect2 id="novell">
<title>Novell Netware</title>

<sect3>
<title>Logging In</title>
<para>From the <ulink
url="http://support.novell.com/cgi-bin/search/searchtid.cgi?/10057455.htm">Novell
Knowledge-base</ulink>: "The best way to log into the server you want via IP
only is to right click on the red N in the System Tray and select "NetWare
Login. . . .".  Then hit the advanced tab and enter the IP address of the
server you want to log into in the "Server:" field.  As long as your user has
rights, and the server you want to log into has its routing path correct, you
should be able to log into that server."</para>
</sect3>
</sect2>
</sect1>
</chapter>

<!-- Configuring PPP ========================================================-->
<chapter id="configuring-ppp">
<title>Configuring PPP Dial-in</title>
<para>For a more comprehensive PPP-HowTo see:
<ulink url="http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html_single/PPP-HOWTO.html">
tldp.org</ulink></para>

<sect1 id="identifying">
<title>Identifying the Modem port</title>
<sect2 id="external">
<title>External</title>
<para>Once logged in to the client machine, you should <literal>grep</literal> 
through<filename>/var/log/messages</filename> to search for a <literal>tty
</literal> string. If you find something similar to this:</para>
<screen>
ttyS00 at 0x03f8 (irq = 4) is a 16550A
</screen>
<para>This means there is one com port, and the mode will be attached to
<filename>/dev/ttyS0</filename></para>
<note><para>If there are more than one com ports, you will have to find out which com
port the modem is attached to (com 0, 1, 2).
This number will be similar to the device in <filename>/dev</filename>,
id est: <literal>com 0</literal> =
<filename>/dev/ttyS0</filename>; <literal>com 1</literal> =
<filename>/dev/ttyS1</filename></para></note>
</sect2>
<sect2 id="internal">
<title>Internal</title>
<para>With an internal modem, you may find the correct modem port from output 
of <function>lspci -vv</function>.</para>
<screen>
02:09.0 Communication controller: Lucent Microelectronics Venus Modem (V90,56KFlex)
        Subsystem: Action Tec Electronics Inc: Unknown device 0480
        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B-
        Status: Cap+ 66Mhz- UDF- FastB2B+ ParErr- DEVSEL=medium TAbort- TAbort- MAbort- SERR- PERR-
        Latency: 0 (63000ns min, 3500ns max)
        Interrupt: pin A routed to IRQ 21
        Region 0: Memory at f9fffc00 (32-bit, non-prefetchable) [size=256]
        Region 1: I/O ports at dc00 [size=256]
        Region 2: I/O ports at d800 [size=256]
        Region 3: I/O ports at d4f8 [size=8]
        Capabilities: [f8] Power Management version 2
                Flags: PMEClk- DSI+ D1- D2+ AuxCurrent=0mA PME(D0-,D1-,D2+,D3hot+,D3cold-)
                Status: D0 PME-Enable- DSel=0 DScale=0 PME-
</screen>
<para>You will notice the <literal>IRQ 21</literal> line. You now need to iterate
through <literal>/dev/ttyS*</literal> devices with setserial until you find a
matching IRQ, as seen below:</para>
<screen>
# setserial /dev/ttyS4
/dev/ttyS4, UART: 16550A, Port: 0xdc00, IRQ: 21
</screen>
</sect2>
<sect2 id="reference">
<title>Naming Convention</title>
<para>From here on I will refer to the modem port as <literal>ttyS0</literal>
for reference.
You should replace this with the port found by the above investigation.
</para>
</sect2>
</sect1>

<sect1 id="inittab">
<title>Inittab</title>
<para>The <filename>/etc/inittab</filename> file needs to have an extra 'tty' 
added for the modem so that dial-in access will be initialised upon a
reboot.</para>
<para>There will be several lines in this file for the standard getty's, which 
will look like this:</para>
<screen>
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6
</screen>
<para>You must add the line <function>7:2345:respawn:/sbin/mgetty
ttyS0</function> to the end of this section, so the section looks like
this:</para>
<screen>
6:2345:respawn:/sbin/mingetty tty6
7:2345:respawn:/sbin/mgetty ttyS0
</screen>
<para>You will then need to restart init by executing the command:
<function>kill -HUP 1</function>.</para>
</sect1>

<sect1 id="ppp">
<title>PPP Configuration</title>
<para>There are three configuration files that will need to be edited to set
up the PPP connection.</para>

<sect2 id="options">
<title>Options</title>
<para>The <filename>/etc/ppp/options</filename> file contains the dial-in
configuration.</para>
<para>This file needs to contain the following information:</para>
<screen>
auth +chap -pap crtscts proxyarp lock
ms-dns 123.456.789.123
name dialin
10.254.100.1:10.254.100.1
</screen>
<para>You will need to change the <literal>ms-dns 123.456.789.123</literal> IP
address to point to the correct DNS server (normally the IP address of eth0, if
a DNS server is running on the host).</para>
<para>You may also need to change the
<literal>10.254.100.1:10.254.100.1</literal> address range to ensure you do not
have ssh host file conflicts when dialing in.</para>
</sect2>

<sect2 id="chapsecrets">
<title>Chap Secrets</title>
<para>The Chap Secrets file contains our username and password.  You will need
the program <literal>genpass</literal>, to create a cryptographically secure
password.</para>
<para>This file should contain information like below:</para>
<screen>
"pppusername" "dialin" "123456" "10.254.100.2"
</screen>
<para>You will need to change the <literal>"pppusername"</literal> and
<literal>"123456"</literal> sections, to provide a good username (normally
"companynameppp") and a secure password.  You may also want to change the
<literal>"10.254.100.2"</literal> IP address to use a different IP address,
but this is not required by default.</para>
<para>Please note the following characters cannot be used in ppp passwords:
<itemizedlist>
<listitem><para>' ' - space</para></listitem>
<listitem><para>'	' - tab</para></listitem>
<listitem><para>'#' - pound sign</para></listitem>
<listitem><para>'@' - at sign</para></listitem>
<listitem><para>'\' - backslash (next character is interpreted as function
ie: \n = newline)</para></listitem>
<listitem><para>'"' - double quote</para></listitem>
</itemizedlist>
</para>
</sect2>

<sect2 id="ttys">
<title>ttyS0 Options</title>
<para>The <filename>/etc/ppp/options.ttyS0</filename> file will contain the
IP address range which the host will use as local PPP addresses.  This file
will need to look like this:</para>
<screen>
10.254.100.1:10.254.100.1
</screen>
<para>You may want to change the address range if this conflicts with an
address already in use, or if you require something different for another
reason.  However, the default is commonly sufficient.</para>
</sect2>
</sect1>

<sect1 id="mgetty">
<title>Mgetty Configuration</title>
<para>The file <filename>/etc/mgetty+sendfax/login.config</filename> will
need to contain the following information:</para>
<screen>
*       -       -       /usr/sbin/pppd
</screen>
</sect1>

<sect1 id="firewall">
<title>Firewall Rules</title>
<sect2 id="fwif">
<title>Firewall Interfaces</title>
<para>The <filename>/etc/fw.if.conf</filename> will need to contain an
interface group for the ppp device.  Add the following line to this
file:</para>
<screen>
interface group modem has ppp0
</screen>
</sect2>
<sect2 id="firewallrules">
<title>Firewall rules</title>
<para>The <filename>/etc/firewall.conf</filename> will need to contain a rule
allowing SSH access over the PPP connection.  Add the following line to an
appropriate section of this file:</para>
<screen>
accept input dport tcp.ssh from modem:@10.254.100.2
</screen>
<para>If you changed the leased IP address in
<filename>/etc/mgetty+sendfax/chap-secrets</filename>, you will need to replace
the <literal>modem:10.254.100.2</literal> address with the correct ip
address.</para>
<para>You will then need to restart the firewall by issuing the command 
<function>service firewall restart</function>.</para>
</sect2>
</sect1>

<sect1 id="dialin">
<title>Dialing in</title>
<para>To test dial-in access you will need a preconfigured modem working on
your machine.</para>

<sect2 id="wvdial">
<title>WvDial Configuration</title>
<para>You will need to add the PPP dialin information to
<filename>/etc/wvdial.conf</filename>.  This file should already contain some
information similar to:</para>
<screen>
[Modem0]
Modem = /dev/ttyS1
Baud = 57600
SetVolume = 0
Dial Command = ATDT
Init1 = ATZ
FlowControl = NOFLOW
</screen>
<para>The following information needs to be added:</para>
<screen>
[Dialer companynameppp]
Area Code = 0123
Username = companyppp
Password = 123456
Phone = 123456
Dial Prefix = 9
Inherits = Modem0
</screen>
<para>You will need to set the <function>Username</function> and
<function>Password</function> values to those defined in the server
config.</para>
<para>The <function>Dialer companynameppp</function>, <function>Area
Code</function> and <function>Phone</function> lines will also need to be
configured to reflect the company name and the phone number to dial in to the
modem.</para> 
</sect2>

<sect2 id="dialing">
<title>Dialing</title>
<para>To dial-in to the server using PPP, you will need to issue the
command <function>wvdial companyppp</function>.  You will then see a screen
similar to this:</para>
<screen>
[root@ecsc root]# wvdial companyppp
--> WvDial: Internet dialer version 1.41
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Modem initialized.
--> Sending: ATDT 9,01274736223
--> Waiting for carrier.
ATDT 9,01274736223
CONNECT 21600/LAP-M
--> Carrier detected.  Starting PPP immediately.
--> Starting pppd
</screen>
<para>Once connected, a ppp0 interface will be shown if you issue the
command <function>ifconfig</function>.  This will look similar to this:</para>
<screen>
ppp0      Link encap:Point-to-Point Protocol
          inet addr:10.254.100.2  P-t-P:10.254.100.1  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:5 errors:2 dropped:0 overruns:0 frame:0
          TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:72 (72.0 b)  TX bytes:78 (78.0 b)
</screen>
<para>The <function>P-t-P:10.254.100.1</function> line shows the address you
should connect to by SSH'ing to <literal>root@10.254.100.1</literal></para>
</sect2>
</sect1>

<sect1 id="troubleshooting">
<title>Troubleshooting</title>
<sect2 id="ioerror">
<title>Cannot open /dev/ttyS0</title>
<para>If when trying to dial-in to a server, you receive the error:</para>
<screen>
--> WvDial: Internet dialer version 1.41
--> Cannot open /dev/ttyS1: Input/output error
</screen>
<para>Then your modem is not set up, or is not configured correctly.  You may
be trying to use a PCMCIA modem without the PCMCIA cardmgr services
running.</para>
</sect2>
<sect2 id="LCP">
<title>LCP timeout</title>
<para>If you cannot connect to a server when dialing in, check your
<filename>/var/log/messages</filename> to see if there is any debugging
information.  If it contains information similar to below:</para>
<screen>
pppd 2.4.1 started by root, uid 0
Using interface ppp0
Connect: ppp0 <--> /dev/ttyS1
/etc/hotplug/net.agent: assuming ppp0 is already up
LCP: timeout sending Config-Requests
Connection terminated.
Receive serial link is not 8-bit clean:
Problem: all had bit 7 set to 0
Exit.
</screen>
<para>Or, on the server you see information similar to this in
<filename>/var/log/messages</filename>:</para>
<screen>
pppd 2.4.1 started by root, uid 0
Using interface ppp0
Connect: ppp0 <--> /dev/pts/0
</screen>
<para>You need to add the word <literal>local</literal> to the
<filename>/etc/ppp/options</filename> on the server so it looks like
this:</para>
<screen>
auth +chap -pap crtscts proxyarp lock local
</screen>
<para>FIXME: Why is this?</para>
</sect2>
</sect1>
</chapter>

<!-- Configuring mail =======================================================-->
<chapter id="configuring-mail">
<title>Configuring Mail</title>
<sect1 id="vmail">
<title>Virtual Mail</title>
<para>This section covers the virtual mail system.  The virtual mail system
provides IMAP and POP3 and mostly involves qmail and vmailmgr.  Other aspects
of Qmail are covered elsewhere in this document.</para>

<sect2 id="installation">
<title>Installation</title>
<para>RPMs Needed:</para>

<itemizedlist>
<listitem><para>qmail</para></listitem>
<listitem><para>vmailmgr</para></listitem>
<listitem><para>vmailmgr-daemon</para></listitem>
<listitem><para>ucspi-unix</para></listitem>
<listitem><para>ucspi-tcp</para></listitem>
<listitem><para>vmmi</para></listitem>
</itemizedlist>

<para>For IMAP support, these extra RPMs are needed:</para>

<itemizedlist>
<listitem><para>courier-imap</para></listitem>
<listitem><para>vmailmgr-courier-imap</para></listitem>
</itemizedlist>
</sect2>

<sect2>
<title>Configuring</title>
<para>Files which need to be configured from the default install:</para>

<itemizedlist>
<listitem><para><filename>/etc/vmailmgr/socket-file</filename></para></listitem>
<listitem><para><filename>/var/qmail/control/defaultdomain</filename></para></listitem>
<listitem><para><filename>/var/qmail/control/virtualdomains</filename></para></listitem>
<listitem><para><filename>/var/qmail/control/rcpthosts</filename></para></listitem>
<listitem><para><filename>/var/qmail/control/checkpassword</filename></para></listitem>
<listitem><para><filename>/etc/httpd/conf/httpd.conf</filename></para></listitem>
<listitem><para><filename>/etc/squid/squid.conf</filename></para></listitem>
</itemizedlist>

<para><filename>/etc/vmailmgr/socket-file</filename> should contain the full
path to the unix-style socket which vmailmgrd listens on.  The path should be
set to <filename>/tmp/.vmailmgrd</filename>.</para>

<para><filename>/var/qmail/control/defaultdomain</filename> and
<filename>/var/qmail/control/rcpthosts</filename> should contain the client's
mail domain(s). e.g.</para>
<screen>
example.co.uk
example.com
</screen>

<para><filename>/var/qmail/control/virtualdomains</filename> should contain the
client's mail domain(s), then the virtual mail user, separated by a colon.
e.g.</para> 
<screen>
example.co.uk:vmail
example.com:vmail
</screen>

<para><filename>/var/qmail/control/checkpassword</filename> should contain the
password checker for virtual mail:</para>
<screen>
checkvpw
</screen>

<para>As of apache-1.3.23-ECSC4, and web_filter-2.2.0-ECSC2, commented-out
lines exist to enable the vmmi package to run on port 7000; and as of
webfwadmin-1.6.1-ECSC7, the mail button on the webadmin will push the client to
a SSL secured port 7000 for vmail configuration.  Several files need to be
checked and/or changed thusly.</para>

<para><filename>/etc/httpd/conf/httpd.conf</filename> contains the apache
webserver configuration. There are two sections commented out (from lines 134
-> 140, and 275 -> 291) containing Directory and VirtualHost directives to
enable <filename>/var/www/html/vmail</filename> on port 7000 with SSL.  You
will need to uncomment this first block; changing the "allowed from" line to
allow access to the management interface from the client's LAN (or specific
IPs).  i.e. 
<screen>allow from 192.168.0.0/24</screen>. 
</para>

<para>You will also need to uncomment the large second block at the end of the
file and change the addresses on the "Listen" and "VirtualHost" lines
to reflect the IP address of the administrative interface (normally the
firewall's internal address on the client's LAN).</para>

<para>You will need to configure squid to allow SSL through to port 7000 using
lines similar to the following, which should be added to
<filename>/etc/squid/squid.conf</filename></para>
<screen>
acl vmail_port port 7000
acl vmail_users src 192.168.1.0/255.255.255.0
http_access allow CONNECT vmail_users vmail_port
</screen>
</sect2>

<sect2>
<title>Running and Testing</title>
<para> A virtual mail administrator must be added and a password assigned to
that account.</para>

<note><para>The user added must be identical to the virtual mailuser added to
<filename>/var/qmail/control/virtualdomains</filename> </para> </note>

<para>Perform the following commands to setup the user: </para>
<screen>
adduser vmail
passwd vmail
su vmail
vadduser postmaster
</screen>

<para>To start vmailmgr link the vmailmgrd directory to the svcscan monitored
/service directory as follows:</para>
<screen>
cd /service
ln -s /var/vmailmgrd
</screen>

<para>Checking the output of <screen>ps -aufx</screen> should show vmailmgrd
running under /service, and the output of <screen>netstat -an</screen> should
show a listening socket on <filename>/tmp/.vmailmgrd</filename>.</para>

<para>To restart apache and squid after re-configuring the configuration
files, issue the following commands.</para>
<screen>
service httpd restart
service squid restart
</screen>

<para>The final test is to open a browser and connect to the firewall
using https on port 7000.</para>
</sect2>

<sect2>
<title>Adding IMAP Mail Support</title>
<para> To enable IMAP support in Vmailmgr you must change the courier-imap
authorisation program and set it as the default authorisation program.  First
perform the following command:</para>
<screen>
ln -s `which authvmailmgr` /usr/lib/courier-imap/libexec/authlib/authvmailmgr
</screen>

<para>Then modify the `AUTHMODULES` statement in
<filename>/usr/lib/courier-imap/etc/imapd.config</filename> and add
<screen>authvmailmgr</screen> as the first authentication module.</para>

</sect2>
</sect1>
<sect1>
<title>Extra features</title>
<sect2>
<title>Auto append @domain.com to incoming mails (envnoathost)</title>
<para>To allow the sending of e-mail without specifying the domain, you need to
tell qmail which domain to append when receiving such mails.</para>
<para>Put the domain name you want to use in the qmail control file
<filename>/var/qmail/control/envnoathost</filename> and restart qmail</para>
</sect2>

</sect1>
</chapter>

<!-- Configuring the Apache Web Server ======================================-->
<chapter id="apache">
<title>Configuring the Apache Web Server</title>
<sect1 id="virtual-sites">
<title>Secure Virtual Site Configuration</title>
<para>This section will help you add virtual web sites on Apache under Linux,
in a secure manner.</para>

<sect2>
<title>Creating the Web Root</title>
<sect3>
<title>Create a new user</title>
<para>Create a new user for the web root, this example will use the user
'fred'.  Lock his password using: <screen>passwd -l fred</screen>.  su to
the new user Fred, and in his home dir, create a directory for the web files to
go in.  For example: <filename>/home/fred/www.testsite.com</filename> </para>
</sect3>

<sect3>
<title>Permissions</title>
<para>Fred needs full access to his files, apache needs read access to the web
root (and execute for directories of course), and everybody else needs diddly
squat.  NOTE: Apache will also need execute access for Fred's home dir as it
tends to use stat to work out its path (apparently).</para>

<para>If you su'ed to Fred before creating the webroot, it should already
belong to him and have the correct default permissions for himself.  Set up the
other permissions using the chmod and chgrp commands:</para>

<screen>
chgrp apache /home/fred/
chmod 0710 /home/fred
chgrp apache /home/fred/www.testsite.com
chmod 0750 /home/fred/www.testsite.com
</screen>

<para>You should also set the web root directory to be setgid, ensuring all
files created in there will belong to apache, thus reducing the user's
temptation to give the world read (and usually write) access to their valuable
secret proprietary perl scripts.</para>

<screen>
chmod 2750 /home/fred/www.testsite.com
</screen>
</sect3>
</sect2>

<sect2>
<title>Creating the Web Logs Directory</title>
<para>Each web hosting user needs access to their own web access and error
logs.  This is a delicate process where permissions are concerned.</para>
<sect3>
<title>Creating the Directory</title>
<para> We now place logfiles in a seperate location, and symlink them into the
user's home dir.  We'll need to make a directory to put the logs in.  For this
example, we'll use <filename>/var/log/httpd/wwwlogs/fred</filename>.</para>
</sect3>

<sect3>
<title>Permissions</title>
<para> Incorrect log dir permissions can open Apache up to a denial of service
attack, and as the logs are created and written to by an Apache process running
as root, lots of other nasty attacks.  The user should have only READ access to
the directory: </para>

<screen>
chown root.fred /var/log/httpd/wwwlogs/fred
chmod 0750 /var/log/httpd/wwwlogs/fred
</screen>

</sect3>
</sect2>

<sect2>
<title>httpd.conf</title>
<para>Globally, things such as handlers, php, Aliases and UserDir should not
be enabled.  You should do this at the virtual host level.  If Fred doesn't use
php scripts then he doesn't need the <screen>AddType application/x-httpd-php
.php4 .php3 .phtml .php</screen> line covering him globally.</para>

<sect3>
<title>Configuring the VirtualHost</title>
<para>Set up the apache VirtualHost directive in the httpd.conf, for example:
</para>
<screen>
&lt;VirtualHost&gt;
ServerAdmin fred@testsite.com
DocumentRoot /home/fred/www.testsite.com
ServerName www.testsite.com
ErrorLog /var/log/httpd/wwwlogs/fred/wwwerror.log
CustomLog /var/log/httpd/wwwlogs/fred/www.testsite.com.log combined
&lt;/VirtualHost&gt;
</screen>
</sect3>
</sect2>
</sect1>
</chapter>

<!-- Configuring IIS protection =============================================-->
<chapter id="configuring-iis-protection">
<title>Configuring IIS Protection and SSL acceleration</title>

<sect1 id="backend-services">
<title>Backend Services</title>
<sect2>
<title>Microsoft Outlook Web Access</title>
<para>The Microsoft Outlook Web Access system (OWA) can run directly from an
Exchange server or through an IIS virtual host.  Either way, there are a number
of problems you may run into.</para>

<sect3>
<title>SSL Acceleration</title>
<para>SSL Accelerating an OWA service requires a little tweak with Apache.
You'll need the specially patched mod_proxy and the following line in your
apache configuration:</para>

<screen>
ProxyRequestHeader set Front-End-Https On
</screen>

<para>This sets a special HTTP header in the backend request to the Outlook
Web host.  Now the Outlook Web service knows there is an SSL accelerator in
front of it and rewrites URLs with <filename>https://</filename> rather than
<filename>http://</filename>.</para>
</sect3>

<sect3>
<title>The SEARCH http method and Squid</title>
<para>When accessing an OWA service, Internet Explorer makes use of a
non-standard HTTP method named "SEARCH".  You will need to set your squid
caches to accept and allow this method else the the inbox will just show
<function>Loading...</function> and never return (or complain, bleh).</para>

<para>You can do this with the following line in your squid config (Squid
2.4):</para>

<screen>
extension_methods request SEARCH
</screen>
</sect3>

<sect3>
<title>The Apache Limit* configuration</title>
<para>Apaches Limit* directives can cause problems with OWA as it tends to
make large and sometimes unusual-looking requests.  The ECSC Webfwadmin's
default Apache settings are currently:
</para>

<screen>
LimitRequestBody 2048
LimitRequestFieldsize 4096
LimitRequestLine 2048
LimitRequestFields 30
</screen>

<para>Requests generated by OWA can be as big as any e-mail sent by a user, so
2k is clearly not enough for all-singing all-dancing animated html ActiveX
e-mails.  You can experiement with these settings but it is currently
recommended to comment them out.</para>
</sect3>
</sect2>
</sect1>
</chapter>

</book>

