[star7th/showdoc]关于showdoc无法使用minio问题

2024-08-05 640 views
0

最近测试使用showdoc发现一个问题,具体情况如下:

图片存储配置为minio,endpoint配置为minio服务器的IP+端口,可以正常上传,但是如果使用nginx反向代理并且配置域名就无法上传。

nginx配置如下:

# minio
server {
    listen 80;
    listen [::]:80;
    listen 443 ssl http2;
    server_name xxx.com;

    ssl_certificate ssl/fullchain.cer;
    ssl_certificate_key ssl/xx.key;

    ignore_invalid_headers off;
    proxy_buffering off;
    proxy_request_buffering off;
    client_max_body_size 1G;

    location / {
        proxy_pass http://127.0.0.1:9002/;
        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;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        chunked_transfer_encoding off;
    }
}

适用域名上传提示如下: 20230629142632

这是bug,还是我配置问题?

回答

4

上传错误的时候,打开浏览器审查元素,看看网络的那个url返回的错误提示是什么。一般会有提示的

2

image

0

那就是连不上服务器咯。你绑定的域名,多半是要改hosts的吧。如果是用docker部署的,那么,单纯修改宿主机的hosts文件没用的。自己上网搜索下怎么修改容器的hosts

1

看你的目录,应该不是docker部署的。自己上服务器,真实链接一下域名,看能否通。

0

我是手动部署的,域名是公网DNS解析的,并且可以正常访问。 image

3

这个事情我好像没法给出好的参考。原始ip+端口能通,说明应该是你绑定域名的问题。但是问题出在哪,我也不好说。 要不你上网搜索个支持s3协议的第三方客户端,使用域名确保能连接正常了再试试。 同时服务器也telnet 域名和端口,确定能走通。

0

我用python测试,可以正常上传图片,安全起见,域名我用xxx代替了,代码如下:

from minio import Minio
from minio.error import S3Error

def main():
    # Create a client with the MinIO server playground, its access key
    # and secret key.
    client = Minio(
        "xxx:443",
        access_key="37HnHxxxjMJj",
        secret_key="6z0hVxxxPZ4W0dN",
    )

    # Make 'lishuismzjgis' bucket if not exist.
    found = client.bucket_exists("showdoc")
    if not found:
        client.make_bucket("showdoc")
    else:
        print("Bucket 'showdoc' already exists")

    # Upload '/home/user/Photos/asiaphotos.zip' as object name
    # 'asiaphotos-2015.zip' to bucket 'lishuismzjgis'.
    client.fput_object(
        "showdoc", "python-upload-test.jpg", "C:\\Users\\Administrator\\Pictures\\1.jpg",
    )
    print(
        "'C:\\Users\\Administrator\\Pictures\\1.jpg' is successfully uploaded as "
        "object 'python-upload-test.jpg' to bucket 'showdoc'."
    )

if __name__ == "__main__":
    try:
        main()
    except S3Error as exc:
        print("error occurred.", exc)

showdoc 后台配置: image

帮我分析分析,谢谢啊。

0

endpoint不加端口试试。因为默认就是使用https 443的

8

我说的是showdoc上填写的配置

0

那应该就是,showdoc所在服务器无法通过公网访问你的域名吧。毕竟像你这样写内网ip就可以。而公网应该是解析公网ip吧

7

要不单独弄个域名,解析成内网ip,然后配置看看

4

我也试了一下,问题依旧。 客户端: image

服务器: image

0

服务器是可以访问公网的,解析minio域名也没问题

1

我暂时没想到发生这种情况的可能性,不知道为什么。

4

@qtsunk 如果排除服务器DNS问题

使用PHP+CURL模拟下上传,你大概率会发现错误 提示SSL问题 如果你minio使用的免费证书或自签名证书