首页 > 系统相关 >nginx 配置Referer防盗链

nginx 配置Referer防盗链

时间:2023-03-07 17:01:05浏览次数:35  
标签:jingxialai www google nginx Referer referer com 防盗链

  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
            valid_referers none blocked server_name *.jingxialai.com www.jingxialai.com/shop/ ~\.google\.;
            if ($invalid_referer) {
               return 403;
               #rewrite ^.*$ https://www.google.com;
            }
  }

none:为空没有referer也可以直接访问
blocked:referer没有值也可以访问;请求头Referer字段不为空(即存在Referer),但是值被代理或者防火墙删除了,这些值不以“http://”或“https://”开头,通俗点说就是允许“http://”或"https//"以外的请求。比如Referer为http://www.baidu.com则会拦截,若是Referer为www.baidu.com或wss://www.baidu.com则不会拦截
server_name:nginx配置的域名,有的可能是server_names
www.jingxialai.com/shop/:从这个页面的请求都可以访问
*.jingxialai.com:域名正则可以访问
~.google.:只要识别到有google正则都可以访问

 

一般配置为

valid_referers xx.xxxx.com;
if ($invalid_referer) {
        return 403;
}

为空啥的都不允许访问。

标签:jingxialai,www,google,nginx,Referer,referer,com,防盗链
From: https://www.cnblogs.com/dwj192/p/17188683.html

相关文章

  • nginx-location
    http/usr/local/openresty/nginx/conf/nginx.confusernobody;worker_processes2;worker_shutdown_timeout10s;worker_rlimit_nofile104800;pid/run/nginx.pid......
  • windows下使用nginx + waitress 部署django
    虽然不喜欢IIS,不过有些项目又必须部署在windows上,windows下部署django的方案有IIS+wfastcgi,apache+mod_wsgi,也有超简单的部署方式如:nginx+waitress,本文主要讲的是最......
  • ##Nginx反向代理负载均衡
    介绍: Ngin x是一个高性能的http和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务,特点:占有内存少,并发能力强。作为中间件具有如下功能:1、制作静态页面2、反向代理3、......
  • 在Linux和Unix上隐藏Nginx版本
    使用CLI显示当前Nginx版本Nginx将在错误页面和“服务器”响应标头字段中显示版本。我们可以使用以下命令进行验证:示例输出:$curl-Ihttps://your-domain$curl-I......
  • 10_Nginx
    Nginx有什么用反向代理、缓存、负载均衡。功能1:反向代理背景:随着访问流量的不断增加,系统不足以支持时,可以对系统进行横向扩展,即增加服务节点,比如说从1个服务节点,增加的2......
  • nginx部署前端项目-location root与 alias区别
    1、locationroot:/path/uri(把匹配的路径追加到配置的路径:/demoProject追加到/usr/local/nginx/front/apps/demo)/demoProject{root/usr/local/nginx......
  • linux下nginx安装rtmp模块
    0.背景1.安装1.1安装nginx所需的编译环境yuminstall-ywgetunzipgccgcc-c++perlpcre-develzlibzlib-developensslopenssl-develnet-tools1.2下载nginx......
  • prometheus监控nginx
    1.下载vtscd/optgitclonehttps://github.com/vozlt/nginx-module-vts.git2.编译nginx./configure--prefix=/app/nginx-1.22.1\--user=www\--group=www\--......
  • nginx 命令说明
    #启动命令./sbin/nginx-c./conf/nginx.conf#验证配置是否正确./nginx-t回显testissuccessful说明配置正确第二种方法  ./sbin/nginx-t-c./conf/nginx.conf......
  • 云服务器搭建frp+docker+nginx转发到本机Nas以及docker服务
    #云服务器搭建frp+docker+nginx转发到本机Nas以及docker服务如果觉得样式不好:跳转即可(md文件复制过来有些样式会不一样)原文地址:https://www.firstsaofan.top/archives......