server: move rewrite/proxy to separate module
extract: fix exception in template extract