From edd380241e9ba2b750eb9a1f82ffd6feeab6252f Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Mon, 7 Aug 2006 03:11:10 +0000 Subject: [PATCH] ServerAlias --- lib/apache.dtl | 3 +++ lib/apache_options.dtl | 3 +++ lib/domain.dtl | 3 +++ src/domain.sml | 15 +++++++++++++++ src/plugins/apache.sml | 18 +++++++++++++++++- tests/testApache.dtl | 6 +++++- 6 files changed, 46 insertions(+), 2 deletions(-) diff --git a/lib/apache.dtl b/lib/apache.dtl index 70edc96..9e70f74 100644 --- a/lib/apache.dtl +++ b/lib/apache.dtl @@ -25,3 +25,6 @@ extern val location : location -> ^Vhost & Location => [Vhost & !Location]; extern val directory : your_path -> ^Vhost & Location => [Vhost & !Location]; {{Set some configuration specific to a URI prefix or filesystem directory, respectively.}} + +extern val serverAlias : your_domain_host -> [Vhost]; +{{Give an alternate hostname for this vhost.}} diff --git a/lib/apache_options.dtl b/lib/apache_options.dtl index 072e3f8..c678d47 100644 --- a/lib/apache_options.dtl +++ b/lib/apache_options.dtl @@ -15,3 +15,6 @@ extern val set_options : [apache_option] -> [^Vhost]; extern val unset_options : [apache_option] -> [^Vhost]; {{Specify some options to be set or unset, leaving the rest as they are.}} +extern val directoryIndex : [no_spaces] -> [^Vhost]; +{{Give the list of filenames to try for the default page of a directory, to be + considered in the order given.}} diff --git a/lib/domain.dtl b/lib/domain.dtl index 0ab7716..34b6859 100644 --- a/lib/domain.dtl +++ b/lib/domain.dtl @@ -18,6 +18,9 @@ extern type domain; extern type your_domain; {{A domain that you're allowed to configure}} +extern type your_domain_host; +{{Some host (as a fully-qualified domain name) in one of your domains}} + extern type node; {{The name of a server controlled by domtool}} diff --git a/src/domain.sml b/src/domain.sml index 71d448d..224755f 100644 --- a/src/domain.sml +++ b/src/domain.sml @@ -71,6 +71,17 @@ fun yourPath path = orelse ch = #"-" orelse ch = #"_") path andalso SS.exists (fn s' => path = s' orelse String.isPrefix (s' ^ "/") path) (your_paths ()) +fun yourDomainHost s = + let + val (pref, suf) = Substring.splitl (fn ch => ch <> #".") (Substring.full s) + in + print ("pref[" ^ Substring.string pref ^ "] suf[" ^ Substring.string suf ^ "]\n"); + Substring.size suf > 0 + andalso validHost (Substring.string pref) + andalso yourDomain (Substring.string + (Substring.slice (suf, 1, NONE))) + end + val _ = Env.type_one "no_spaces" Env.string (CharVector.all (fn ch => not (Char.isSpace ch))) @@ -94,6 +105,10 @@ val _ = Env.type_one "your_domain" Env.string yourDomain +val _ = Env.type_one "your_domain_host" + Env.string + yourDomainHost + val _ = Env.type_one "your_user" Env.string yourUser diff --git a/src/plugins/apache.sml b/src/plugins/apache.sml index f497825..4887043 100644 --- a/src/plugins/apache.sml +++ b/src/plugins/apache.sml @@ -208,7 +208,9 @@ val () = Env.containerV_one "vhost" file end) nodes; - write "\tSuexecUserGroup "; + write "\tServerName "; + write fullHost; + write "\n\tSuexecUserGroup "; write user; write " "; write group; @@ -362,4 +364,18 @@ val () = Env.action_one "unset_options" app (fn opt => (write " -"; write opt)) opts; write "\n")) +val () = Env.action_one "directoryIndex" + ("filenames", Env.list Env.string) + (fn opts => + (write "\tDirectoryIndex"; + app (fn opt => (write " "; write opt)) opts; + write "\n")) + +val () = Env.action_one "serverAlias" + ("host", Env.string) + (fn host => + (write "\tServerAlias "; + write host; + write "\n")) + end diff --git a/tests/testApache.dtl b/tests/testApache.dtl index ff45dfa..9c28fcd 100644 --- a/tests/testApache.dtl +++ b/tests/testApache.dtl @@ -22,6 +22,8 @@ domain "hcoop.net" with end; vhost "proxy" with + serverAlias "proxy2.hcoop.net"; + proxyPass "/proxyLand" "http://localhost:1234/otherProxyLand"; proxyPassReverse "/proxyLand" "http://localhost:1234/otherProxyLand"; @@ -39,6 +41,8 @@ domain "hcoop.net" with vhost "lists" with proxyPass "/mailman" "http://hcoop.net/cgi-bin/mailman"; - alias "/doc/mailman" "/home/adamc/mailman" + alias "/doc/mailman" "/home/adamc/mailman"; + + directoryIndex ["index.sml", "index.h", "index.v"] end end -- 2.20.1