-
Notifications
You must be signed in to change notification settings - Fork 653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting endpoint and bucket does not work if they are different domains #2883
Comments
Hi @deitch , virtual hosted bucket host anatomy is For example, a bucket "foo" and us-east-1 will result in host: In your case, the bucket name is Thanks, |
Hi @RanVaknin thanks for jumping in so quickly; I do rather appreciate it.
I had always assumed endpoint is distinct from the hostname being served. The same way you can use SNI on certs, etc. "Endpoint" = "go to this IP or FQDN to access the service", while "virtual-path bucket" = "this is the Host field I will put in the headers". They could very well be distinct. What is the correct way to ask the sdk, "I want you to request the bucket FQDN bucket1.mydomain.com (i.e. that is the Host header), but establish the connection to localhost:9000"? They don't have to be tied together. If this is something we do not support but would want to, I am game for opening a PR for it, if I can have some proper direction as to where. I would guess an option that says not to append the endpoint to the bucket FQDN? |
Hi @deitch ,
I think this might be a confusion based on the meaning of the word endpoint that is being used here to mean SDK specific thing. Endpoint is where the request is being sent to. In the context of S3, the endpoint will either be formatted with the bucket name prefix the endpoint for virtual hosted buckets (
They are tied together. The SDK does not have a built in DNS resolver to know that If this is the desired outcome:
the bucket name is Then to route mydomain.com to localhost:9000 you can edit your system's host file to route traffic from mydomain.com to 127.0.0.1 and then using a reverse proxy routing traffic to port 9000 of your localhost. I might be missing the point here since this use case is new to me. Thanks, |
These are both cases I am working with: a local clone (primarily for testing, but not always) and a transparent proxy.
This, I believe, is the heart of it. I think you are saying, from the SDK's perspective, "endpoint" means two things:
I can get why the endpoint might mean both, but also why we might want them to be optionally separable. There is a direct analogy in pkg net/http. On the one hand, if I do Dial func(network, addr [string](https://pkg.go.dev/builtin#string)) ([net](https://pkg.go.dev/net).[Conn](https://pkg.go.dev/net#Conn), [error](https://pkg.go.dev/builtin#error)) The resolution of "here is an FQDN" to "here is a net.Conn which the higher-level http.Client can use to create the http connection, sending whatever headers it wants. As I think about this, if your position is that this may be a valid use case, but should be handled at the Does this explanation help? |
Hi @deitch, Thanks for the additional info.
That is because the Go SDK's http client is the Golang standard library http client. The SDK only builds the request and then hands it to the standard library to handle the actual http request. You can override the SDK's http client to use your desired custom Transport layer with your own implementation of Let me know if this is the piece of info you are after. Thanks, |
Ah, that's it. So would the following be correct? -----BEGIN----- If you wish to override low-level connection, for example to change the timeout or connect to a different server and port, you can do so by changing the |
Hi @deitch , Sounds largely correct. Endpoint is not an S3 specific thing though, its a concept you'd use to override the default request building logic that the SDK provides out of the box and can apply to any AWS service. Seems like the original question was answered (using your own custom transport to define your own implementation of Dial), so I'm going to close this issue. Thanks for reaching out. If you need anything else please feel free to open a new issue. All the best, |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Acknowledgements
go get -u github.com/aws/aws-sdk-go-v2/...
)Describe the bug
Create a proxy or local S3-compatible server. Run it at
localhost:8080
. You would expect that the endpoint is not part of the name. Then try to do activities against the bucket namedbucket1
. TheHost
header in the request always includes the bucket name and the endpoint.For example,
PutObject
formyfile
against bucketbucket1.mydomain.com
with endpointlocalhost:9000
should have headers:Yet it actually has
Regression Issue
Expected Behavior
The endpoint would not be part of the
Host
, since that is a pointer as to where to find the fully named bucket.Current Behavior
Includes it in the host. See the bug description
Reproduction Steps
Possible Solution
No response
Additional Information/Context
I did try various combinations of
BaseEndpoint
andEndpointResolverV2
as described in this doc, to no avail.I suspect there is some combination of which I am not aware, in which case feel free to call this a "docs error report" as opposed to a bug report.
AWS Go SDK V2 Module Versions Used
Compiler and Version used
go version go1.23.0
Operating System and version
linux/amd64
The text was updated successfully, but these errors were encountered: