Day #2 Using Apache to Serve Static Content Wildan Maulana [email protected] http://workshop.openthinklabs.com #5
Jul 19, 2015
Day #2Using Apache to Serve Static Content
Wildan [email protected]
http://workshop.openthinklabs.com
#5
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
Addresses, Ports, and Server Names
Listen ipaddress:port
ServerName UseCanonicalName
Customizing the Web Server
● Error Messages● International Error Messages● Handling URL Errors: mod_speling
● Customizing Server Information● Server Identification● Contact Information
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"
Customizing the Web ServerInternational Error Messages
Server Side Includes (mod_include) and content negotiation (mod_negotiation).
Custom Error Codes
Customizing the Web ServerHandling URL Errors: mod_speling
CheckSpelling
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]
Aliasing and Mapping of Resources
Alias /icons/ /usr/local/apache2/icons/
AliasMatch ^/help(.*) /usr/local/apache/htdocs/manual$1
URL Redirection
Redirect temp /news/ http://example.com/latest/news/
MIME Types
● Directives :● TypesConfig● AddType
– AddType text/xml xml● DefaultType
● MIME Type List
MIME Magic
mod_mime_magic
MimeMagicFile
The ForceType Directive
<Location /images/>ForceType image/gif</Location>
Content Handlers
AddHandler
RemoveHandler SetHandler
Directory Listings
DirectoryIndex index.html index.htm
mod_autoindex
Default Document Index
Directory Indexing
Forbidding Directory Access
● Disable the mod_autoindex● Use the Options-Indexes directive● Use IndexIgnore directive.
Icons for Bookmarks
AliasMatch /favicon.ico /usr/local/apache2/icons/site.ico
Icon
Q&Ahttp://workshop.openthinklabs.com/resources
Reference
● Daniel Lopez Ridruezo; SAMS Teach Yourself Apache2 in 24 Hours, SAMS Publishing, 2002 (Buy this book on Amazon)