2

Our company has created simple CMS app, which it is planning to sell to thousands of small companies. Right now, our CMS app spits out the html files to a pre-configured directory in a directory structure like:

root:
    /foo.com
    /bar.com
    /.......

Managing these websites using the virtual hosts is not practical, Right now, we are using a simple rack module which finds the right files based on the HTTP_HOST and returns the appropriate html by reading the file from the hard-drive. This is obviously not an optimal solution.

What would you guys do to solve this?

1 Answers1

6

you could generate small configuration file for each directory(virtual host) you have if you need to handle those differently or if you want to save effort use the following:

server {
  server_name   ~^(www\.)?(?<domain>.+)$;
  location / {
    root  /sites/$domain;
  }
}

This maps the request domain to a directory.

Istvan
  • 2,562
  • 3
  • 20
  • 28