From e519d69680e425dc1d44db474dd5d9e7ea1cf379 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sun, 29 Apr 2007 20:33:12 +0000 Subject: [PATCH] Domain aliases support for Apache --- lib/apache.dtl | 8 +++++++- src/plugins/apache.sml | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/lib/apache.dtl b/lib/apache.dtl index 93fb3a3..db30398 100644 --- a/lib/apache.dtl +++ b/lib/apache.dtl @@ -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".}} diff --git a/src/plugins/apache.sml b/src/plugins/apache.sml index 48c7f6f..7e3deb5 100644 --- a/src/plugins/apache.sml +++ b/src/plugins/apache.sml @@ -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 -- 2.20.1