FAQ

Page Discussion Edit History

UserDir

(Redirected from NginxUserDir)

Nginx does not natively support user dirs, but as of 0.7.42 it can be done by using regex captures.

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

Reference: http://marc.info/?l=nginx&m=123706015914220&w=2

You may get 403 Forbidden when you just put the snippet above into your nginx configuration, because by default nginx does not allow autoindex. If you would like it to behave more likely to the default Apache userdir, add two lines as below:

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