Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like to add a condition in an adduser script to update nginx.conf for it to load ~/www as http://ipaddress/~user whenever I create a new user.

And when a user is named www.domainname it will host that domain name in the ~/www folder.

Is there a script that already does this?

share|improve this question
    
No, there isn't. –  mailq Sep 17 '11 at 12:53

1 Answer 1

up vote 5 down vote accepted

You don't need to add anything to nginx upon user creation. Simply use something like this in your server block:

location ~ ^/~(.+?)(/.*)?$ {
    alias /home/$1/www$2;
    autoindex on;
}

Check your distributions /etc/skel

if you mkdir /etc/skel/www all userdirs created by adduser (or your distributions adduser-script) will have this directory by default.

share|improve this answer
    
wow that's awesome –  Joseph Le Brech Oct 10 '11 at 11:37
    
now what if i want the users to override this once then have pointed their dns to that server? –  Joseph Le Brech Oct 10 '11 at 11:42
    
I dont understand the question/issue :/ –  Franz Bettag Oct 16 '11 at 10:22
    
if a user has a site hosted on ~username is there a way for the user to change it to domainname –  Joseph Le Brech Oct 17 '11 at 7:26
1  
that actually rocks :) –  Joseph Le Brech Oct 18 '11 at 13:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.