val _ = Env.type_one "proxy_port"
Env.int
- (fn n => n >= 1024)
+ (fn n => n > 1024)
+
+val _ = Env.type_one "proxy_target"
+ Env.string
+ (fn s =>
+ let
+ fun default () = List.exists (fn s' => s = s') Config.Apache.proxyTargets
+ in
+ case String.fields (fn ch => ch = #":") s of
+ ["http", "//localhost", rest] =>
+ (case String.fields (fn ch => ch = #"/") rest of
+ port :: _ =>
+ (case Int.fromString port of
+ NONE => default ()
+ | SOME n => n > 1024 orelse default ())
+ | _ => default ())
+ | _ => default ()
+ end)
val _ = Env.type_one "rewrite_arg"
Env.string
(CharVector.all Char.isAlphaNum)
+fun validLocation s =
+ size s > 0 andalso size s < 1000 andalso CharVector.all
+ (fn ch => Char.isAlphaNum ch
+ orelse ch = #"-"
+ orelse ch = #"_"
+ orelse ch = #"."
+ orelse ch = #"/") s
+
+val _ = Env.type_one "location"
+ Env.string
+ validLocation
+
val dl = ErrorMsg.dummyLoc
val _ = Main.registerDefault ("WebNodes",
| _ => NONE
+val cond_flag = fn (EVar "cond_nocase", _) => SOME "NC"
+ | (EVar "ornext", _) => SOME "OR"
+ | _ => NONE
+
val vhostsChanged = ref false
fn () => (write "</VirtualHost>\n";
app TextIO.closeOut (!vhostFiles)))
+val () = Env.container_one "location"
+ ("prefix", Env.string)
+ (fn prefix =>
+ (write "\t<Location ";
+ write prefix;
+ write ">\n"),
+ fn () => write "\t</Location>\n")
+
+val () = Env.container_one "directory"
+ ("directory", Env.string)
+ (fn directory =>
+ (write "\t<Directory ";
+ write directory;
+ write ">\n"),
+ fn () => write "\t</Directory>\n")
+
fun checkRewrite () =
if !rewriteEnabled then
()
write to;
write " [P]\n"))
-val () = Env.action_three "localProxyPass"
- ("from", Env.string, "to", Env.string, "port", Env.int)
- (fn (from, to, port) =>
- let
- val to =
- case to of
- "" => "/"
- | _ => if String.sub (to, 0) = #"/" then
- to
- else
- "/" ^ to
- in
- write "\tProxyPass\t";
- write from;
- write "\thttp://localhost:";
- write (Int.toString port);
- write to;
- write "\n"
- end)
-
-val () = Env.action_three "localProxyPassReverse"
- ("from", Env.string, "to", Env.string, "port", Env.int)
- (fn (from, to, port) =>
- let
- val to =
- case to of
- "" => "/"
- | _ => if String.sub (to, 0) = #"/" then
- to
- else
- "/" ^ to
- in
- write "\tProxyPassReverse\t";
- write from;
- write "\thttp://localhost:";
- write (Int.toString port);
- write to;
- write "\n"
- end)
+val () = Env.action_two "proxyPass"
+ ("from", Env.string, "to", Env.string)
+ (fn (from, to) =>
+ (write "\tProxyPass\t";
+ write from;
+ write "\t";
+ write to;
+ write "\n"))
+
+val () = Env.action_two "proxyPassReverse"
+ ("from", Env.string, "to", Env.string)
+ (fn (from, to) =>
+ (write "\tProxyPassReverse\t";
+ write from;
+ write "\t";
+ write to;
+ write "\n"))
val () = Env.action_three "rewriteRule"
("from", Env.string, "to", Env.string, "flags", Env.list flag)
write "]");
write "\n"))
+val () = Env.action_three "rewriteCond"
+ ("test", Env.string, "pattern", Env.string, "flags", Env.list cond_flag)
+ (fn (from, to, flags) =>
+ (checkRewrite ();
+ write "\tRewriteCond\t";
+ write from;
+ write "\t";
+ write to;
+ case flags of
+ [] => ()
+ | flag::rest => (write " [";
+ write flag;
+ app (fn flag => (write ",";
+ write flag)) rest;
+ write "]");
+ write "\n"))
+
end