Nginx服务器反向代理MinIO配置

配置

请求代理到该域名的根目录


# 代理minio 上传
    server {
    
    
       listen       80;
       listen  [::]:80;
       server_name  minio.example.net;

       # 允许在HTTP头中使用特殊字符
       ignore_invalid_headers off;
       # 禁用代理缓冲
       proxy_buffering off;
       # 禁用请求缓冲
       proxy_request_buffering off;
       # 不限制文件大小
       client_max_body_size 0;

       location / {
    
    
      	   proxy_set_header Host $http_host;
      	   # proxy_set_header Host $host; # 失败,可尝试
           # proxy_set_header Host 127.0.0.1:9000;  # 失败,可尝试
           # proxy_set_header Host  # 失败,可尝试 去掉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;
           proxy_http_version 1.1;
           proxy_set_header Connection "";
           chunked_transfer_encoding off;

           proxy_pass http://minio_s3;
       }
    }

请求代理到该域名的非根目录

    #S3 API签名计算算法不支持托管MinIO Server API的代理方案,例如.example.net/s3/。所以这里使用 ^~ 表示前缀匹配,即任何以 /minio- 开头的请求都会被这个位置块处理。
    #注意:在创建Buckets时要加上minio-前缀,例如:minio-testoss。
        location ^~ /minio- {
    
    
			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_set_header Host $host; # 失败,可尝试
            # proxy_set_header Host 127.0.0.1:9000;  # 失败,可尝试
            # proxy_set_header Host  # 失败,可尝试 去掉host
      		proxy_set_header authorization $http_authorization;
      		proxy_connect_timeout 300;
      		proxy_http_version 1.1;
      		proxy_set_header Connection "";
      		chunked_transfer_encoding off;

            proxy_pass http://127.0.0.1:9000;
            #    proxy_pass_request_headers on;
       }

参考网址

猜你喜欢

转载自blog.csdn.net/qq_35385687/article/details/143208450