我有一个自定义nginx模块,在某些代理情况下,将代理文件备份到S3。以下在我的开发机器(macOS Sierra)上按预期工作:
Aws::Client::ClientConfiguration config;
auto s3_client = Aws::MakeShared<Aws::S3::S3Client>(ALLOCATION_TAG,
Aws::Auth::AWSCredentials(s3_key_id, s3_secret),
config);
/* Create stream for S3 PUT from nginx ngx_buf_t *b */
auto input_data = Aws::MakeShared<Aws::StringStream>(ALLOCATION_TAG);
input_data->write(reinterpret_cast<char *>(b->pos), buffer_size);
Aws::S3::Model::PutObjectRequest put_object_request;
put_object_request.WithBucket(bucket_name).WithKey(key_name);
put_object_request.SetBody(input_data);
auto s3_put_outcome = s3_client->PutObject(put_object_request);
然而,在生产EC2实例时,无论是Amazon Linux还是CentOS,它都只是Unable to connect to endpoint while sending to client
错误。
我已尝试设置配置选项(按照AWS C++ S3 SDK PutObjectRequest unable to connect to endpoint的建议),寻求内容长度设置,但没有一个有效:
config.scheme = Aws::Http::Scheme::HTTPS;
config.region = Aws::Region::US_EAST_1;
config.connectTimeoutMs = 30000;
config.requestTimeoutMs = 600000;
...
input_data->seekg(0);
...
put_object_request.SetContentLength(buffer_size);
AWS SDK和nginx版本在我的开发机器和EC2上是相同的,所以我没有想法。关于为什么这可以从macOS而不是在实际AWS主机上工作的任何见解?