apache2 bootcamp : using apache to serve static content

20
Day #2 Using Apache to Serve Static Content Wildan Maulana [email protected] http://workshop.openthinklabs.com #5

Upload: wildan-maulana

Post on 19-Jul-2015

509 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Apache2 BootCamp : Using Apache to Serve Static Content

Day #2Using Apache to Serve Static Content

Wildan [email protected]

http://workshop.openthinklabs.com

#5

Page 2: Apache2 BootCamp : Using Apache to Serve Static Content

Overview

● How to configure Apache to listen on different IP addresses and ports

● How to organize the URL space with directory aliasing and redirection

● How to customize the server information and error messages

Page 4: Apache2 BootCamp : Using Apache to Serve Static Content

Customizing the Web Server

● Error Messages● International Error Messages● Handling URL Errors: mod_speling

● Customizing Server Information● Server Identification● Contact Information

Page 5: Apache2 BootCamp : Using Apache to Serve Static Content

Customizing the Web ServerError Messages

ErrorDocument

ErrorDocument 500 http://foo.example.com/cgi-bin/testerErrorDocument 404 /cgi-bin/bad_urls.plErrorDocument 401 /subscription_info.htmlErrorDocument 403 "Sorry can't allow you access today"

Page 6: Apache2 BootCamp : Using Apache to Serve Static Content

Customizing the Web ServerInternational Error Messages

Server Side Includes (mod_include) and content negotiation (mod_negotiation).

Custom Error Codes

Page 7: Apache2 BootCamp : Using Apache to Serve Static Content

Customizing the Web ServerHandling URL Errors: mod_speling

CheckSpelling

Page 8: Apache2 BootCamp : Using Apache to Serve Static Content

Customizing the Web ServerServer Identification & Contact Information

ServerTokens Options

Settings Output

ServerTokens ProductOnly Apache

ServerTokens Minimal Apache/2.0.28

ServerTokens OS Apache/2.0.28 (Unix)

ServerTokens Full Apache/2.0.28 (Unix) SSL/2.0. 0

ServerSignature On/Off

ServerAdmin [email protected]

Page 9: Apache2 BootCamp : Using Apache to Serve Static Content

Aliasing and Mapping of Resources

Alias /icons/ /usr/local/apache2/icons/

AliasMatch ^/help(.*) /usr/local/apache/htdocs/manual$1

Page 10: Apache2 BootCamp : Using Apache to Serve Static Content

URL Redirection

Redirect temp /news/ http://example.com/latest/news/

Page 12: Apache2 BootCamp : Using Apache to Serve Static Content

MIME Magic

mod_mime_magic

MimeMagicFile

Page 13: Apache2 BootCamp : Using Apache to Serve Static Content

The ForceType Directive

<Location /images/>ForceType image/gif</Location>

Page 15: Apache2 BootCamp : Using Apache to Serve Static Content

Directory Listings

DirectoryIndex index.html index.htm

mod_autoindex

Default Document Index

Directory Indexing

Page 16: Apache2 BootCamp : Using Apache to Serve Static Content

Forbidding Directory Access

● Disable the mod_autoindex● Use the Options-Indexes directive● Use IndexIgnore directive.

Page 18: Apache2 BootCamp : Using Apache to Serve Static Content

Icons for Bookmarks

AliasMatch /favicon.ico /usr/local/apache2/icons/site.ico

Icon

Page 20: Apache2 BootCamp : Using Apache to Serve Static Content

Reference

● Daniel Lopez Ridruezo; SAMS Teach Yourself Apache2 in 24 Hours, SAMS Publishing, 2002 (Buy this book on Amazon)