<div dir="ltr"><div dir="ltr"></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Nov 12, 2020 at 8:13 PM Francis Daly <<a href="mailto:francis@daoine.org">francis@daoine.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, Nov 12, 2020 at 07:17:46PM +0530, Kaushal Shriyan wrote:<br>
<br>
Hi there,<br>
<br>
> I am running the Nginx version: nginx/1.16.1 on CentOS Linux release<br>
> 7.8.2003 (Core). I am trying to forbid/prevent web.config file to<br>
> download it from the browser. When I hit<br>
> <a href="https://mydomain.com/web.config" rel="noreferrer" target="_blank">https://mydomain.com/web.config</a> it is allowing me to download instead of<br>
> forbidding the page ( 403 Forbidden).<br>
<br>
When I use this config, it works for me (I get the http 403 response).<br>
<br>
Are you sure that the config file with this server{} block is read by<br>
your running nginx?<br>
<br>
Are there any other server{} blocks with the same (implicit) "listen"<br>
directive, that might mean that this server{} block is never used?<br>
<br>
What do you get if you do<br>
<br>
  curl -i -H Host:_ <a href="http://your-server/web.config" rel="noreferrer" target="_blank">http://your-server/web.config</a><br>
<br>
where the "Host:_" part is an attempt to match the server_name that you<br>
set in this server{} block.<br>
<br>
(Change "your-server" to be a name or IP that your client can use to get<br>
at the web service.)<br></blockquote><div><br></div><div>Hi Francis,</div><div><br></div><div> Thanks Francis for the email response. There are two servers {} blocks one with <b>listen 80 default_server</b> and the other with <b>listen 443 ssl</b> I am running the website on port 443 and added the below in the server block with listen 443 ssl. It worked perfectly. Thanks a lot for pointing the issue and appreciate it.</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">location ^~ /web.config {<br>            deny all;<br>        }</blockquote><div><br></div><div>Best Regards,</div><div><br></div><div>Kaushal</div></div></div>