As mentioned in the nginx wiki webiste, Nginx does not natively support user dirs, but as of 0.7.42 it can be done by using regex captures. i’ve tested it using this simple configuration.

server {
                listen       192.168.200.18:80;
                server_name  _;
                access_log  /var/log/nginx/nginx-userdirs-access.log  main;

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

explaination:

location ~ ^/~(.+?)(/.*)?$ {

-

~		= tilde
(.+?)	= homedir
(/.*)	= request file / rest of uri

-

alias /home/$1/public_html$2;

-

$1	= variable subtitution for homedir
$2	= variable subtitution for requested file or uri

The requested url would be like this:


http://www.example.com/~user/test.html
Share

You may also want to read these posts:

 Leave a Reply

(required)

(required)


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

   
GeoIP
© 2011 KutuKupret Suffusion theme by Sayontan Sinha