--- /dev/null
+This directory contains some examples of more or less simple ashd
+configurations. Each sub-directory contains a self-contained example
+with a shell script called `run'. Simply run that script to start the
+example, and examine it to see how it was made. All of them will start
+an non-SSL HTTP server on port 8080.
+
+Note that ashd must be installed on the system to be able to run the
+examples, including the default configuration files.
+
+The `python' sub-directory contains examples for using the Python
+module. To run then, the Python module has to be installed and
+accessible as well.
--- /dev/null
+You're accessing via IP address.
--- /dev/null
+This example uses Python to dynamically dispatch requests for
+different vhosts. The Python program dynhosts will look in a directory
+for subdirectories named after the virtual host and start a dirplex
+instance for each such host that is requested.
+
+To try this example, run it on your local machine and request
+<http://localhost:8080/> or <http://127.0.0.1:8080/>.
--- /dev/null
+#!/usr/bin/python
+
+import os, sys, signal
+from ashd import util
+
+children = {}
+root = sys.argv[1]
+signal.signal(signal.SIGCHLD, signal.SIG_IGN)
+
+def serve(req):
+ if "Host" in req:
+ # Strip port specification
+ dname = req["Host"].split(':')[0]
+ dname = dname.lower()
+ path = os.path.join(root, dname)
+ if os.path.isdir(path):
+ if dname not in children:
+ children[dname] = util.pchild(["dirplex", path], autorespawn = True)
+ children[dname].passreq(req)
+ return
+ util.respond(req, "No such host in configured.\n", status = "404 Not Found", ctype = "text/plain")
+
+util.serveloop(serve)
--- /dev/null
+You're accessing via hostname.
--- /dev/null
+#!/bin/sh
+
+set -e
+cd "$(dirname "$0")"
+
+htparser plain:port=8080 -- setsid ./dynhosts .
--- /dev/null
+To view this example, simply run it on your local machine and point
+your web browser at <http://localhost:8080/>.
--- /dev/null
+<?xml version="1.0" encoding="US-ASCII"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
+<head>
+<title>Test page</title>
+<link rel="stylesheet" title="Default style" type="text/css" href="test.css" />
+</head>
+<body>
+<h1>Test page</h1>
+<p>
+Note how this page is accessible as
+<a href="/"><code>/</code></a>,
+<a href="/index"><code>/index</code></a> and
+<a href="/index.html"><code>/index.html</code></a>.
+</p>
+</body>
+</html>
--- /dev/null
+#!/bin/sh
+
+set -e
+cd "$(dirname "$0")"
+
+htparser plain:port=8080 -- dirplex .
--- /dev/null
+body {
+ font-family: sans-serif;
+}
+
+h1 {
+ font-size: 1.75em;
+}
+
+p {
+ font-size: 1em;
+}
--- /dev/null
+To view this example, simply run it on your local machine and point
+your web browser at <http://localhost:8080/>.
--- /dev/null
+<?xml version="1.0" encoding="US-ASCII"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
+<head>
+<title>Default site</title>
+<link rel="stylesheet" title="Default style" type="text/css" href="test.css" />
+</head>
+<body>
+<h1>Default site</h1>
+<p>
+This site is called when the requested Host is not exactly
+<code>localhost</code>, such as 127.0.0.1.
+</p><p>
+Try visiting
+<a href="http://localhost:8080/"><code>localhost</code></a>
+instead (and make sure the server is running on your local machine).
+</p>
+</body>
+</html>
--- /dev/null
+body {
+ font-family: sans-serif;
+}
+
+h1 {
+ font-size: 1.75em;
+}
+
+p {
+ font-size: 1em;
+}
--- /dev/null
+<?xml version="1.0" encoding="US-ASCII"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
+<head>
+<title>localhost site</title>
+<link rel="stylesheet" title="Default style" type="text/css" href="test.css" />
+</head>
+<body>
+<h1><code>localhost</code> site</h1>
+<p>
+This site is called when the requested Host is
+exactly <code>localhost</code> (plus any port specification).
+</p><p>
+Try requesting the server via a different hostname, such as
+<a href="http://127.0.0.1:8080/"><code>127.0.0.1</code></a>,
+instead.
+</p>
+</body>
+</html>
--- /dev/null
+body {
+ font-family: sans-serif;
+}
+
+h1 {
+ font-size: 1.75em;
+}
+
+p {
+ font-size: 1em;
+}
--- /dev/null
+child default
+ exec dirplex default-site
+
+child localhost
+ exec dirplex localhost
+
+match
+ default
+ handler default
+
+match
+ header host localhost(:[0-9]+)?$ i
+ handler localhost
--- /dev/null
+#!/bin/sh
+
+set -e
+cd "$(dirname "$0")"
+
+htparser plain:port=8080 -- patplex patterns.conf