upload icon indicating copy to clipboard operation
upload copied to clipboard

Cannot resolve host correctly for AWS S3 module

Open shawPLUSroot opened this issue 3 years ago • 4 comments

Bug Report

Current Behavior I built the Minio in a server which is compatible with AWS S3 API and initially it works fine, but when I tried to add the SSL certificate to my domain and attached it to my IP address which holds the Minio server, it crashed. The main problem I checked in my logs is the extension resolved the host incorrectly. It's a weird action -- the normal host should be host:port/bucket_name/image.jpg, but it gave:

bucket_name.host:port/bucket_name/image.jpg. Also, the host should be starting with https, however, it gave http instead. Can you help me solve this issue?

Expected Behavior It should upload image normally.

Screenshots 截屏2022-01-23 15 28 41

Environment

  • Flarum version: 1.1.1
  • Extension version: 1.0.7
  • Webserver: nginx
  • Hosting environment: vps
  • PHP version: 7.4.1
  • Browser: Firfox/Safari

Possible solution(s)

I think it might be due to the original code for dealing with S3 API. But I don't know which file is relevant.

shawPLUSroot avatar Jan 23 '22 07:01 shawPLUSroot

It seems like we are passing the options quasi-verbatim to the AWS SDK so I'm not sure what else we could do:

https://github.com/FriendsOfFlarum/upload/blob/fe72df5d93753c011d099242fcc43b38a5b66dda/src/Adapters/Manager.php#L110-L122

Have you tried to change the awsS3UsePathStyleEndpoint setting? (not sure how it's called in the frontend)

I don't see where the HTTPS/HTTP issue is from your screenshot.

Can you share a screenshot/copy of your S3 settings in the Flarum admin panel so we can compare with the error message?

clarkwinkelmann avatar Jan 23 '22 17:01 clarkwinkelmann

截屏2022-01-24 12 28 20 截屏2022-01-24 12 29 26

It seems that I solve the https problem as long as I add https:// for the endpoint part. But still, it would put the bucket_name (in my case, the name is "images") in front of my domain -- which leads to the unresolved host https://images.my_domain:9000/date/image_name. 😅 This is really weird.....

shawPLUSroot avatar Jan 24 '22 04:01 shawPLUSroot

Can someone plz help me?

shawPLUSroot avatar Feb 17 '22 02:02 shawPLUSroot

Unfortunately I don't have any other idea... A change might be required in the extension to make this format work.

clarkwinkelmann avatar Feb 17 '22 17:02 clarkwinkelmann