3

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?

2 Answers 2

3

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:

/home/$remote_user/.. 
0
2

You can't do this using nginx config file. You'd better use a php script connected to database for authentication and then use a redirect.

5
  • you have database table of user/pass which you connect to it for authentication using a php script. According to the username provided you decide where to redirect the user inside the php script. Commented Oct 6, 2013 at 6:12
  • At present i am using simple authentication so no any database i am using now, i simple created authentication file and refer its location in config file, Now how to do that and how to redirect? is there any online documentation which i can refer? Commented Oct 6, 2013 at 6:19
  • You cannot do redirection based on basic authentication you add to config file. This is why you have to use another method to do proper redirections. Without redirection you can simply continue with basic authentication though. Commented Oct 6, 2013 at 8:19
  • I mean that, Is there any online documentation or link where i can read about this redirection and all of stuff which you are referring? Commented Oct 6, 2013 at 8:34
  • Here is a documentation for php authentication: php.net/manual/en/features.http-auth.php Commented Oct 6, 2013 at 8:55

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.