[Top] [Prev] [Next] [Last]
|
|
Chapter 1Basic Administration
This chapter discusses basic server administration tasks, including how to
- start and stop the Stronghold Web Server
- navigate the server directory tree
- use the logs and reports
- track sessions
Starting and Stopping Stronghold
Stronghold Web Server comes with three scripts designed to automate the starting, restarting, and shutting down of your server. All three are located in the ServerRoot/bin/ directory. This section shows you how to run these scripts from the command line. If you decide to customize the scripts or write your own, read the existing scripts carefully before doing so.
Starting Stronghold
# bin/start-server
# bin/decrypt_key hostname
# bin/change_pass hostname
NOTE: The change_pass script encrypts the key after changing the pass phrase. If you were storing the key unencrypted, run decrypt_key again after you run change_pass.
Restarting Stronghold
The reload-server script lets you restart the Stronghold Web Server server in one step:
# bin/reload-server
Shutting Stronghold Down
To shut down the server, simply run the stop-server script:
# bin/stop-server
The Server Directory Tree
Using Logs and Reports
By default, Stronghold Web Server compiles with the modules that implement
- access logs
- error logs
- cipher logs
- custom logs
- server status reports
- server information reports
- agent logs
- referer logs
Access Logs
- ServerRoot/logs/access_log records all normal, HTTP transactions.
The location of this log is set with a TransferLog directive in the global configuration section of httpd.conf.
- ServerRoot/logs/ssl/access_log records all secure, HTTPS transactions.
By default, the access logs follow the common log format, which contains these fields:
- remote hostname or IP
- basic authentication username (if applicable)
- identd (RFC1413) username (if applicable and enabled)
- date and time
- request
- returned status code
For a full list of status codes and their meanings, see Appendix B.
- bytes sent
mserver42.n-link.com - - [29/Oct/1996:18:17:21 -0800] "GET / HTTP/1.0" 200 2291
207.176.149.181 - - [29/Oct/1996:18:17:21 -0800] "GET /~ic/img/skullt.gif HTTP/1.0" 200 -
proxy.ozemail.net - - [29/Oct/1996:18:17:23 -0800] "GET /~pre111/api5.html HTTP/1.0" 200 244
proxy.ozemail.net - - [29/Oct/1996:18:17:23 -0800] "GET /~pre111/api6.html HTTP/1.0" 304 -
In this example, none of the transactions involved authentication, so the second and third fields are empty. In the last entry, the server sent a status code of 304 Not Modified, meaning "use local copy," and the body of the message was empty. Therefore, the byte field is also empty.
The access log can be configured to contain a combination of fields other than the default. The log configuration directive is LogFormat, which uses a string of variables to set the type and order of the fields. The default log has the following format:
LogFormat "%h %u %l %t \"%r\" %>s %b
To configure the log, you can change the order of the field variables, remove unwanted variables, or add different ones. For a complete list of log format variables, see "Custom Logs" on page 1-8.
Error Logs
Stronghold keeps two error logs:
- ServerRoot/logs/error_log records errors that occur during normal, HTTP transactions. Its location is set with the ErrorLog directive.
- ServerRoot/logs/ssl/error_log records errors that occur during secure, HTTPS transactions. Its location is set with the SSLErrorFile directive.
The location of the error log is set during installation, but you can change it at any time by editing the ErrorLog directive in httpd.conf. This directive can also be set to "syslog" to pipe the error logs through syslogd(8), if the system supports it.
Stronghold's error log records two types of errors in two different forms:
- requests that cause the server to return an error-related status code:
[date] [error-level] [client IP] error-message
The error-level denotes the error's degree of severity. Only errors at or above the level specified by the LogLevel directive are recorded. The error-message does not include the corresponding status code, which is recorded separately in the access log. Error-related status codes are listed in "Server Errors" on page B-6.
- CGI errors:
location: error-message
tail -f error_log
Cipher Logs
The default location of the cipher log is ServerRoot/logs/ssl/cipher_log. It is set with the SSLLogFile directive. A typical cipher log entry looks like this:
[11/Nov/1997:13:55:42 -0800] SSLv3 RC4-MD5 reused 0 "ok" "/O=C2Net/CN=Sonya L. Jo/Email=sony@c2.net"
- date, time, and time zone offset (from GMT)
- SSL/TLS version number for this transaction, either "SSLv2," "SSLv3," or "TLSv1"
- cipher used to encrypt this transaction
For a complete list of ciphers supported by Stronghold Web Server, see the table on page 2-7.
- "new" or "reused," depending on whether the requested file was newly retrieved or reused from the cache
- verification status code: "0" if verification succeeded
- verification status: "ok" if certificate verification succeeded, or an error message if verification failed
- contents of the Organization, Common Name, and Email fields of the client certificate presented for this transaction, if any
Custom Logs
The CustomLog directive can be used to create multiple logs in custom formats. The value for CustomLog is a path followed by a string of variables or the name of a log format defined by a LogFormat directive. Each variable specifies the content of a log field.
CustomLog logs/customlog %400,501{User-Agent}i
This example logs the contents of the User-Agent header when a 400 (Bad Request) or 501 (Not Implemented) error occurs. The status code can be preceded by a "!" to exclude certain conditions from logging. For example:
CustomLog logs/customlog %!200,304,302{Referer}i
This example logs the referring URI for all requests that do not return a normal status code such as 200 OK, 302 Moved Temporarily, or 304 Not Modified.
Server Status Reports
Stronghold includes the mod_status module for on-the-fly HTML status reports that provide instant access to server activity statistics. Although mod_status is compiled into Stronghold by default, status reports are turned off to conserve server resources. To enable status reports, set the ExtendedStatus directive to "on."
- the current date and time
- the date and time when the server was last started or restarted
- the server uptime
- the total number of accesses
- the total traffic volume
- the CPU usage
- the average number of requests per second, average volume per second, and average volume per request
- the number of requests currently being processed
- the current number of idle children
- a snapshot of the ScoreBoardFile
Figure 1-1: Server Status Report
The snapshot of the ScoreBoardFile has two parts: a quick summary in ASCII and a detailed report in tabular form. Each character in the quick summary represents one child process. Children represented by a period (.) are unused but available as determined by the MaxSpareServers directive. Children in use are each represented by a code:
Code Description _ waiting for a connection S starting up R reading a request W writing a response K keepalive (waiting) D performing a DNS lookup L logging a transaction The same codes are reflected in the table, which gives the following details about each child:
<Location /stronghold-status>
SetHandler server-status
</Location>
Add the following inside the container:
<Limit GET POST>
order deny,allow
deny from all
allow from .your.domain
</Limit>
To access the server status report
- Access http://your.server.name/stronghold-status/ with a Web browser.
- For an automatically refreshing status report, access the page as http://your.server.name/stronghold-status?refresh=n where n is the number of seconds in a refresh cycle.
- For a machine-readable version of the status file, access http://your.server.name/stronghold-status?auto.
Server Information Reports
Server information reports provide comprehensive server configuration information, including
- a list of the modules currently compiled into the server
- the server version
- the core server configuration
- the available configuration directives for each module
- the current configuration for each module
- additional information about modules, if configured with AddModuleInfo
Figure 1-2: Server Information Report
Optional Logs
Two optional logs are available:
- Agent logs record the client used for each request in order to track which browsers visitors are using. They are supported by mod_log_agent and configured with the AgentLog directive.
- Referer logs record the links users follow to reach the site in order to track which sites are linked to this one. They are supported by mod_log_referer and configured with the RefererLog directive.
Keep in mind that these logs can also be implemented using the CustomLog directive, described in "Custom Logs" on page 1-8.
Rotating the Logs
Since log files grow larger and larger as they accumulate more information, you'll eventually need to rotate the logs so that no single log file becomes too large. The access log, for example, occupies about 1 MB per 10,000 requests. After several hundred thousand requests, the access log can become unwieldy and difficult to manage. Logs can be rotated manually or by using the automatic rotatelogs utility.
NOTE: Logs configured with the CustomLog directive must be rotated manually.
To rotate a log file manually
- Move the old file:
# mv logfile logfile.old
- Restart the server:
# reload-server
To rotate a log file using rotatelogs
- Locate the log file's directive in httpd.conf.
Rotatelogs works with the TransferLog, ErrorLog, CookieLog, SSLLogFile, SSLErrorFile, ScriptLog, AgentLog, and RefererLog directives. It does not work with CustomLog.
- Replace the directive's filename value with a string of the following form:
"|rotatelogs ServerRoot/logs/filename n"
- Save the modified configuration file.
- Restart the server:
# reload-server
Tracking Sessions
Since HTTP implements single, self-contained transactions, it provides no built-in way to track a whole session, which consists of more than one transaction. Exchanges of requests and responses occur individually, and each exchange appears to be unrelated to the last. However, today's complex, interactive Web applications require session tracking in order to implement features such as site customization, preference tracking, and so on.
There are two ways to perform session tracking:
- cookies, which pass the session ID in the HTTP header
- the PATH_INFO variable, which encodes the session ID in the URL
Session Tracking with Cookies
Cookies, supported by the mod_usertrack module, are session IDs that are exchanged as HTTP metainformation. When the CookieTracking directive is set to "on," Stronghold automatically generates a session ID whenever it receives a request that does not already include a cookie. Depending on whether it appears inside a container, CookieTracking can apply to the whole server, a single virtual host, or only an object such as a directory or file. A session that uses cookies works like this:
- A client submits a request that does not include a cookie.
- Stronghold generates a session ID and sends it in the Set-Cookie header of its response.
- The client returns the cookie in the Cookie header of each subsequent request.
- Dynamic contents programs may read the session ID in the HTTP_COOKIE variable.
The Set-Cookie header uses this syntax:
Set-Cookie name=value; expires=date; path=pathname; domain=domain-name; secure
Stronghold sets only the name field and the domain field, unless httpd.conf contains the CookieExpires directive. Without this directive, cookies are deleted when the client quits and Stronghold issues a new one at the beginning of the next session. When CookieExpires is set, Stronghold sends the expires field and the client saves the cookie until it expires.
Cookie: name=gw427516826238200437
By reading the HTTP_COOKIE environment variable, a program can track related requests and produce dynamic content based on multiple requests over the course of a session.
CustomLog logs/clickstream "%{cookie}i %r %t"
Session Tracking with PATH_INFO
The PATH_INFO variable places a session identification token in the URL, instead of in the response header. The client then uses the GET request method to communicate its token to the server, instead of the Cookie header described in the previous section. This method accommodates older browsers that do not support cookies, as well as users who do not accept cookies.
[Top] [Prev] [Next] [Last]
© 1998 C2Net International
Feedback: stronghold-docs@c2.net![]()