upstream minio_cluster { server 192.168.1.77:19000; }
server { listen 80; server_name 192.168.1.77 localhost;
# To allow special characters in headers ignore_invalid_headers off; # Allow any size file to be uploaded. # Set to a value such as 1000m; to restrict file size to a specific value client_max_body_size 100m; # To disable buffering proxy_buffering off;
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;
通过 mc policy 策略命令来设置匿名访问 kyc/public 目录下的所有文件的访问权限为可读可写(public)。
上图为 mc policy 策略命令的帮助,可以看到支持的权限 policy 有:none, download, upload, public,根据名称权限一目了然。
下面为通过 mc policy 命令设置对 kyc/public 目录下的资源的匿名访问权限:
1 2 3 4 5 6
[health@kyc-dev bin]$ mc policy set public local/kyc/public Access permission for `local/kyc/public` is set to `public` [health@kyc-dev bin]$ mc policy list local/kyc/public kyc/public* => readwrite [health@kyc-dev bin]$ mc policy list local/kyc kyc/public* => readwrite
通过 mc policy 命令我们也可以根据业务需求来设置指定的目录或资源仅有上传(upload)或下载(download)的权限,如下命令将 kyc/public 目录重新设置为 readonly 权限:
1 2 3 4
[health@kyc-dev ~]$ mc policy set download local/kyc/public Access permission for `local/kyc/public` is set to `download` [health@kyc-dev ~]$ mc policy list local/kyc kyc/public* => readonly
设置成功之后,就可以直接通过浏览器访问其中的资源,如下图:
通过 Java SDK 来设置
除了通过 mc policy 命令来为指定的 bucket 设置策略之外,还可以通过代码的方式在运行时根据业务需求来动态设置资源的访问策略: