• 使用nginx limit_except 保护暴露*的minio 服务


    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

  • 相关阅读:
    POJ3253Fence Repair(优先队列或单调队列)
    POJ3630Phone List(字典树)
    HDU1896Stones(优先队列)
    POJ3468 A Simple Problem with Integers(线段树延时标记)
    HDU3535AreYouBusy(分组背包)
    C++ 学习涨姿势汇总
    [C++] std::vector 使用
    Cocos2dx-3.2 引擎学习(四)之CCScheduler
    Cocos2dx-3.2 引擎学习(三)之AssetsManager
    Cocos2dx-3.2 引擎学习(二)之Director
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/16830196.html
Copyright © 2020-2023  润新知