Apache Cookbook
Publisher: O'Reilly Media
Published: 2007
Place of publication: Sebastapol, California, USA
Table of contents: title: Preface ..................................................................... xi; title: 1. Installation ............................................................. 1; title: 1.1 Installing from Red Hat Linux’s Packages 2; title: 1.2 Installing from Debian Packages 3; title: 1.3 Installing Apache on Windows 4; title: 1.4 Downloading the Apache Sources 7; title: 1.5 Building Apache from the Sources 10; title: 1.6 Installing with ApacheToolbox 12; title: 1.7 Starting, Stopping, and Restarting Apache 15; title: 1.8 Uninstalling Apache 18; title: 1.9 Which Version of Apache to Use 19; title: 1.10 Upgrading Using config.nice 21; title: 1.11 Starting Apache at Boot 22; title: 1.12 Useful configure Options 22; title: 1.13 Finding Apache’s Files 24; title: 2. Adding Common Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27; title: 2.1 Installing a Generic Third-Party Module 28; title: 2.2 Installing mod_dav on a Unixish System 28; title: 2.3 Installing mod_dav on Windows 31; title: 2.4 Installing mod_perl on a Unixish System 33; title: 2.5 Installing mod_php on a Unixish System 35; title: 2.6 Installing mod_php on Windows 36; title: 2.7 Installing mod_ssl 37; title: 2.8 Finding Modules Using Modules.Apache.Org 38; title: 2.9 Installing mod_security 39; title: 2.10 Why Won’t This Module Work? 40; title: 3. Logging ............................................................... 43; title: 3.1 Getting More Details in Your Log Entries 46; title: 3.2 Getting More Detailed Errors 47; title: v; title: 4.; title: 3.3 Logging POST Contents 49; title: 3.4 Logging a Proxied Client’s IP Address 50; title: 3.5 Logging Client MAC Addresses 51; title: 3.6 Logging Cookies 51; title: 3.7 Not Logging Image Requests from Local Pages 53; title: 3.8 Rotating logfiles at a particular time 54; title: 3.9 Rotating Logs on the First of the Month 55; title: 3.10 Logging Hostnames Instead of IP Addresses 56; title: 3.11 Maintaining Separate Logs for Each Virtual Host 57; title: 3.12 Logging Proxy Requests 58; title: 3.13 Logging Errors for Virtual Hosts to Multiple Files 59; title: 3.14 Logging Server IP Addresses 60; title: 3.15 Logging the Referring Page 61; title: 3.16 Logging the Name of the Browser Software 62; title: 3.17 Logging Arbitrary Request Header Fields 63; title: 3.18 Logging Arbitrary Response Header Fields 63; title: 3.19 Logging activity to a MySQL database 64; title: 3.20 Logging to syslog 65; title: 3.21 Logging user directories 67; title: Virtual Hosts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69; title: 4.1 Setting Up Name-Based Virtual Hosts 70; title: 4.2 Designating One Name-Based Virtual Host as the Default 72; title: 4.3 Setting Up Address-Based Virtual Hosts 73; title: 4.4 Creating a Default Address-Based Virtual Host 73; title: 4.5 Mixing Address-Based and Name-Based Virtual Hosts 74; title: 4.6 Mass Virtual Hosting with mod_vhost_alias 75; title: 4.7 Mass Virtual Hosting Using Rewrite Rules 77; title: 4.8 Logging for Each Virtual Host 78; title: 4.9 Splitting Up a LogFile 79; title: 4.10 Port-Based Virtual Hosts 79; title: 4.11 Displaying the Same Content on Several Addresses 80; title: 4.12 Defining virtual hosts in a database 81; title: Aliases, Redirecting, and Rewriting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83; title: 5.1 Mapping a URL to a Directory 83; title: 5.2 Creating a New URL for Existing Content 85; title: 5.3 Giving Users Their Own URLs 86; title: 5.4 Aliasing Several URLs with a Single Directive 89; title: 5.5 Mapping Several URLs to the Same CGI Directory 89; title: 5.6 Creating a CGI Directory for Each User 90; title: 5.7 Redirecting to Another Location 91; title: 5.8 Redirecting Several URLs to the Same Destination 93; title: Table of Contents; title: 5.; label: vi; title: 5.9 Permitting Case-Insensitive URLs 94; title: 5.10 Showing Highlighted PHP Source without Symlinking 94; title: 5.11 Replacing Text in Requested URLs 96; title: 5.12 Rewriting Path Information to CGI Arguments 97; title: 5.13 Denying Access to Unreferred Requests 98; title: 5.14 Redirecting Unreferred Requests to an Explanation Page 99; title: 5.15 Rewriting Based on the Query String 100; title: 5.16 Redirecting All—or Part—of Your Server to SSL 100; title: 5.17 Turning Directories into Hostnames 101; title: 5.18 Redirecting All Requests to a Single Host 102; title: 5.19 Turning Document Names into Arguments 103; title: 5.20 Rewriting Elements between Path and Query String 103; title: 5.21 Rewriting a Hostname to a Directory 104; title: 5.22 Turning URL Segments into Query Arguments 105; title: 5.23 Using AliasMatch, ScriptAliasMatch, and RedirectMatch 105; title: 6. Security .............................................................. 107; title: 6.1 Using System Account Information for Web Authentication 109; title: 6.2 Setting Up Single-Use Passwords 110; title: 6.3 Expiring Passwords 111; title: 6.4 Limiting Upload Size 113; title: 6.5 Restricting Images from Being Used Off-Site 115; title: 6.6 Requiring Both Weak and Strong Authentication 116; title: 6.7 Managing .htpasswd Files 117; title: 6.8 Making Password Files for Digest Authentication 119; title: 6.9 Relaxing Security in a Subdirectory 120; title: 6.10 Lifting Restrictions Selectively 122; title: 6.11 Authorizing Using File Ownership 124; title: 6.12 Storing User Credentials in a MySQL Database 124; title: 6.13 Accessing the Authenticated Username 126; title: 6.14 Obtaining the Password Used to Authenticate 127; title: 6.15 Preventing Brute-Force Password Attacks 128; title: 6.16 Using Digest Versus Basic Authentication 129; title: 6.17 Accessing Credentials Embedded in URLs 130; title: 6.18 Securing WebDAV 130; title: 6.19 Enabling WebDAV Without Making Files Writable by the; title: Web User 131; title: 6.20 Restricting Proxy Access to Certain URLs 132; title: 6.21 Protecting Files with a Wrapper 134; title: 6.22 Protecting Server Files from Malicious Scripts 136; title: 6.23 Setting Correct File Permissions 136; title: 6.24 Running a Minimal Module Set 139; title: 6.25 Restricting Access to Files Outside Your Web Root 141; title: Table of Contents; title: vii; title: 7.; title: 8.; title: 6.26 Limiting Methods by User 142; title: 6.27 Restricting Range Requests 143; title: 6.28 Rebutting DoS Attacks with mod_evasive 145; title: 6.29 chrooting Apache with mod_security 146; title: 6.30 Migrating to 2.2 Authentication 147; title: 6.31 Blocking Worms with mod_security 148; title: 6.32 MixingRead-OnlyandWriteAccesstoaSubversionRepository; title: 149; title: 6.33 Using Permanent Redirects to Obscure Forbidden URLs 150; title: SSL .................................................................. 153; title: 7.1 Installing SSL 153; title: 7.2 Installing SSL on Windows 155; title: 7.3 Generating Self-Signed SSL Certificates 155; title: 7.4 Generating a Trusted CA 160; title: 7.5 Serving a Portion of Your Site via SSL 161; title: 7.6 Authenticating with Client Certificates 163; title: 7.7 SSL Virtual Hosts 164; title: 7.8 Wildcard Certificates 166; title: Dynamic Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167; title: 8.1 Enabling a CGI Directory 167; title: 8.2 Enabling CGI Scripts in Non-ScriptAliased Directories 168; title: 8.3 Specifying a Default Document in a CGI Directory 169; title: 8.4 Using Windows File Extensions to Launch CGI Programs 171; title: 8.5 Using Extensions to Identify CGI Scripts 172; title: 8.6 Testing that CGI is Set up Correctly 173; title: 8.7 Reading Form Parameters 176; title: 8.8 Invoking a CGI Program for Certain Content Types 178; title: 8.9 Getting SSIs to Work 180; title: 8.10 Displaying Last Modified Date 182; title: 8.11 Including a Standard Header 182; title: 8.12 Including the Output of a CGI Program 183; title: 8.13 Running CGI Scripts as a Different User with suexec 184; title: 8.14 Installing a mod_perl Handler from CPAN 186; title: 8.15 Writing a mod_perl Handler 187; title: 8.16 Enabling PHP Script Handling 189; title: 8.17 Verifying PHP Installation 189; title: 8.18 Parsing CGI output for Server Side Includes 190; title: 8.19 Parsing ScriptAlias Script Output for Server Side Includes 191; title: 8.20 Getting mod_perl to handle all Perl scripts 192; title: 8.21 Enabling Python Script Handling 193; title: Table of Contents; label: viii; title: 9. Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195; title: 9.1 Handling a Missing Host Field 195; title: 9.2 Changing the Response Status for CGI Scripts 196; title: 9.3 Customized Error Messages 197; title: 9.4 Providing Error Documents in Multiple Languages 198; title: 9.5 Redirecting Invalid URLs to Some Other Page 199; title: 9.6 Making Internet Explorer Display Your Error Page 200; title: 9.7 Notification on Error Conditions 201; title: 10. Proxies; title: .............................................................. 203; title: 10.1 Securing Your Proxy Server 203; title: 10.2 Preventing Your Proxy Server from Being Used as an Open; title: Mail Relay 205; title: 10.3 Forwarding Requests to Another Server 205; title: 10.4 Blocking Proxied Requests to Certain Places 207; title: 10.5 Proxying mod_perl Content to Another Server 207; title: 10.6 Configuring a Caching Proxy Server 208; title: 10.7 Filtering Proxied Content 209; title: 10.8 Requiring Authentication for a Proxied Server 210; title: 10.9 Load Balancing with mod_proxy_balancer 211; title: 10.10 Proxied Virtual Host 212; title: 10.11 Refusing to Proxy FTP 213; title: 11. Performance ..........................................................215; title: 11.1 Determining How Much Memory You Need 215; title: 11.2 Benchmarking Apache with ab 217; title: 11.3 Tuning Keepalive Settings 218; title: 11.4 Getting a Snapshot of Your Site’s Activity 219; title: 11.5 Avoiding DNS Lookups 221; title: 11.6 Optimizing Symbolic Links 222; title: 11.7 Minimizing the Performance Impact of .htaccess Files 223; title: 11.8 Disabling Content Negotiation 225; title: 11.9 Optimizing Process Creation 227; title: 11.10 Tuning Thread Creation 228; title: 11.11 Caching Frequently Viewed Files 229; title: 11.12 Distributing Load Evenly Between Several Servers 231; title: 11.13 Caching Directory Listings 232; title: 11.14 Speeding Up Perl CGI Programs with mod_perl 233; title: 11.15 Caching Dynamic Content 235; title: 12. Directory Listings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237; title: 12.1 Generating Directory/Folder Listings 237; title: 12.2 Display a Standard Header and Footer on Directory Listings 239; label: Table of Contents
title: ix; title: 12.3 Applying a Style Sheet 240; title: 12.4 Hiding Things from the Listing 240; title: 12.5 Searching for Certain Files in a Directory Listing 241; title: 12.6 Sorting the List 241; title: 12.7 Allowing a Client-Specified Sort Order 242; title: 12.8 Specifying How the List Will Be Formatted 243; title: 12.9 Allowing the Client to Specify the Formatting 244; title: 12.10 Adding Descriptions to Files 245; title: 12.11 AutoGenerated Document Titles 245; title: 12.12 Changing the Listing Icons 246; title: 12.13 Listing the Directories First 247; title: 12.14 Ordering by Version Number 247; title: 12.15 Allowing the End User to Specify Version Sorting 248; title: 12.16 Complete User Control of Output 248; title: 12.17 Don’t Allow the End User to Modify the Listing 249; title: 12.18 Suppressing Certain Columns 250; title: 12.19 Showing Forbidden Files 251; title: 12.20 Aliases in Directory Listings 251; title: 13. Miscellaneous Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253; title: 13.1 Placing Directives Properly 253; title: 13.2 Renaming .htaccess Files 255; title: 13.3 Generating Directory/Folder Listings 256; title: 13.4 Solving the “Trailing Slash” Problem 258; title: 13.5 Setting the Content-Type According to Browser Capability 259; title: 13.6 Handling Missing Host: Header Fields 259; title: 13.7 Alternate Default Document 260; title: 13.8 Setting Up a Default “Favicon” 261; title: 13.9 Setting Up a Default “Favicon” 262; title: 13.10 Enabling .htaccess Files 263; title: 13.11 Converting IBM/Lotus Server-Side Includes to Apache 263; title: A. Using Regular Expressions in Apache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265; title: B. Troubleshooting ...................................................... 271; title: Index ..................................................................... 279