Toadhttpd

Update of "Configuration"
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview

Artifact ID: f1129e8fe6e7be40c587801915ce25503b50e207946185df4623504c642476a3
Page Name:Configuration
Date: 2018-05-03 21:42:34
Original User: hypnotoad
Parent: af78a1b6446d2dc82813ee0f419ae2f21b423e1570eaa6f3d383a11bfacef36a
Content

Deploying | Configuration | Customizing

Configuring Toadhttpd

Toadhttpd will accept all of the same command line options as the httpd example from tcllib.

In addition it provides the following default behaviors:

configuration_file (config.tcl)

The configuration_file is source by the new httpd::server instance prior to invoking the start method. Because it is sourced by the object itself, you can exercise all of the object's methods via the my mechanism.

etoyoc.com is probably as complicated a setup as one will encounter in the wild. It serves a number of top level domains, mixes static content and dynamic content, and even plays dispatcher to scgi based fossil repositories. On the page Etoyoc.com we will explore, in depth, how Sean configured etoyoc.com and how you can do the same to create your own site. For now here is a simple setup to give you a sense of what is in the file:

# Set a configuration parameter for the server
my config set doc_ttl 900

# Load a plugin
package require toadhttpd::sqlite
package require toadhttpd::bouncer
package require toadhttpd::fossil

##
# Inject a plugin behavior into the server object
##
my plugin bouncer
my plugin sqlite

###
# Specify how URLs are responded to
###
# Someone asking for /ccvv is up to no good, send them to the honeypot
my uri add % /ccvv {
  mixin toadhttpd::content.honeypot
}

###
# If someone asks for http://fossil.etoyoc.com/index* send them to the 
# proper URL
# NOTE: This rule only applies if the server requested was fossil.etoyoc.com
###
my uri add fossil.etoyoc.com {/fossil/ /fossil/index%} {
   mixinmap {reply httpd::content.redirect}
  LOCATION http://fossil.etoyoc.com/fossil
}
# The page /fossil is a dynamic page with a list of fossil repos
my uri add fossil.etoyoc.com /fossil {
   mixinmap {reply toadhttpd::content.fossil_root}
   fossil_root /opt/fossil
   prefix fossil
 }
# Everything under that page is dispatched out to fossil SCGI
# proxies
my uri add fossil.etoyoc.com /fossil/% {
    mixinmap {reply toadhttpd::content.fossil_node_scgi}
    prefix fossil
    fossil_root /opt/fossil
 }

# The "trivial" plugin provides a cute little
# database or random facts. Accept requests at either
# /trivia or /fortune
my uri add % {/trivia /fortune} {
  mixinmap {
    reply ::etoyoc::content.trivia
    style ::etoyoc::style
  }
}
# Add /trivia to the list of places we don't like 
# robots visiting
my robots.txt add /trivia

###
# Note that any URL that hasn't matched one of the rules
# above will be handled by the default hander: find the file
# under doc_root, or fail with 404
###