nginx prevent file download

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

nginx prevent file download

Kaushal Shriyan
Hi,

I am running nginx webserver and i have set the below location block in nginx.conf configuration file to prevent a file to download.  When i hit http://example.com/web.config on the browser, the web.config file gets downloaded. It is not working. 

location ~* \.(config)$ {
    deny all;
}

I will appreciate if somebody can pitch in for help. Thanks in Advance.

Best Regards,

Kaushal

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: nginx prevent file download

Francis Daly
On Wed, Aug 29, 2018 at 09:15:26PM +0530, Kaushal Shriyan wrote:

Hi there,

> When i hit
> http://example.com/web.config on the browser, the web.config file gets
> downloaded. It is not working.
>
> location ~* \.(config)$ {
>     deny all;
> }

It works for me.

Are you sure that the config file that you think you are using is actually
being used?

Do you have any other "location" blocks defined that nginx will choose
to process the "/web.config" request, instead of this one?

If you test by temporarily making this the only location{} block in your
config, do you see it work or fail?

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx