<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
code
{mso-style-priority:99;
font-family:"Courier New";}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;}
span.EmailStyle22
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">I think you need to change this a little<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></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>
}<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">and then in in the download location block<br>
<br>
autoindex $allowed;<o:p></o:p></p>
<p class="MsoNormal">I use similar logic on different variables and try at all costs to avoid IF statements anywhere in the configs.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;color:#44546A">___________________________________________<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;color:#44546A">Michael Friscia<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;color:#44546A">Office of Communications<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;color:#44546A">Yale School of Medicine<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;color:#44546A">(203) 737-7932 - office<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;color:#44546A">(203) 931-5381 - mobile<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;color:#44546A"><a href="http://web.yale.edu/"><span style="color:#44546A">http://web.yale.edu</span></a><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><o:p> </o:p></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 <nginx-bounces@nginx.org> on behalf of PRAJITH <prajithpalakkuda@gmail.com><br>
<b>Reply-To: </b>"nginx@nginx.org" <nginx@nginx.org><br>
<b>Date: </b>Friday, May 18, 2018 at 2:16 AM<br>
<b>To: </b>"nginx@nginx.org" <nginx@nginx.org><br>
<b>Subject: </b>Re: Nginx Directory Listing - Restrict by IP Address<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><a name="_MailOriginalBody">Hi Satish,<o:p></o:p></a></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="mso-bookmark:_MailOriginalBody">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=" target="_blank"><span style="mso-bookmark:_MailOriginalBody">http://nginx.org/r/if</span><span style="mso-bookmark:_MailOriginalBody"></span></a><span style="mso-bookmark:_MailOriginalBody">.
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>
}<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="mso-bookmark:_MailOriginalBody">and then in in the download location block<br>
<br>
if ($allowed = 1) {<br>
autoindex on;<br>
}<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="mso-bookmark:_MailOriginalBody">Thanks,<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="mso-bookmark:_MailOriginalBody">Prajith<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="mso-bookmark:_MailOriginalBody"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span style="mso-bookmark:_MailOriginalBody">On 18 May 2018 at 05:35, Sathish Kumar <</span><a href="mailto:satcse88@gmail.com" target="_blank"><span style="mso-bookmark:_MailOriginalBody">satcse88@gmail.com</span><span style="mso-bookmark:_MailOriginalBody"></span></a><span style="mso-bookmark:_MailOriginalBody">>
wrote:<o:p></o:p></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="mso-margin-top-alt:0in;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 style="mso-bookmark:_MailOriginalBody"><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729">Hi Team,<o:p></o:p></span></span></p>
<p style="mso-margin-top-alt:0in;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 style="mso-bookmark:_MailOriginalBody"><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.<o:p></o:p></span></span></p>
<p style="mso-margin-top-alt:0in;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 style="mso-bookmark:_MailOriginalBody"><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729">Can somebody provide the correct nginx config for the same.<o:p></o:p></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 style="mso-bookmark:_MailOriginalBody"><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0in;background:#EFF0F1">location / {<o:p></o:p></span></code></span></pre>
<pre style="background:#EFF0F1;vertical-align:baseline"><span style="mso-bookmark:_MailOriginalBody"><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0in;background:#EFF0F1">root /downloads;<o:p></o:p></span></code></span></pre>
<pre style="background:#EFF0F1;vertical-align:baseline"><span style="mso-bookmark:_MailOriginalBody"><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0in;background:#EFF0F1">autoindex on;<o:p></o:p></span></code></span></pre>
<pre style="background:#EFF0F1;vertical-align:baseline"><span style="mso-bookmark:_MailOriginalBody"><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0in;background:#EFF0F1">allow 1.1.1.1;<o:p></o:p></span></code></span></pre>
<pre style="background:#EFF0F1;vertical-align:baseline"><span style="mso-bookmark:_MailOriginalBody"><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0in;background:#EFF0F1">deny all;<o:p></o:p></span></code></span></pre>
<pre style="background:#EFF0F1;vertical-align:baseline"><span style="mso-bookmark:_MailOriginalBody"><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0in;background:#EFF0F1">}<o:p></o:p></span></code></span></pre>
<p style="mso-margin-top-alt:0in;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 style="mso-bookmark:_MailOriginalBody"><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<o:p></o:p></span></span></p>
<p style="mso-margin-top-alt:0in;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 style="mso-bookmark:_MailOriginalBody"><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729">Is there a way to overcome this issue, thanks.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:_MailOriginalBody"><br clear="all">
<o:p></o:p></span></p>
<div>
<div>
<p class="MsoNormal"><span style="mso-bookmark:_MailOriginalBody">Thanks & Regards<br>
Sathish.V<o:p></o:p></span></p>
</div>
</div>
</div>
<p class="MsoNormal"><span style="mso-bookmark:_MailOriginalBody"><br>
_______________________________________________<br>
nginx mailing list<br>
</span><a href="mailto:nginx@nginx.org"><span style="mso-bookmark:_MailOriginalBody">nginx@nginx.org</span><span style="mso-bookmark:_MailOriginalBody"></span></a><span style="mso-bookmark:_MailOriginalBody"><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=" target="_blank"><span style="mso-bookmark:_MailOriginalBody">http://mailman.nginx.org/mailman/listinfo/nginx</span><span style="mso-bookmark:_MailOriginalBody"></span></a><span style="mso-bookmark:_MailOriginalBody"><o:p></o:p></span></p>
</blockquote>
</div>
<p class="MsoNormal"><span style="mso-bookmark:_MailOriginalBody"><o:p> </o:p></span></p>
</div>
</div>
</body>
</html>