-1

At the moment I have a directory containing various web-facing products, such as a Drupal site, a wiki, etc, something like this.

/srv/www

/srv/www/blog

/srv/www/wiki

/srv/www/sometestphpapp

At the moment, I've got one apache2 virtualhost config in /sites-available that simply sets ServerName to the domain mydomain.com sets the docroot to /srv/www and sets basic auth. If I want to bring up or demonstrate something I'm working on, I direct people to the site, and they just navigate the apache-provided directory structure.

What I'd like to do, I think, is have a setup where I can control which of the subdirectories in /srv/www are available to people, by mapping them to a URL path with its own basic auth. So for instance, /srv/www/blog would be available at mydomain.com/blog

Do I need a seperate config for each folder I want to serve up, and more importantly, what does the directive look like to map mydomain.com/blog to the /srv/www/blog, and say, mydomain.com/wiki to /srv/www/wiki?

1

1 Answer 1

1

For development/demos, I find it better to set up separate sites in Apache with a wildcard DNS entry like *.mydevcompany.com resolving to my staging Web server's public IP.

This accomplishes several things:

  • Some web apps don't like to be in a sub-directory
  • Improves security isolation between apps (i.e. a directory traversal vulnerability in one app could compromise another)
  • easier to setup backups and keep client data separate
  • easier to configure SSL and non-SSL sites without conflicting

With the wildcard DNS, you just have to create your site configuration in Apache and the wildcard DNS does all the work:

ServerName someclient.mydevcompany.com
ServerAlias someclient.mydevcompany.com
DocumentRoot /srv/www/someclient.mydevcompany.com

Note: I also like to create separate config files in sites-available, one for each site, to keep it organized.

Not the answer you're looking for? Browse other questions tagged .