gdritter repos melvil / master
Some more docs in README Getty Ritter 3 years ago
1 changed file(s) with 45 addition(s) and 7 deletion(s). Collapse all Expand all
22
33 **EARLY AND EXPERIMENTAL**
44
5 Melvil is the HTTP server interface I want to use. It's very
6 slow at present, and still quite early, but it's at least a
7 proof-of-concept of something I think should exist.
5 Melvil is the HTTP server interface I think I'd want to use.
6 It's very slow at present, and still quite early, but it's at
7 least a proof-of-concept of something I think should exist.
88
99 ## Basic Use
1010
4545 three possible forwarding modes:
4646 - If the mode is `http`, then Melvil will forward the HTTP
4747 request to the server listening on the host `host` and the
48 port `port`.
48 port `port`.
4949 - If the mode is `melvil`, then Melvil will recursively check
50 the configuration directory at `conf`.
50 the configuration directory at `conf`.
5151 - If the mode is `redir`, then Melvil will respond with an
52 HTTP response code as indicated in `resp` and redirect to
53 the host as indicated in `host`.
52 HTTP response code as indicated in `resp` and redirect to
53 the host as indicated in `host`.
54
55 In the future, there might be more modes, such as a `fastcgi` mode
56 which points to a Unix socket or a `static` mode which serves
57 static files, but this is enough to test the idea.
5458
5559 ## Example Setups
60
61 A simple-but-interesting configuration, which forwards requests
62 for `example.com` to `localhost:5001`, redirects `www.example.com` to
63 `example.com`, forwards requests for `blog.example.com` to
64 `example.tumblr.com`, and redirects everything else to `localhost:5000`.
65
66 ~~~
67 $ # create the example.com config, which forwards to a
68 $ # local HTTP server listening on port 5001
69 $ mkdir 00-base
70 $ echo example.com >00-base/domain
71 $ echo 5001 >00-base/port
72 $
73 $ # redirect www.example.com to example.com
74 $ mkdir 00-www
75 $ echo www.example.com >00-www/domain
76 $ echo redir >00-www/mode
77 $ echo example.com >00-www/host
78 $
79 $ # create the configuration for the blog subdomain
80 $ mkdir 00-blog
81 $ echo blog.example.com >00-blog/domain
82 $ echo example.tumblr.com >00-blog/host
83 $
84 $ # and now create the fallthrough case
85 $ mkdir 99-default
86 $ echo mode >99-default
87 $ echo 5000 >99-default/port
88 ~~~
89
90 Notice that we only need to specify a few pieces of information for
91 each case, because we can often use the defaults for various fields,
92 so each "configuration" is usually a directory with two or maybe
93 three files.
5694
5795 Because configuration is specified as a directory, rather than as
5896 a single file, we can use properties of the Unix file system as a