hanazuki / s3tftpd

TFTP server with Amazon S3 as backing storage
MIT License
22 stars 3 forks source link

Support for S3-compatible object storage #4

Closed chitvan1988 closed 2 years ago

chitvan1988 commented 2 years ago

Request for Procedure to compile and build the entire code so as to include options like:

1) using custom url to access custom s3 storage like minio 2) disabling ssl and using plain http
Or may please enlighten us if above ways are already implemented. Thanks for for your support.

hanazuki commented 2 years ago

You can just run go build to build the executable.

s3tftpd currently only supports the genuine S3 and so it always uses secure transport to get and put objects. Your contributions for those features are welcome.

hanazuki commented 2 years ago

Actually, I have no idea whether the AWS Go SDK provides a way to connect to S3-compatible object storage.

hanazuki commented 2 years ago

Reading How to use AWS SDK for Go with MinIO Server, I think you want --endpoint and --no-tls CLI options to set awsConfig.Endpoint and awsConfig.DisableSSL, respectively, in https://github.com/hanazuki/s3tftpd/blob/78235b071850ea010b1232bb84e59c4d1e1c5376/main.go#L49-L60

chitvan1988 commented 2 years ago

Did some work to get it working for s3 compatible storage like MINIO(non-AWS s3) main.go.txt Tested for http backend.Please change extension main.go.txt to main.go for checkin purposes. Compile using: DOCKER_BUILDKIT=1 docker build .

Post successful compilation it can be run using :

sudo docker run -p 69:69/udp --env AWS_ACCESS_KEY_ID= --env AWS_SECRET_ACCESS_KEY= --env AWS_REGION= --endpointurl="http://:" --diablessl=true --s3forcepathstyle=true --nonawsbuts3=true s3://

Please let us know if any more changes to be done.

chitvan1988 commented 2 years ago

Reposting sample docker command for execution: sudo docker run -p 69:69/udp --env AWS_ACCESS_KEY_ID=AWS ACESS KEY ID --env AWS_SECRET_ACCESS_KEY=AWSACESSKEY --env AWS_REGION=anydummyregion "newly compiled tfttpd image name" --endpointurl="http://ip:port" --diablessl=true --s3forcepathstyle=true --nonawsbuts3=true s3://bucketname

chitvan1988 commented 2 years ago

Explanation of options as written in new main.go: Endpointurl string name:"endpointurl" help: "for Non-AWS but S3 Complaint like MINIO.nonawsbuts3 needs to be true" DisableSSL bool name:"diablessl" help: "for simpler http based endpoint urls.nonawsbuts3 needs to be true" Forcepathstyle bool name:"s3forcepathstyle" help: "For S3 complaint like MINIO.nonawsbuts3 needs to be true" Nonawsbuts3 bool name:"nonawsbuts3" help: "For use with non-AWS but comaliant with s3 solutions like MINIO"

hanazuki commented 2 years ago

@chitvan1988 Thank you for providing a patch. I'll review it soon.

Are you willing to license your patch under the MIT license, which is available in LICENSE file in this repository, so that I can merge it into this repository?

chitvan1988 commented 2 years ago

Any license of your choice

hanazuki commented 2 years ago

I have merged your patch with some modifications. Now TLS is automatically disabled if you specify http://... URL to --endpoint-url, and removed --nonawsbuts3 because --endpoint-url option is also applicable to S3 in some use cases.

I tested the code with MinIO running on Docker, but if you find any problem with your real-world deployment, please feel free to reopen this issue.

chitvan1988 commented 2 years ago

Thanks for review .I believe http support is leftout in your checkin .Ans also force-path-style might(may be ) break existing users.

hanazuki commented 2 years ago

You can just specify --endpoint-url="http://host:port" to use HTTP and --endpoint-url="https://host:port" to use HTTPS. If you don't specify --force-path-style options, it works as it was (uses virtual hosted-style when possible).