Some more docs in README
Getty Ritter
7 years ago
2 | 2 | |
3 | 3 | **EARLY AND EXPERIMENTAL** |
4 | 4 | |
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 |
|
|
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. | |
8 | 8 | |
9 | 9 | ## Basic Use |
10 | 10 | |
45 | 45 | three possible forwarding modes: |
46 | 46 | - If the mode is `http`, then Melvil will forward the HTTP |
47 | 47 | request to the server listening on the host `host` and the |
48 |
|
|
48 | port `port`. | |
49 | 49 | - If the mode is `melvil`, then Melvil will recursively check |
50 |
|
|
50 | the configuration directory at `conf`. | |
51 | 51 | - 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. | |
54 | 58 | |
55 | 59 | ## 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. | |
56 | 94 | |
57 | 95 | Because configuration is specified as a directory, rather than as |
58 | 96 | a single file, we can use properties of the Unix file system as a |