如何使用带有身份validation的Nginx使用用户目录

我正在使用基于Debian的主机,并使用Nginx和PHP-FPM,我想在nginx中启用用户目录,并希望多用户支持基本身份validation。 这意味着当亚历克斯打开www.example.com/rutorrent; 这将提示login名和密码,并authentication后,这应该指向自己的版本的PHP脚本位于/ home / alex / www / rutorrent当鲍勃将打开www.example.com/rutorrent;这将提示login和密码和身份validation后,这应该指向他的PHP脚本位于/ home / bob / www / rutorrent。

我已经试过这里的官方文档: http : //wiki.nginx.org/UserDir

但我不知道如何configuration他们到默认文件,以便我可以得到我想要的function,我的默认configuration文件的nginx在这里:

server { server_name localhost; location / { try_files $uri $uri/ /index.html; } location /doc/ { alias /usr/share/doc/; autoindex on; allow 127.0.0.1; allow ::1; deny all; } index index.php index.html index.htm; location ~ ^/~([^/]*)(.*)\.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; auth_basic "Restricted"; auth_basic_user_file /etc/nginx/sites-available/.htpasswd; fastcgi_param SCRIPT_FILENAME /home/$1/www$2.php; include fastcgi_params; } location ~ ^/~([^/]*)(.*) { autoindex on; alias /home/$1/www$2; auth_basic "Restricted"; auth_basic_user_file /etc/nginx/sites-available/.htpasswd; } location /RPC2 { include scgi_params; scgi_pass localhost:5000; } } 

有没有办法得到这个?

感谢帮助我,我得到了解决用户目录问题的线索,我在主要的nginxconfiguration文件中使用了$ remote_uservariables,而在我们使用基本authentication的时候,Nginx在$ remote_uservariables中捕获了用户名,所以使用User Directories如果我们像这样包括:

 /home/$remote_user/.. 

你不能使用nginxconfiguration文件来做到这一点。 你最好使用连接到数据库的PHP脚本进行身份validation,然后使用redirect。