<chapter id="nca-1"><title>Managing Web Cache Servers</title><highlights><para>This chapter provides an overview of the Solaris Network Cache
and Accelerator (NCA). Procedures for using NCA and reference material
about NCA are included. Also for the Solaris 10 6/06 release, an
introduction to using the Secure Sockets Layer (SSL) and procedures
for using the SSL kernel proxy to improve the performance of the
SSL packet processing are added.</para><itemizedlist><listitem><para><olink targetptr="nca-2" remap="internal">Network Cache and Accelerator
(Overview)</olink></para>
</listitem><listitem><para><olink targetptr="nca-35" remap="internal">Managing Web Cache Servers
(Task Map)</olink></para>
</listitem><listitem><para><olink targetptr="nca-4" remap="internal">Administering the Caching
of Web Pages (Tasks)</olink></para>
</listitem><listitem><para><olink targetptr="nca-27" remap="internal">Caching Web Pages (Reference)</olink></para>
</listitem>
</itemizedlist>
</highlights><sect1 id="nca-2"><title>Network Cache and Accelerator (Overview)</title><para>The Solaris Network Cache and Accelerator (NCA) increases
web server performance by maintaining an in-kernel cache of web
pages that are accessed during HTTP requests. This in-kernel cache
uses system memory to significantly increase performance for HTTP
requests that are normally handled by web servers. Using system
memory to hold web pages for HTTP requests increases web server
performance by reducing the overhead between the kernel and the
web server. NCA provides a sockets interface through which any web
server can communicate with NCA with minimal modifications.</para><para>In situations where the requested page is retrieved from the
in-kernel cache (cache hit), performance improves dramatically.
In situations where the requested page is not in the cache (cache
miss) and must be retrieved from the web server, performance is
also significantly improved.</para><para>This product is intended to be run on a dedicated web server.
If you run other large processes on a server that runs NCA, problems
can result.</para><para>NCA provides logging support in that NCA logs all cache hits.
This log is stored in binary format to increase performance. The <command>ncab2clf</command> command can be used to convert the log from binary
format to common log format (CLF).</para><itemizedlist><para>The Solaris release includes the following enhancements:</para><listitem><para>Sockets interface.</para>
</listitem><listitem><para>Support for vectored sendfile, which provides support
for AF_NCA. See the <olink targetdoc="refman3e" targetptr="sendfilev-3ext" remap="external"><citerefentry><refentrytitle>sendfilev</refentrytitle><manvolnum>3EXT</manvolnum></citerefentry></olink> man page for
more information.</para>
</listitem><listitem><para>New options for the <command>ncab2clf</command> command
that support the ability to skip records before a selected date
(<option>s</option>) and to process a specified number of records
(<option>n</option>).</para>
</listitem><listitem><para><literal>logd_path_name</literal> in <filename>ncalogd.conf</filename> can specify either a raw device, a file, or a combination
of the two.</para>
</listitem><listitem><para>Support for a web server to open multiple AF_NCA
sockets. With multiple sockets, you can have different web servers
that run on one server.</para>
</listitem><listitem><para>A new configuration file that is called <filename>/etc/nca/ncaport.conf</filename>. The file can be used to manage the IP addresses and
ports that NCA uses. Your web server might not provide native support
of the AF_NCA socket. If your server lacks this support, use this
file and the NCA socket utility library to convert an AF_INET socket
to an AF_NCA socket.</para>
</listitem>
</itemizedlist>
</sect1><sect1 id="gcbks"><title>Web Servers Using the Secure Sockets Layer
Protocol</title><para>In the Solaris 10 6/06 release, an Apache 2.0 and a Sun Java
System Web Server may be configured to use the Secure Sockets Layer
(SSL) Protocol. The protocol provides confidentiality, message integrity
and end point authentication between two applications. The Solaris
kernel has been changed to accelerate the SSL traffic.</para>
</sect1><sect1 id="nca-35"><title>Managing Web Cache Servers (Task Map)</title><para>The following table describes the procedures that are needed
to use NCA or SSL.</para><informaltable frame="all" pgwide="1"><tgroup cols="3" colsep="1" rowsep="1"><colspec colwidth="33*"/><colspec colwidth="33*"/><colspec colwidth="33*"/><thead><row><entry><para>Task</para>
</entry><entry><para>Description</para>
</entry><entry><para>For Instructions</para>
</entry>
</row>
</thead><tbody><row><entry><para>Planning for NCA</para>
</entry><entry><para>A list of issues to be resolved before you enable the use
of NCA.</para>
</entry><entry><para><olink targetptr="nca-44" remap="internal">Planning for NCA</olink></para>
</entry>
</row><row><entry><para>Enabling NCA</para>
</entry><entry><para>Steps to enable in-kernel caching of web pages on a web server.</para>
</entry><entry><para><olink targetptr="nca-5" remap="internal">How to Enable Caching of Web Pages</olink></para>
</entry>
</row><row><entry><para>Disabling NCA</para>
</entry><entry><para>Steps to disable in-kernel caching of web pages on a web server.</para>
</entry><entry><para><olink targetptr="nca-13" remap="internal">How to Disable Caching of Web Pages</olink></para>
</entry>
</row><row><entry><para>Administering NCA logging</para>
</entry><entry><para>Steps to enable or disable the NCA logging process.</para>
</entry><entry><para><olink targetptr="nca-19" remap="internal">How to Enable or Disable NCA Logging</olink></para>
</entry>
</row><row><entry><para>Loading the NCA socket library</para>
</entry><entry><para>Steps to use NCA if the AF_NCA socket is not supported.</para>
</entry><entry><para><olink targetptr="nca-36" remap="internal">How to Load the Socket Utility Library
for NCA</olink></para>
</entry>
</row><row><entry><para>Using the SSL kernel proxy with an Apache 2.0 web server</para>
</entry><entry><para>Steps to use the SSL kernel proxy with a web server to improve
SSL packet processing.</para>
</entry><entry><para><olink targetptr="gcbjy" remap="internal">How to Configure an Apache 2.0 Web
Server to Use the SSL Kernel Proxy</olink></para>
</entry>
</row><row><entry><para>Using the SSL kernel proxy with a Sun Java System Web Server</para>
</entry><entry><para>Steps to use the SSL kernel proxy with a web server to improve
SSL packet processing.</para>
</entry><entry><para><olink targetptr="gcbwb" remap="internal">How to Configure a Sun Java System
Web Server to Use the SSL Kernel Proxy</olink></para>
</entry>
</row><row><entry><para>Using the SSL kernel proxy with a web server in a local zone</para>
</entry><entry><para>Steps to use the SSL kernel proxy with a web server in a local
zone.</para>
</entry><entry><para><olink targetptr="gcdwj" remap="internal">Using the SSL Kernel Proxy in Zones</olink></para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect1><sect1 id="nca-44"><title>Planning for NCA</title><para>The following sections cover the issues that need to be resolved
before starting the NCA service.</para><sect2 id="nca-39"><title>System Requirements for NCA</title><itemizedlist><para>To support NCA, the system must meet these requirements:</para><listitem><para>256 Mbytes RAM must be installed.</para>
</listitem><listitem><para>The Solaris 10, or 9 release, or one of the Solaris
8 upgrade releases must be installed.</para>
</listitem><listitem><itemizedlist><para>Support for a web server which has native support for NCA
or a web server whose startup script has been modified  to use the
Socket Utility Library for NCA:</para><listitem><para>Apache web server, ships with Solaris 8 upgrade,
Solaris 9, and Solaris 10 releases</para>
</listitem><listitem><para><trademark>Sun</trademark> Java System Web Server</para>
</listitem><listitem><para>Zeus web server available from Zeus Technology, <ulink url="http://www.zeus.com" type="url"></ulink></para>
</listitem>
</itemizedlist>
</listitem>
</itemizedlist><para>This product is intended to be run on a dedicated web server.
The running of other large processes on a server that runs NCA can
cause problems.</para>
</sect2><sect2 id="nca-45"><title>NCA Logging</title><para>The NCA service can be configured to log web activity. Generally,
NCA logging should be enabled if the web server logging is enabled.</para>
</sect2><sect2 id="nca-48"><title>Interpositioning Library for Daemon Support
of the Door Server</title><para>Many web servers use AF_INET sockets. By default, NCA
uses AF_NCA sockets. To correct this situation, an interpositioning
library is provided. The new library is loaded in front of the standard
socket library, <filename>libsocket.so</filename>. The library call <function>bind</function> is interposed by the new library, <filename>ncad_addr.so</filename>. Suppose that the status is enabled in <filename>/etc/nca/ncakmod.conf</filename>. The version of Apache that is included with the Solaris
9 and Solaris 10 release is already set up to call this library.
If you are using IWS or Netscape servers, see <olink targetptr="nca-36" remap="internal">How to Load the Socket Utility Library for NCA</olink> to use the
new library.</para>
</sect2><sect2 id="nca-46"><title>Multiple Instance Support</title><para>Systems that have NCA installed often need to run multiple
instances of a web server. For instance, a single server might need
to support a web server for outside access as well as a web administration
server. To separate these servers, you would configure each server
to use a separate port.</para>
</sect2>
</sect1><sect1 id="nca-4"><title>Administering the Caching of Web Pages
(Tasks)</title><para>The following sections cover the procedures to enable or disable
parts of the service.</para><task id="nca-5"><title>How to Enable Caching of Web Pages</title><procedure>&rolestepA;<step id="nca-step-8"><para>Register the interfaces.</para><para>Type the names of each of the physical interfaces in
the <filename>/etc/nca/nca.if</filename> file. See the <olink targetdoc="refman4" targetptr="nca.if-4" remap="external"><citerefentry><refentrytitle>nca.if</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> man
page for more information.</para><screen># <userinput>cat /etc/nca/nca.if</userinput>
hme0
hme1</screen><para>Each interface must have an accompanying <filename>hostname.<replaceable>interface-name</replaceable></filename> file and an entry in <filename>/etc/hosts</filename> file for the contents of <filename>hostname.<replaceable>interface-name</replaceable></filename>. To start the NCA feature
on all interfaces, place an asterisk, <literal>*</literal>, in the <filename>nca.if</filename> file.</para>
</step><step id="nca-step-9"><para>Enable the <filename>ncakmod</filename> kernel
module.</para><para>Change the <literal>status</literal> entry in <filename>/etc/nca/ncakmod.conf</filename> to <literal>enabled</literal>.</para><screen># <userinput>cat /etc/nca/ncakmod.conf</userinput>
#
# NCA Kernel Module Configuration File
#
status=<userinput>enabled</userinput>
httpd_door_path=/var/run/nca_httpd_1.door
nca_active=disabled</screen><para>See the <olink targetdoc="refman4" targetptr="ncakmod.conf-4" remap="external"><citerefentry><refentrytitle>ncakmod.conf</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> man page for more
information.</para>
</step><step performance="optional" id="nca-step-10"><para>Enable NCA logging.</para><para>Change the <literal>status</literal> entry in <filename>/etc/nca/ncalogd.conf</filename> to <literal>enabled</literal>.</para><screen># <userinput>cat /etc/nca/ncalogd.conf</userinput>
#
# NCA Logging Configuration File
#
status=<userinput>enabled</userinput>
logd_path_name="/var/nca/log"
logd_file_size=1000000</screen><para>You can change the location of the log file by changing
the path that is indicated by the <literal>logd_path_name</literal> entry.
The log file can be a raw device or a file. See the following examples
for samples of NCA log file paths. See the <olink targetdoc="refman4" targetptr="ncalogd.conf-4" remap="external"><citerefentry><refentrytitle>ncalogd.conf</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> man page for more
information about the configuration file.</para>
</step><step performance="optional" id="nca-step-47"><para>Define ports
for multiple instance support.</para><para>Add the port numbers
in the <filename>/etc/nca/ncaport.conf</filename> file. This entry
causes NCA to monitor port 80 on all configured IP addresses.</para><screen># <userinput>cat /etc/nca/ncaport.conf</userinput>
#
# NCA Kernel Module Port Configuration File
#
  .
  .
<userinput>ncaport=*/80</userinput></screen>
</step><step id="nca-step-11"><para>For x86 only: Increase the virtual
memory size.</para><para>Use the <command>eeprom</command> command
to set the <literal>kernelbase</literal> of the system.</para><screen># <userinput>eeprom kernelbase=0x90000000</userinput>
# <userinput>eeprom kernelbase</userinput>
kernelbase=0x90000000</screen><para>The second command verifies that the parameter has been set.</para><note><para>By setting the <literal>kernelbase</literal>, you reduce
the amount of virtual memory that user processes can use to less
than 3 Gbytes. This restriction means that the system is not ABI
compliant. When the system boots, the console displays a message
that warns you about noncompliance. Most programs do not actually
need the full 3&ndash;Gbyte virtual address space. If you have a
program that needs more than 3 Gbytes, you need to run the program
on a system that does not have NCA enabled.</para>
</note>
</step><step id="nca-step-12"><para>Reboot the server.</para>
</step>
</procedure><example><title>Using a Raw Device as the NCA Log File</title><para>The <literal>logd_path_name</literal> string in <filename>ncalogd.conf</filename> can define a raw device as the place to store the NCA
log file. The advantage to using a raw device is that the service
can run faster because the overhead in accessing a raw device is
less. </para><para>The NCA service tests any raw device that is listed in the
file to ensure that no file system is in place. This test ensures
that no active file systems are accidentally written over.</para><para>To prevent this test from finding a file system, run the following
command. This command destroys part of the file system on any disk
partition that had been configured as a file system. In this example, <literal>/dev/rdsk/c0t0d0s7</literal> is the raw device that has an old file
system in place.</para><screen># <userinput>dd if=/dev/zero of=/dev/rdsk/c0t0d0s7 bs=1024 count=1</userinput></screen><para>After running <command>dd</command>, you can then add the
raw device to the <filename>ncalogd.conf</filename> file.</para><screen># <userinput>cat /etc/nca/ncalogd.conf</userinput>
#
# NCA Logging Configuration File
#
status=enabled
logd_path_name="<userinput>/dev/rdsk/c0t0d0s7</userinput>"
logd_file_size=1000000</screen>
</example><example><title>Using Multiple Files for NCA Logging</title><para>The <literal>logd_path_name</literal> string in <filename>ncalogd.conf</filename> can define multiple targets as the place to store the
NCA log file. The second file is used when the first file is full.
The following example shows how to select to write to the <literal>/var/nca/log</literal> file first and then use a raw partition.</para><screen># <userinput>cat /etc/nca/ncalogd.conf</userinput>
#
# NCA Logging Configuration File
#
status=enabled
logd_path_name="<userinput>/var/nca/log /dev/rdsk/c0t0d0s7</userinput>"
logd_file_size=1000000</screen>
</example>
</task><task id="nca-13"><title>How to Disable Caching of Web Pages</title><procedure>&rolestepA;<step id="nca-step-16"><para>Disable the <filename>ncakmod</filename> kernel
module.</para><para>Change the <literal>status</literal> entry in <filename>/etc/nca/ncakmod.conf</filename> to <literal>disabled</literal>.</para><screen># <userinput>cat /etc/nca/ncakmod.conf</userinput>
# NCA Kernel Module Configuration File
#
status=<userinput>disabled</userinput>
httpd_door_path=/var/run/nca_httpd_1.door
nca_active=disabled</screen><para>See the <olink targetdoc="refman4" targetptr="ncakmod.conf-4" remap="external"><citerefentry><refentrytitle>ncakmod.conf</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> man page for more
information.</para>
</step><step id="nca-step-17"><para>Disable NCA logging.</para><para>Change
the <literal>status</literal> entry in <filename>/etc/nca/ncalogd.conf</filename> to <literal>disabled</literal>.</para><screen># <userinput>cat /etc/nca/ncalogd.conf</userinput>
#
# NCA Logging Configuration File
#
status=<userinput>disabled</userinput>
logd_path_name="/var/nca/log"
logd_file_size=1000000</screen><para>See the <olink targetdoc="refman4" targetptr="ncalogd.conf-4" remap="external"><citerefentry><refentrytitle>ncalogd.conf</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> man page for more
information.</para>
</step><step id="nca-step-18"><para>Reboot the server.</para>
</step>
</procedure>
</task><task id="nca-19"><title>How to Enable or Disable NCA Logging</title><tasksummary><para>NCA logging can be turned on or turned off, as needed,
after NCA has been enabled. See <olink targetptr="nca-5" remap="internal">How to
Enable Caching of Web Pages</olink> for more information.</para>
</tasksummary><procedure>&rolestepA;<step id="nca-step-22"><para>Change NCA logging.</para><para>To
permanently disable logging, you need to change the status in <filename>/etc/nca/ncalogd.conf</filename> to <literal>disabled</literal> and
reboot the system. See the <olink targetdoc="refman4" targetptr="ncalogd.conf-4" remap="external"><citerefentry><refentrytitle>ncalogd.conf</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> man page for more
information.</para><substeps><step id="nca-step-23"><para>Stop logging.</para><screen># <userinput>/etc/init.d/ncalogd stop</userinput></screen>
</step><step id="nca-step-24"><para>Start logging.</para><screen># <userinput>/etc/init.d/ncalogd start</userinput></screen>
</step>
</substeps>
</step>
</procedure>
</task><sect2 id="nca-36"><title>How to Load the Socket Utility Library
for NCA</title><para>Follow this process only if your web server does not provide
native support of the AF_NCA socket.</para><para>In the startup script for the web server, add a line that
causes the library to be preloaded. The line should resemble the
following:</para><screen><userinput>LD_PRELOAD=/usr/lib/ncad_addr.so /usr/bin/httpd</userinput></screen>
</sect2><task id="nca-49"><title>How to Add a New Port to the NCA Service</title><procedure>&rolestepA;<step id="nca-step-50"><para>Add a new port.</para><para>Add a new
port entry to <filename>/etc/nca/ncaport.conf</filename>. This example
adds port <literal>8888</literal> on IP address <literal>192.168.84.71</literal>.
See <olink targetdoc="refman4" targetptr="ncaport.conf-4" remap="external"><citerefentry><refentrytitle>ncaport.conf</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> for more information.</para><screen># <userinput>cat /etc/nca/ncaport.conf</userinput>
#
# NCA Kernel Module Port Configuration File
#
  .
  .
ncaport=*/80
<userinput>ncaport=192.168.84.71/8888</userinput></screen>
</step><step id="nca-step-51"><para>Start a new web instance.</para><para>An
address needs to be in the file that contains the NCA port configurations
before a web server can use the address for NCA. If the web server
is running, it must be restarted after the new address is defined.</para>
</step>
</procedure>
</task><task id="gcbjy"><title>How to Configure an Apache 2.0 Web Server
to Use the SSL Kernel Proxy</title><tasksummary><para>This procedure should be used to improve the performance of
SSL packet process on an Apache 2.0 web server.</para>
</tasksummary><taskprerequisites><para>The following procedure requires that an Apache 2.0 web server
has been installed and configured. The Apache 2.0 web server is
included in the Solaris 10 release.</para><para>To use the SSL kernel proxy, the server private key and the
server certificate need to exist in a single file. If only the <literal>SSLCertificateFile</literal> parameter is specified in the <filename>ssl.conf</filename> file, then the specified file can be used directly for
kernel SSL. If the <literal>SSLCertificateKeyFile</literal> parameter
is also specified, then the certificate file and the private key
file need to be combined. One way to combine the certificate and
the key file is to run the following command:</para><screen># <userinput>cat cert.pem key.pem >cert-and-key.pem</userinput></screen>
</taskprerequisites><procedure>&rolestepB;<step><para>Stop the web server.</para><para>This command will stop
the web server on a system in which the server is configured to
run using SMF.</para><screen># <userinput>svcadm disable svc:/network/http:apache2</userinput></screen><para>If the service has not be converted yet, stop the service
with this command syntax: <literal>/usr/apache2/bin/apachectl stop</literal></para>
</step><step><para>Determine what parameters to use with the <command>ksslcfg</command> command.</para><itemizedlist><para>All of the options are listed in the <citerefentry><refentrytitle>ksslcfg</refentrytitle><manvolnum>1M</manvolnum></citerefentry> man page. The parameters that you must have information
for are:</para><listitem><para><literal>key-format</literal> &ndash; Used with
the <option>f</option> option to define the certificate and key
format. For the SSL kernel proxy the value should be either <literal>pem</literal> or <literal>pkcs12</literal>.</para>
</listitem><listitem><para><literal>key-and-certificate-file</literal> &ndash;
Used with the <option>i</option> option to set the location of the
file that stores to server key and the certificate.</para>
</listitem><listitem><para><literal>password-file</literal> &ndash; Used with
the <option>p</option> option to select the location of the file
that includes the password used to encrypt the private key. This
password is used to allow unattended reboots. The permissions on
the file should be <literal>0400</literal>.</para>
</listitem><listitem><para><literal>proxy-port</literal> &ndash; Used with
the <option>x</option> option to set the SSL proxy port. Select
a different port than the standard port <literal>80</literal>.</para>
</listitem><listitem><para><literal>ssl-port</literal> &ndash; Selects the
port of the server application. Normally this is set to <literal>443</literal>.</para>
</listitem>
</itemizedlist><note><para>The <literal>ssl-port</literal> and the <literal>proxy-port</literal> values can not be configured for NCA since these ports
are used exclusively by the SSL kernel proxy. Usually, port 80 is
used for NCA, port 8080 for the <literal>proxy-port</literal> and
443 for the <literal>ssl-port</literal></para>
</note>
</step><step><para>Create the service instance.</para><para>The <command>ksslcfg</command> command to specify the SSL proxy port and associated
parameters.</para><screen>ksslcfg create -f <replaceable>key-format</replaceable> -i <replaceable>key-and-certificate-file</replaceable> -p <replaceable>password-file</replaceable> -x <replaceable>proxy-port</replaceable> <replaceable>ssl-port</replaceable></screen>
</step><step><para>Verify that the instance was created properly.</para><para>The service state reported by the following command should
be &ldquo;online&rdquo;.</para><screen># <userinput>svcs svc:/network/ssl/proxy</userinput></screen>
</step><step><para>Configure the web server to listen on the SSL proxy
port.</para><para>Edit the <filename>/etc/apache2/http.conf</filename> file
and add a line to define the SSL proxy port. If you use the servers
IP address, then the web server will only listen on that interface.
The line should look like:</para><screen>Listen 0.0.0.0:<replaceable>proxy-port</replaceable></screen>
</step><step><para>Set an SMF dependency for the web server.</para><para>The
web server should only be started after the SSL kernel proxy instance.
The following commands establish that dependency.</para><screen># <userinput>svccfg -s svc:/network/http:apache2</userinput>
svc:/network/http:apache2> <userinput>addpg kssl dependency</userinput>
svc:/network/http:apache2> <userinput>setprop kssl/entities = fmri:svc:/network/ssl/proxy:kssl-INADDR_ANY-443</userinput>
svc:/network/http:apache2> <userinput>setprop kssl/grouping = astring: require_all</userinput>
svc:/network/http:apache2> <userinput>setprop kssl/restart_on = astring: refresh</userinput>
svc:/network/http:apache2> <userinput>setprop kssl/type = astring: service</userinput>
svc:/network/http:apache2> <userinput>end</userinput></screen>
</step><step><para>Enable the web server.</para><screen># <userinput>svcadm enable svc:/network/http:apache2</userinput></screen><para>If the service is not started using SMF, use the following
command: <literal>/usr/apache2/bin/apachectl startssl</literal></para>
</step>
</procedure><example id="gcbwm"><title>Configuring an Apache 2.0 Web Server to Use the SSL Kernel
Proxy</title><para>The following command creates an instance using the <literal>pem</literal> key
format.</para><screen># <userinput>ksslcfg create -f pem -i cert-and-key.pem -p file -x 8080 443</userinput></screen>
</example>
</task><task id="gcbwb"><title>How to Configure a Sun Java System Web Server
to Use the SSL Kernel Proxy</title><tasksummary><para>This procedure should be used to improve the performance of
SSL packet process on a Sun Java System Web Server. See the <olink targetdoc="sjswsag" remap="external"><citetitle remap="book">Sun Java System Web Server 6.1 SP4 Administrator&rsquo;s Guide</citetitle></olink> for
information about this web server.</para>
</tasksummary><taskprerequisites><para>The following procedure requires that a Sun Java System Web
Server has been installed and configured.</para>
</taskprerequisites><procedure>&rolestepB;<step><para>Stop the web server.</para><para>Use the administrator
web interface to stop the server. See <citetitle>Starting and Stopping
the Server</citetitle> in the <olink targetdoc="sjswsag" remap="external"><citetitle remap="book">Sun Java System Web Server 6.1 SP4 Administrator&rsquo;s Guide</citetitle></olink>for more information.</para>
</step><step><para>Determine what parameters to use with the <command>ksslcfg</command> command.</para><itemizedlist><para>All of the options are listed in the <citerefentry><refentrytitle>ksslcfg</refentrytitle><manvolnum>1M</manvolnum></citerefentry> man page. The parameters that you must have information
for are:</para><listitem><para><literal>key-format</literal> &ndash; Used with
the <option>f</option> option to define the certificate and key
format.</para>
</listitem><listitem><para><literal>token-label</literal> &ndash; Used with
the <option>T</option> option to specify the PKCS#11 token.</para>
</listitem><listitem><para><literal>certificate-label</literal> &ndash; Used
with the <option>C</option> option to select the label in the certificate
object in the PKCS#11 token</para>
</listitem><listitem><para><literal>password-file</literal> &ndash; Used with
the <option>p</option> option to select the location of the file
that includes the password used to login the user to the PKCS#11
token used by the web server.. This password is used to allow unattended
reboots. The permissions on the file should be <literal>0400</literal>.</para>
</listitem><listitem><para><literal>proxy-port</literal>&ndash; Used with the <option>x</option> option to set the SSL proxy port. Select a different
port than the standard port <literal>80</literal>.</para>
</listitem><listitem><para><literal>ssl-port</literal> &ndash; Defines the
port of the server application. This value is set in the <literal>server.xml</literal> file. Normally this value is set to <literal>443</literal>.</para>
</listitem>
</itemizedlist><note><para>The <literal>ssl-port</literal> and the <literal>proxy-port</literal> values can not be configured for NCA since these ports
are used exclusively by the SSL kernel proxy. Usually, port 80 is
used for NCA, port 8080 for the <literal>proxy-port</literal> and
443 for the <literal>ssl-port</literal></para>
</note>
</step><step><para>Create the service instance.</para><para>The <command>ksslcfg</command> command to specify the SSL proxy port and associated
parameters.</para><screen>ksslcfg create -f <replaceable>key-format</replaceable> -T <replaceable>PKCS#11-token</replaceable> -C <replaceable>certificate-label</replaceable> -p <replaceable>password-file</replaceable> -x <replaceable>proxy-port</replaceable> <replaceable>ssl-port</replaceable></screen>
</step><step><para>Verify that the instance was created properly.</para><para>The service state reported by the following command should
be &ldquo;online&rdquo;.</para><screen># <userinput>svcs svc:/network/ssl/proxy</userinput></screen>
</step><step><para>Configure the web server to listen on the SSL proxy
port.</para><para>See <citetitle>Adding and Editing Listen Sockets</citetitle> in
the <olink targetdoc="sjswsag" remap="external"><citetitle remap="book">Sun Java System Web Server 6.1 SP4 Administrator&rsquo;s Guide</citetitle></olink> for
more information.</para>
</step><step><para>Start the web server.</para>
</step>
</procedure><example id="gcbxf"><title>Configuring a Sun Java System Web Server to Use the SSL Kernel
Proxy</title><para>The following command creates an instance using the <literal>pkcs11</literal> key format.</para><screen># <userinput>ksslcfg create -f pkcs11 -T "NSS Internal PKCS #11 Module" -C "Server-Cert" -p file -x 8080 443</userinput></screen>
</example>
</task><sect2 id="gcdwj"><title>Using the SSL Kernel Proxy in Zones</title><itemizedlist><para>The SSL Kernel Proxy works in zones with the following limitations:</para><listitem><para>All of the kernel SSL administration must be done
from the global zone. The global zone administrator needs access
to the local zone certificate and key files. The local zone web
server can be started once the service instance is configured using
the <command>ksslcfg</command> command in the global zone.</para>
</listitem><listitem><para>A specific host name or IP address must be specified
when running the <command>ksslcfg</command> command to configure
the instance. In particular, the instance can not use INADDR_ANY.</para>
</listitem>
</itemizedlist><example id="gcdwx"><title>Configuring an Apache Web Server in a
Local Zone to Use the SSL Kernel Proxy</title><para>In the local zone, first stop the web server. In the global
zone do all of the steps to configure the service. To create a instance
for a local zone called <literal>apache-zone</literal>, use the
following command:</para><screen># <userinput>ksslcfg create -f pem -i /zone/apache-zone/root/keypair.pem -p /zone/apache-zone/root/pass \
    -x 8080 apache-zone 443</userinput></screen><para>In the local zone, run the following command to enable the
service instance:</para><screen># <userinput>svcadm enable svc:/network/http:apache2</userinput></screen>
</example>
</sect2>
</sect1><sect1 id="nca-27"><title>Caching Web Pages (Reference)</title><para>The following sections cover the files and the components
that are needed to use NCA. Also, specifics about how NCA interacts
with the web server are included.</para><sect2 id="nca-25"><title>NCA Files</title><para>You need several files to support the NCA feature. Many
of these files are ASCII, but some of the files are binary. The
following table lists all of the files.</para><table frame="topbot" id="nca-tbl-26"><title>NCA Files</title><tgroup cols="2" colsep="0" rowsep="0"><colspec colnum="1" colname="column1" colwidth="5*"/><colspec colnum="2" colname="column2" colwidth="5*"/><thead><row rowsep="1"><entry><para>File Name</para>
</entry><entry><para>Function</para>
</entry>
</row>
</thead><tbody><row><entry><para><filename>/dev/nca</filename> </para>
</entry><entry><para>The path name for the NCA device.</para>
</entry>
</row><row><entry><para><filename>/etc/hostname.<replaceable>*</replaceable></filename>  </para>
</entry><entry><para>File that lists all physical interfaces that are configured
on the server.</para>
</entry>
</row><row><entry><para><filename>/etc/hosts</filename>  </para>
</entry><entry><para>File that lists all host names that are associated with the
server. Entries in this file must match entries in <filename>/etc/hostname.<replaceable>*</replaceable></filename> files for NCA to function.</para>
</entry>
</row><row><entry><para><filename>/etc/init.d/ncakmod</filename>  </para>
</entry><entry><para>Script that starts the NCA server. This script is run when
a server is booted.</para>
</entry>
</row><row><entry><para><filename>/etc/init.d/ncalogd</filename>  </para>
</entry><entry><para>Script that starts NCA logging. This script is run when a
server is booted.</para>
</entry>
</row><row><entry><para><filename>/etc/nca/nca.if</filename>  </para>
</entry><entry><para>File that lists the interfaces on which NCA is run. See the <olink targetdoc="refman4" targetptr="nca.if-4" remap="external"><citerefentry><refentrytitle>nca.if</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> man
page for more information.</para>
</entry>
</row><row><entry><para><filename>/etc/nca/ncakmod.conf</filename>  </para>
</entry><entry><para>File that lists configuration parameters for NCA. See the <olink targetdoc="refman4" targetptr="ncakmod.conf-4" remap="external"><citerefentry><refentrytitle>ncakmod.conf</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> man page for more information.</para>
</entry>
</row><row><entry><para><filename>/etc/nca/ncalogd.conf</filename>   </para>
</entry><entry><para>File that lists configuration parameters for NCA logging.
See the <olink targetdoc="refman4" targetptr="ncalogd.conf-4" remap="external"><citerefentry><refentrytitle>ncalogd.conf</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> man page for more information.</para>
</entry>
</row><row><entry><para><filename>/etc/nca/ncaport.conf</filename>   </para>
</entry><entry><para>File that lists the IP addresses and the ports for NCA. See
the <olink targetdoc="refman4" targetptr="ncaport.conf-4" remap="external"><citerefentry><refentrytitle>ncaport.conf</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> man page for more information.</para>
</entry>
</row><row><entry><para><command>/usr/bin/ncab2clf</command>   </para>
</entry><entry><para>Command that is used to convert data in the log file to the
common log format. See the <olink targetdoc="refman1" targetptr="ncab2clf-1" remap="external"><citerefentry><refentrytitle>ncab2clf</refentrytitle><manvolnum>1</manvolnum></citerefentry></olink> man page for more
information.</para>
</entry>
</row><row><entry><para><command>/usr/lib/net/ncaconfd</command>   </para>
</entry><entry><para>Command that is used to configure NCA to run on multiple interfaces
during boot. See the <olink targetdoc="refman1m" targetptr="ncaconfd-1m" remap="external"><citerefentry><refentrytitle>ncaconfd</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> man page for more
information.</para>
</entry>
</row><row><entry><para><command>/usr/lib/nca_addr.so</command>   </para>
</entry><entry><para>Library that uses AF_NCA sockets instead of AF_INET sockets.
This library must be used on web servers that use AF_INET sockets.
See the <olink targetdoc="refman4" targetptr="ncad-addr-4" remap="external"><citerefentry><refentrytitle>ncad_addr</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> man page for more information.</para>
</entry>
</row><row><entry><para><filename>/var/nca/log</filename>   </para>
</entry><entry><para>File that holds the log file data. The file is in binary format,
so do not edit it.</para>
</entry>
</row><row><entry><para><filename>/var/run/nca_httpd_1.door</filename>   </para>
</entry><entry><para>The door path name.</para>
</entry>
</row>
</tbody>
</tgroup>
</table>
</sect2><sect2 id="nca-28"><title>NCA Architecture</title><para>The NCA feature includes the following components.</para><itemizedlist><listitem><para>Kernel module, <literal>ncakmod</literal></para>
</listitem><listitem><para>Web server, <literal>httpd</literal></para>
</listitem>
</itemizedlist><para>The kernel module <literal>ncakmod</literal> maintains the
cache of web pages in system memory. The module communicates with
a web server, <literal>httpd</literal>, through a sockets interface.
The family type is PF_NCA.</para><para>The kernel module also provides a logging facility that logs
all HTTP cache hits. NCA logging writes HTTP data to the disk in
binary format. NCA provides a conversion utility for converting
binary log files to common log format (CLF).</para><para>The following figure shows the flow of data for the conventional
path and the path that is used when NCA is enabled.</para><figure id="nca-fig-42"><title>Data Flow With the NCA Service</title><mediaobject><imageobject><imagedata entityref="nca-stack"/>
</imageobject><textobject><simpara>Flow diagram shows the flow of data from a
client request through the NCA layer in the kernel.</simpara>
</textobject>
</mediaobject>
</figure><sect3 id="nca-30"><title>NCA to Httpd Request Flow</title><para>The following list shows the request flow between the client
and the web server.</para><orderedlist><listitem><para>An HTTP request is made from the client to the web
server.</para>
</listitem><listitem><para>If the page is in cache, the in-kernel cache web
page is returned.</para>
</listitem><listitem><para>If the page is not in cache, the request goes to
the web server to retrieve or update the page.</para>
</listitem><listitem><para>Depending on the HTTP protocol semantics that are
used in the response, the page is cached or not. Then the page is
returned to the client. If the Pragma: No-cache header is included
in the HTTP request, the page is not cached.</para>
</listitem>
</orderedlist>
</sect3>
</sect2>
</sect1>
</chapter>