【异常解决】java程序连接MinIO报错The request signature we calculated does not match the signature you provided.

简介: 【异常解决】java程序连接MinIO报错The request signature we calculated does not match the signature you provided.

更多ruoyi-nbcio功能请看演示系统

gitee源代码地址

前后端代码: https://gitee.com/nbacheng/ruoyi-nbcio

演示地址:RuoYi-Nbcio后台管理系统

      用java程序上传minio文件时候出现下面前端报上面的错误

      创建Bucket失败, 请核对配置信息:[The request signature we calculated does not match the signature you provided. Check your key and signing method. (Service: Amazon S3; Status Code: 403; Error Code: SignatureDoesNotMatch; Request ID: 17997C8E8553FD5A; S3 Extended Request ID: f295cb55-b4ca-4821-a685-982f66bda3e9; Proxy: null)]

后端报下面的错误

2023-11-21 08:41:25[0;39m [32m[XNIO-1 task-1][0;39m [1;31mERROR[0;39m [1;35mc.r.f.w.e.GlobalExceptionHandler
[0;39m - 请求地址'/system/oss/upload',发生未知异常.
com.ruoyi.oss.exception.OssException: 创建Bucket失败, 请核对配置信息:[The request signature we calculated does not match the signature you provided. Check your key and signing method. (Service: Amazon S3; Status Code: 403; Error Code: SignatureDoesNotMatch; Request ID: 17997C8E8553FD5A; S3 Extended Request ID: f295cb55-b4ca-4821-a685-982f66bda3e9; Proxy: null)]
  at com.ruoyi.oss.core.OssClient.createBucket(OssClient.java:92)
  at com.ruoyi.oss.core.OssClient.<init>(OssClient.java:71)
  at com.ruoyi.oss.factory.OssFactory.instance(OssFactory.java:50)
  at com.ruoyi.oss.factory.OssFactory.instance(OssFactory.java:36)
  at com.ruoyi.system.service.impl.SysOssServiceImpl.upload(SysOssServiceImpl.java:125)
  at com.ruoyi.system.service.impl.SysOssServiceImpl$$FastClassBySpringCGLIB$$8fa643de.invoke(<generated>)
  at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)

根据minio的官方网站,对于nginx需要做调整

为 MinIO 服务器配置 NGINX 代理 — MinIO Object Storage for Linux

upstream minio {
   least_conn;
   server minio-01.internal-domain.com;
   server minio-02.internal-domain.com;
   server minio-03.internal-domain.com;
   server minio-04.internal-domain.com;
}
server {
   listen       80;
   listen  [::]:80;
   server_name  minio.example.net;
   # 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 0;
   # Disable buffering
   proxy_buffering off;
   proxy_request_buffering off;
   location / {
      proxy_set_header Host $http_host;
      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_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 https://minio:9000/; # This uses the upstream directive definition to load balance
   }
   location /minio {
      proxy_set_header Host $http_host;
      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 X-NginX-Proxy true;
      # This is necessary to pass the correct IP to be hashed
      real_ip_header X-Real-IP;
      proxy_connect_timeout 300;
      # To support websockets in MinIO versions released after January 2023
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      chunked_transfer_encoding off;
      proxy_pass https://minio:9001/; # This uses the upstream directive definition to load balance and assumes a static Console port of 9001
   }
}


相关实践学习
对象存储OSS快速上手——如何使用ossbrowser
本实验是对象存储OSS入门级实验。通过本实验,用户可学会如何用对象OSS的插件,进行简单的数据存、查、删等操作。
相关文章
|
JSON Java 数据格式
java调用服务报错400
java调用服务报错400
309 6
java调用服务报错400
|
JSON Java 数据格式
java调用服务报错415 Content type ‘application/octet-stream‘ not supported
java调用服务报错415 Content type ‘application/octet-stream‘ not supported
681 6
|
安全 Java
Java异常处理:程序世界的“交通规则
Java异常处理:程序世界的“交通规则
477 98
|
Java API 开发工具
【Azure Developer】Java代码实现获取Azure 资源的指标数据却报错 "invalid time interval input"
在使用 Java 调用虚拟机 API 获取指标数据时,因本地时区设置非 UTC,导致时间格式解析错误。解决方法是在代码中手动指定时区为 UTC,使用 `ZoneOffset.ofHours(0)` 并结合 `withOffsetSameInstant` 方法进行时区转换,从而避免因时区差异引发的时间格式问题。
533 4
|
JSON 网络协议 安全
【Java】(10)进程与线程的关系、Tread类;讲解基本线程安全、网络编程内容;JSON序列化与反序列化
几乎所有的操作系统都支持进程的概念,进程是处于运行过程中的程序,并且具有一定的独立功能,进程是系统进行资源分配和调度的一个独立单位一般而言,进程包含如下三个特征。独立性动态性并发性。
743 1
|
JSON 网络协议 安全
【Java基础】(1)进程与线程的关系、Tread类;讲解基本线程安全、网络编程内容;JSON序列化与反序列化
几乎所有的操作系统都支持进程的概念,进程是处于运行过程中的程序,并且具有一定的独立功能,进程是系统进行资源分配和调度的一个独立单位一般而言,进程包含如下三个特征。独立性动态性并发性。
674 1
|
数据采集 存储 弹性计算
高并发Java爬虫的瓶颈分析与动态线程优化方案
高并发Java爬虫的瓶颈分析与动态线程优化方案
Java 数据库 Spring
563 0