首页 > 系统相关 >Nginx配置referer校验,实现简单的防盗链

Nginx配置referer校验,实现简单的防盗链

时间:2023-03-07 18:00:54浏览次数:33  
标签:请求 校验 Nginx referer Referer 防盗链

1、背景

对增删修改类请求接口的referer做白名单校验或 在参数中增加随机,预防CSRF漏洞


2.1、 Nginx Referer模块

ngx_http_referer_module模块用于阻止"Refer"头字段中具有无效值的来源非法的域名请求。使用适当的"Referer"字段值创建请求是非常容易,这些伪造的"Referer"字段可能会包括一些不合法的字段。本模块的目的不是彻底阻止此类请求,而是阻止常规浏览器发送的大量请求。还应考虑到,即使对于有效的请求,常规浏览器也不应发送"Referer"字段。

2.2、 valid_referers

| Syntax:  | valid_referers none | blocked | server_names | string ...; |
| -------- | ---------------------------------------------------------- |
| Default: | —                                                          |
| Context: | server, location                                           |

标签:请求,校验,Nginx,referer,Referer,防盗链
From: https://www.cnblogs.com/linuxshare/p/17188974.html

相关文章

  • nginx 配置Referer防盗链
    location~.*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)${valid_referersnoneblockedserver_name*.jingxialai.comwww.jingxialai.com/shop/~\.go......
  • 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......