<div dir="ltr">Hi Francis.<br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Apr 9, 2017 at 8:47 PM, Francis Daly <span dir="ltr"><<a href="mailto:francis@daoine.org" target="_blank">francis@daoine.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span>On Sun, Apr 09, 2017 at 06:36:51PM +0530, Ajay Garg wrote:<br>
<br>
Hi there,<br>
<br>
</span>> Got it Francis !!<br>
<br>
Good news.<br>
<span><br>
> location / {<br>
> auth_basic 'Restricted';<br>
> auth_basic_user_file<br>
> /home/20da689b45c84f2b80bc84d6<wbr>51ed573f/.htpasswd;<br>
><br>
> if ($remote_user =<br>
> "20da689b45c84f2b80bc84d651ed5<wbr>73f") {<br>
> proxy_pass<br>
> <a href="https://127.0.0.1:2000" rel="noreferrer" target="_blank">https://127.0.0.1:2000</a>;<br>
> }<br>
><br>
> }<br>
<br>
</span>When you come to add the second user, you will see that you want one<br>
file with all the user/pass details.<br></blockquote><div> </div><div><br></div><div>Yes, I have already changed it to use just one file.<br></div><div>Upon that, would not just multiple sections of "if" checks for $remote_user suffice, something like ::<br><br>#########################################################################<br>server {<br> listen 2000 ssl;<br><br> ssl_certificate /etc/nginx/ssl/nginx.crt;<br> ssl_certificate_key /etc/nginx/ssl/nginx.key;<br><br> location / {<br> <wbr> auth_basic 'Restricted';<br> <wbr> auth_basic_user_file /etc/nginx/ssl/.htpasswd;<br><br> <wbr> if ($remote_user = "user1") {<br> <wbr> proxy_pass <a href="https://127.0.0.1:2000" target="_blank">https://127.0.0.1:2001</a>;<br> <wbr> }<br><br> if ($remote_user = "user2") {<br> <wbr> proxy_pass <a href="https://127.0.0.1:2000" target="_blank">https://127.0.0.1:2002</a>;<br> <wbr> }<br><br> <wbr> # and so on ....<br><br> }<br> }<br>#########################################################################<br><br></div><div>Looking forward to hearing back from you.<br><br><br></div><div>Thanks and Regards,<br></div><div>Ajay<br></div><div><br></div><div><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
You will probably also see that it will be good to use a map<br>
(<a href="http://nginx.org/r/map" rel="noreferrer" target="_blank">http://nginx.org/r/map</a>) to set a variable for the port to connect to,<br>
based on $remote_user. Then your main config becomes just "proxy_pass<br>
http://127.0.0.1:$per_user_por<wbr>t;".<br>
<br>
Note that I have not tested that, and expect that there may be some more<br>
subtleties involved, such as perhaps requiring an explicit proxy_redirect<br>
directive.<br>
<br>
Note also that you will probably want to set a default value for<br>
$per_user_port, and make sure that something sensible happens when that<br>
value is used -- probably a response along the lines of "something isn't<br>
fully set up on the server yet; please wait or let us know", so the user<br>
is not confused.<br>
<div class="gmail-m_4983239477093541800HOEnZb"><div class="gmail-m_4983239477093541800h5"><br>
Good luck with it,<br>
<br>
f<br>
--<br>
Francis Daly <a href="mailto:francis@daoine.org" target="_blank">francis@daoine.org</a><br>
______________________________<wbr>_________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailm<wbr>an/listinfo/nginx</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail-m_4983239477093541800gmail_signature">Regards,<br>Ajay<br></div>
</div></div>