On Sun, 25 Sep 2016 11:39:34 GMT, Sönke Ludwig wrote:

On Thu, 22 Sep 2016 17:41:26 GMT, Uiy Uiy wrote:

I am having some trouble with the virtual hosts but I think I just have to play around with it.

What I really would like to do is be able to create n independent websites(each one is restricted to it's own "space") and serve them off the same ip but also allow for common functionality to be served between them, such as common templates, etc.

e.g.,

public
source
views
data
images
css
Site1.com
   public
   source
   views
   data
   images
   css
Site2.com
   public
   source
   views
   data
   images
   css
...

Then when Site1.com is accessed, all the files are served from it's subdirectory. It would be nice if some common templates, icons, etc can be stored in the root to be used by all the sites but otherwise secure(no way for someone to access site2's files from site1.

I see no way to set a path for each server or really accomplish this effectively with one vibe.d process. Any ideas?

You can call serveStaticFiles multiple times, as needed:

{ // setup host 1
  auto settings = new HTTPServerSettings;
  settings.hostName = "foo.example.org";

  auto router = new URLRouter;
  router.serveStaticFiles("/public");
  router.serveStaticFiles("/site1/public");

  listenHTTP(settings, router);
}

{ // setup host 2
  auto settings = new HTTPServerSettings;
  settings.hostName = "bar.example.org";

  auto router = new URLRouter;
  router.serveStaticFiles("/public");
  router.serveStaticFiles("/site2/public");

  listenHTTP(settings, router);
}

The two virtual hosts are logically completely distinct, except that both serve the "public" folder of the root directory.

But how do we keep the views isolated and such. It doesn't seem to keep the two sites distinct. You are simply adding two different directories to serve from(BTW, what is the precedence order?).

If I have 10 sites, say, and ones view directory, then things can get very hairy quickly. I have to keep everything named properly.

It would be nice to have a

settings.rootDir which sets the root dir for the site.

That is, unless setting hostName sets the rootDir?

Or is there something I'm missing?

My goal is to really have n distinct sites with each it's own distinct root directory. The common folder is not as important... I can just copy files between them if necessary. I was just trying to avoid duplicating a bunch of files between the sites but then I forgot about views and dt files.