Domain aliases support for Apache
authorAdam Chlipala <adamc@hcoop.net>
Sun, 29 Apr 2007 20:33:12 +0000 (20:33 +0000)
committerAdam Chlipala <adamc@hcoop.net>
Sun, 29 Apr 2007 20:33:12 +0000 (20:33 +0000)
lib/apache.dtl
src/plugins/apache.sml

index 93fb3a3..db30398 100644 (file)
@@ -44,5 +44,11 @@ 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];
+extern val serverAliasHost : your_domain_host -> [Vhost];
 {{Give an alternate hostname for this vhost.}}
+extern val serverAlias : host -> [Vhost];
+{{Like serverAliasHost, but adds an alias for the given hostname at every domain
+  being configured.}}
+extern val serverAliasDefault : [Vhost];
+{{Like serverAliasDefault, but adds aliases for the domains being configured
+  instead of any of their hosts/"subdomains".}}
index 48c7f6f..7e3deb5 100644 (file)
@@ -423,6 +423,12 @@ val () = Env.containerV_one "vhost"
                                           TextIO.output (file, "/access.log combined\n");
                                           TextIO.output (file, "\tServerName ");
                                           TextIO.output (file, fullHost);
+                                          app
+                                              (fn dom => (TextIO.output (file, "\n\tServerAlias ");
+                                                          TextIO.output (file, host);
+                                                          TextIO.output (file, ".");
+                                                          TextIO.output (file, dom)))
+                                              (Domain.currentAliasDomains ());
                                           if suexec then
                                               if isVersion1 node then
                                                   (TextIO.output (file, "\n\tUser ");
@@ -634,7 +640,7 @@ val () = Env.action_one "directoryIndex"
              app (fn opt => (write " "; write opt)) opts;
              write "\n"))
 
-val () = Env.action_one "serverAlias"
+val () = Env.action_one "serverAliasHost"
         ("host", Env.string)
         (fn host =>
             (write "\tServerAlias ";
@@ -642,6 +648,31 @@ val () = Env.action_one "serverAlias"
              write "\n";
              !aliaser host))
 
+val () = Env.action_one "serverAlias"
+        ("host", Env.string)
+        (fn host =>
+            (app
+                 (fn dom =>
+                     let
+                         val full = host ^ "." ^ dom
+                     in
+                         write "\tServerAlias ";
+                         write full;
+                         write "\n";
+                         !aliaser full
+                     end)
+                 (Domain.currentDomains ())))
+
+val () = Env.action_none "serverAliasDefault"
+        (fn () =>
+            (app
+                 (fn dom =>
+                         (write "\tServerAlias ";
+                          write dom;
+                          write "\n";
+                          !aliaser dom))
+                 (Domain.currentDomains ())))
+
 val authType = fn (EVar "basic", _) => SOME "basic"
                | (EVar "digest", _) => SOME "digest"
                | _ => NONE