URL-Rewriting not working
Francis Daly
francis at daoine.org
Sun Apr 9 15:17:21 UTC 2017
On Sun, Apr 09, 2017 at 06:36:51PM +0530, Ajay Garg wrote:
Hi there,
> Got it Francis !!
Good news.
> location / {
> auth_basic 'Restricted';
> auth_basic_user_file
> /home/20da689b45c84f2b80bc84d651ed573f/.htpasswd;
>
> if ($remote_user =
> "20da689b45c84f2b80bc84d651ed573f") {
> proxy_pass
> https://127.0.0.1:2000;
> }
>
> }
When you come to add the second user, you will see that you want one
file with all the user/pass details.
You will probably also see that it will be good to use a map
(http://nginx.org/r/map) to set a variable for the port to connect to,
based on $remote_user. Then your main config becomes just "proxy_pass
http://127.0.0.1:$per_user_port;".
Note that I have not tested that, and expect that there may be some more
subtleties involved, such as perhaps requiring an explicit proxy_redirect
directive.
Note also that you will probably want to set a default value for
$per_user_port, and make sure that something sensible happens when that
value is used -- probably a response along the lines of "something isn't
fully set up on the server yet; please wait or let us know", so the user
is not confused.
Good luck with it,
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list