<div dir="ltr">Since this requires more logic, I think you can implement this in an application server / server-side scripting  like php/python etc<div><br></div><div>your application must verify the IP address and list files rather than web server </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 18, 2018 at 6:25 PM, Sathish Kumar <span dir="ltr"><<a href="mailto:satcse88@gmail.com" target="_blank">satcse88@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>Hi,</div><div dir="auto"><br><div dir="auto">I tried this option but it says autoindex need to be on or off and it's not accepting a variable.</div><div dir="auto"><br></div><div dir="auto"><br></div>[emerg] invalid value "$allowed" in "autoindex" directive, it must be "on" or "off" in domain.conf<div><div class="h5"><br><br><div class="gmail_quote" dir="auto"><div dir="ltr">On Fri, May 18, 2018, 7:18 PM Friscia, Michael <<a href="mailto:michael.friscia@yale.edu" target="_blank">michael.friscia@yale.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="blue" vlink="purple">
<div class="m_-4914925538238463374m_-1878159203279836585WordSection1">
<p class="MsoNormal">I think you need to change this a little<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">map $remote_addr $allowed {<br>
    default         “off”;<br>
    1.1.1.1         “on”;<br>
    2.2.2.2         “on:;<br>
}<u></u><u></u></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">and then in in the download location block<br>
<br>
 autoindex $allowed;<u></u><u></u></p>
<p class="MsoNormal">I use similar logic on different variables and try at all costs to avoid IF statements anywhere in the configs.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;color:#44546a">______________________________<wbr>_____________<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;color:#44546a">Michael Friscia<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;color:#44546a">Office of Communications<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;color:#44546a">Yale School of Medicine<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;color:#44546a">(203) 737-7932 - office<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;color:#44546a">(203) 931-5381 - mobile<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;color:#44546a"><a href="http://web.yale.edu/" rel="noreferrer" target="_blank"><span style="color:#44546a">http://web.yale.edu</span></a><u></u><u></u></span></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:12.0pt;color:black">From: </span></b><span style="font-size:12.0pt;color:black">nginx <<a href="mailto:nginx-bounces@nginx.org" rel="noreferrer" target="_blank">nginx-bounces@nginx.org</a>> on behalf of PRAJITH <<a href="mailto:prajithpalakkuda@gmail.com" rel="noreferrer" target="_blank">prajithpalakkuda@gmail.com</a>><br>
<b>Reply-To: </b>"<a href="mailto:nginx@nginx.org" rel="noreferrer" target="_blank">nginx@nginx.org</a>" <<a href="mailto:nginx@nginx.org" rel="noreferrer" target="_blank">nginx@nginx.org</a>><br>
<b>Date: </b>Friday, May 18, 2018 at 2:16 AM<br>
<b>To: </b>"<a href="mailto:nginx@nginx.org" rel="noreferrer" target="_blank">nginx@nginx.org</a>" <<a href="mailto:nginx@nginx.org" rel="noreferrer" target="_blank">nginx@nginx.org</a>><br>
<b>Subject: </b>Re: Nginx Directory Listing - Restrict by IP Address<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><a name="m_-4914925538238463374_m_-1878159203279836585__MailOriginalBody" rel="noreferrer">Hi Satish,<u></u><u></u></a></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span>There are "if" constructs in nginx, please check
</span><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__nginx.org_r_if&d=DwMFaQ&c=cjytLXgP8ixuoHflwc-poQ&r=wvXEDjvtDPcv7AlldT5UvDx32KXBEM6um_lS023SJrs&m=fKmL-eoW-L4wbuOH4Cy1Z_3ZWkTmrmgNPGNe6O6FIV4&s=_hMwYrlV1QXfU7fEvfqx9BnEUgUoadjGtTqav5fo_7M&e=" rel="noreferrer" target="_blank"><span>http://nginx.org/r/if</span><span></span></a><span>.
 if you want to allow multiple IP addresses, it might be better idea to use map. eg:<br>
<br>
map $remote_addr $allowed {<br>
    default         0;<br>
    1.1.1.1         1;<br>
    2.2.2.2         1;<br>
}<u></u><u></u></span></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span>and then in in the download location block<br>
<br>
 if ($allowed = 1) {<br>
        autoindex on;<br>
}<u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span>Thanks,<u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span>Prajith<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<div>
<p class="MsoNormal"><span>On 18 May 2018 at 05:35, Sathish Kumar <</span><a href="mailto:satcse88@gmail.com" rel="noreferrer" target="_blank"><span>satcse88@gmail.com</span><span></span></a><span>>
 wrote:<u></u><u></u></span></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<p style="margin-right:0in;margin-bottom:12.0pt;margin-left:0in;background:white;vertical-align:baseline;font-variant-ligatures:normal;font-variant-caps:normal;text-decoration-style:initial;text-decoration-color:initial;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;box-sizing:inherit;word-spacing:0px">
<span><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729">Hi Team,<u></u><u></u></span></span></p>
<p style="margin-right:0in;margin-bottom:12.0pt;margin-left:0in;background:white;vertical-align:baseline;font-variant-ligatures:normal;font-variant-caps:normal;text-decoration-style:initial;text-decoration-color:initial;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;box-sizing:inherit;word-spacing:0px">
<span><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729">We have a requirement to allow directory listing from few servers and disallow from other ip addresses and all IP addresses should be able
 to download all files inside the directory.<u></u><u></u></span></span></p>
<p style="margin-right:0in;margin-bottom:12.0pt;margin-left:0in;background:white;vertical-align:baseline;font-variant-ligatures:normal;font-variant-caps:normal;text-decoration-style:initial;text-decoration-color:initial;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;box-sizing:inherit;word-spacing:0px">
<span><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729">Can somebody provide the correct nginx config for the same.<u></u><u></u></span></span></p>
<pre style="background:#eff0f1;vertical-align:baseline;white-space:pre-wrap;font-variant-ligatures:normal;font-variant-caps:normal;text-decoration-style:initial;text-decoration-color:initial;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;box-sizing:inherit;max-height:600px;word-wrap:normal;overflow:auto;word-spacing:0px"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0in;background:#eff0f1">location / {<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0in;background:#eff0f1">root /downloads;<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0in;background:#eff0f1">autoindex on;<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0in;background:#eff0f1">allow 1.1.1.1;<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0in;background:#eff0f1">deny all;<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0in;background:#eff0f1">}<u></u><u></u></span></code></span></pre>
<p style="margin-right:0in;margin-bottom:12.0pt;margin-left:0in;background:white;vertical-align:baseline;font-variant-ligatures:normal;font-variant-caps:normal;text-decoration-style:initial;text-decoration-color:initial;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;box-sizing:inherit;word-spacing:0px">
<span><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729">If I use the above config, only on 1.1.1.1 IP address can directory list from this server and can file download but from other IP addresses
 download shows forbidden, due to IP address restriction<u></u><u></u></span></span></p>
<p style="margin-right:0in;margin-bottom:12.0pt;margin-left:0in;background:white;vertical-align:baseline;font-variant-ligatures:normal;font-variant-caps:normal;text-decoration-style:initial;text-decoration-color:initial;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;box-sizing:inherit;word-spacing:0px">
<span><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729">Is there a way to overcome this issue, thanks.<u></u><u></u></span></span></p>
<p class="MsoNormal"><span><br clear="all">
<u></u><u></u></span></p>
<div>
<div>
<p class="MsoNormal"><span>Thanks & Regards<br>
Sathish.V<u></u><u></u></span></p>
</div>
</div>
</div>
<p class="MsoNormal"><span><br>
______________________________<wbr>_________________<br>
nginx mailing list<br>
</span><a href="mailto:nginx@nginx.org" rel="noreferrer" target="_blank"><span>nginx@nginx.org</span><span></span></a><span><br>
</span><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__mailman.nginx.org_mailman_listinfo_nginx&d=DwMFaQ&c=cjytLXgP8ixuoHflwc-poQ&r=wvXEDjvtDPcv7AlldT5UvDx32KXBEM6um_lS023SJrs&m=fKmL-eoW-L4wbuOH4Cy1Z_3ZWkTmrmgNPGNe6O6FIV4&s=UVcx123SYSrcJEG8dvDlswatIFjwcvFXOBJR6JO6VVk&e=" rel="noreferrer" target="_blank"><span>http://mailman.nginx.org/<wbr>mailman/listinfo/nginx</span><span></span></a><span><u></u><u></u></span></p>
</blockquote>
</div>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
</div>
</div>
</div>

______________________________<wbr>_________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" rel="noreferrer" target="_blank">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer noreferrer" target="_blank">http://mailman.nginx.org/<wbr>mailman/listinfo/nginx</a></blockquote></div></div></div></div></div>
<br>______________________________<wbr>_________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/<wbr>mailman/listinfo/nginx</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><b>Anoop P Alias</b> <div><br></div></div></div></div>
</div>