I am using Debian based host and using Nginx and PHP-FPM, I wants to enable user directories in nginx and wants multiuser support with basic authentication also. That means when Alex open www.example.com/rutorrent; That will prompt for login and password and after authentication, This should point to his own version of php script located at /home/alex/www/rutorrent and when Bob will open www.example.com/rutorrent;That will prompt for login and password and after authentication This should point to his php script located at /home/bob/www/rutorrent.
I already tried the official documentation located here:
http://wiki.nginx.org/UserDir
But i am not sure how configure them into default file so that i can get my desired functionality, My default config file of nginx is here:
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;
}
}
Is there any way to get this?
Best Answer
Thanks to help me, I got clue to fix User Directories issue, I am using $remote_user variable in main nginx config file, Nginx capture user name in $remote_user variable while we use basic authentication, So very nice and easy way to use User Directories if we include like in this way: