首页 > 系统相关 >使用nginx limit_except 保护暴露外网的minio 服务

使用nginx limit_except 保护暴露外网的minio 服务

时间:2022-10-26 21:59:27浏览次数:73  
标签:minio header except nginx limit proxy

minio 做为比较热门的开源s3 服务,受到好多团队的青睐,使用率还是比较高的,如果我们的服务是部署在内网的还好
一般不用太担忧安全问题(但是也得做好内网的安全防护),但是如果直接将s3 服务暴露到公网问题就比较多了,解决
方法很多,比如使用waf,自己配置一些安全策略,以下是基于nginx limit_except 搞一个minio 快速的安全防护

参考玩法

核心是利用了limit_except 只允许,get,head, 以及options 请求,对于delete 以及put,post 等操作都禁用,好处比较明显
我们只会暴露我们需要提供给用户资源(主要是get),一般就不同利用我们的put 以及delete 操作了

 

 

参考玩法

  • docker-compose 文件
 
version: '3'
services:
  minio:
    image: minio/minio
    ports:
      - "9000:9000"
      - "19001:19001"
    environment:
      MINIO_ROOT_USER: minio
      MINIO_ROOT_PASSWORD: minio123
    command: server --console-address :19001 --quiet /data
  nginx:
    image: openresty/openresty:alpine-fat
    volumes:
      - ./nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf
    ports:
      - 80:80
  • nginx.conf
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    gzip  on;
    real_ip_header     X-Forwarded-For;
    resolver 127.0.0.11;
    real_ip_recursive on;
    server {
        listen       80;
        server_name  localhost;
        charset utf-8;
        # 基于nginx 暴露最小的请求路径,同时限制只能使用get head 以及options 请求
        location /apps/ {
            limit_except GET HEAD OPTIONS{
                 deny all;
            }
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header Host $http_host;
            proxy_connect_timeout 300;
            # Default is HTTP/1, keepalive is only enabled in HTTP/1.1
            proxy_http_version 1.1;
            proxy_set_header Connection "";
            chunked_transfer_encoding off;
            proxy_pass http://minio:9000;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

说明

以上是一个简单的玩法,实际上我们基于nginx (openresty) 可以做不少关于minio 的安全防护,减少minio 因为安全问题,造成的数据泄漏以及被人利用

参考资料

https://nginx.org/en/docs/http/ngx_http_core_module.html#satisfy
https://github.com/rongfengliang/using_limit_except_protect_minio

标签:minio,header,except,nginx,limit,proxy
From: https://www.cnblogs.com/rongfengliang/p/16830196.html

相关文章

  • Nginx初接触
    Nginx的反向代理与负载均衡以及动静分离正向代理与反向代理正向代理代理客户端反向代理代理服务器**Nginx提供的负载均衡策略有2种:内置策略和扩展策略。内置策略为轮......
  • nginx 又出现了 404
    我使用下面的nginx配置, 看起来好像没问题:server{listen80;#listensomename:80;#server_namesomenamealiasanother.alias;......
  • minio 对象存储部署一些说明
    一个minio简单部署使用说明,以前写过一些简单的,主要扩展下,对于优化相关的具体可以参考官方的以及linux相关优化的文章参考部署  可靠性玩法可以开启多版本开启......
  • weka遇到java.util.zip.ZipException: invalid LOC header (bad signature)
    这是因为有jar包没有下载完全引起的,需要将相应包重新下载。到maven的reposity目录下搜aether*****in-progress(可以搜aether或者in-progress都行)文件,如果存在,把这个文件对......
  • Linux安装nginx
    1、安装所需环境//安装gccyuminstallgcc-c++//安装PCREpcre-develyuminstall-ypcrepcre-devel//安装zlibyuminstall-yzlibzlib-devel//安装OpenS......
  • Windows安装nginx
    环境Windows10nginx1.22.1配置下载nginx下载地址:http://nginx.org/en/download.html下载稳定版安装解压到指定目录,以管理员权限启动命令提示符,进入解压后的ngin......
  • nginx动静分离 性能对比
    压力测试工具:jmeter1将静态资源放在后端服务上,测试以下测试参数   2测试报告吞吐量1.5   3将静态资源放在nginx上,设置以下参数   4测试报告......
  • nginx配置增加代替头部proxy_set_header信息upgrade支持WebSocket--笔记
    1、开发的数据库分片管理平台使用nginx代理报错页面访问执行没有报错,chrome按F12有如下报错WebSocketconnectionto'ws://mdb.xxx.cn/app/shard_createtable/'failed: ......
  • Nginx04 反向代理和负载均衡
    1反向代理介绍https://www.cnblogs.com/jthr/p/16827214.html 2负载均衡介绍https://www.cnblogs.com/jthr/p/16827328.html 3 Nginx的反向代理配置3.......
  • Nginx 为什么要配置 server_name
    作用servername为虚拟服务器的识别路径。因此不同的域名会通过请求头中的HOST字段,匹配到特定的server块,转发到对应的应用服务器中去。案例修改nginx.confserver{ l......