当前位置:首页 > 未分类

nginx 设置某个目录只允许访问指定后缀文件

admin1年前 (2025-01-15)未分类18500

server {
        listen 80;
        server_name your_domain.com;
         
        location /example_directory/ {
            # 允许访问 特定 后缀的文件
            location ~* \.(png|jpg|jpeg|PNG|JPG|JPEG)$ {
                allow all;
                try_files $uri $uri/ =404;
            }
         
            # 拒绝其他所有请求
            deny all;
        }
         
        # 其他配置...
    }


扫描二维码推送至手机访问。

版权声明:本文由web开发技术分享发布,如需转载请注明出处。

本文链接:https://www.htmlcmf.cn/?id=14

分享给朋友:

相关文章

first-child 不起作用的原因

CSS3—first-child 不起作用的原因1、first-child、last-child、nth-child(n)、nth-child(2n)、nth-child(2n-1)、nth-child(odd)、nth-child(eve…

css文字颜色渐变

background-size: 100%; background-repeat: repeat; background-clip: text; -webkit-background-clip: …

vue修改数据不生效

Vue修改数据不生效的问题通常发生在以下几种情况:直接修改了Vue实例的data对象的根级属性。修改数组时没有使用Vue提供的特定方法(例如push、splice),导致视图不更新。对象属性添加、删除不是响应式的,需要使用Vue.set或v…

npm install卡在“sill idealTree buildDeps“问题的两种解决方法

当你尝试在 Vue 项目中执行 npm install 时,你可能会遇到一个问题:命令卡在"sill idealTree buildDeps"这一步,没有任何反应。这个问题的根源在于淘宝镜像源的域名过…

nginx 阻止指定user-agent

在 Nginx 中阻止特定的 user-agent 可以通过配置 Nginx 的 if 模块或者使用 map 模块来完成。但是,需要注意的是,从 Nginx 1.1.18 开始,官方文档推荐使用 map 模块来更高效地处理这类需求,因为它避…