I am planning to offer some free hosting for ruby development. At the moment I have to manually edit nginx to add sub domains when a user is create to point to his directory /home/$user/www/public
so for user yoda I have something like this
server {
listen 80;
server_name yoda.jedi.am;
root /home/yoda/www/public;
passenger_enabled on;
}
Now suppose I add user obione is there anyway to set nginx to automatically server user.jedi.am with root /home/user/www/public and if that is not available to redirect to the main root ?
Thanks
Try something more like:
server {
listen 80;
server_name ~^(.*)\.jedi\.am$
if ($hostname ~ ^(.*)\.jedi\.am$) {
set $user $1;
}
if ( ! -d /home/$user/www/public ) {
rewrite . http://jedi.am/ redirect;
}
root /home/$user/www/public;
passenger_enabled on;
}
Untested, but this or something like it should work.