Welcome! Log In Create A New Profile

Advanced

Reverse proxy for S3 bucket with wildcard

Posted by horizn 
Reverse proxy for S3 bucket with wildcard
February 27, 2019 07:18AM
What I want is to pass somehow bucket name to aws_s3_bucket and proxy_pass. Configuration below works as expected but it is configured to single static bucket. So to access file from the defined in the config bucket, I have to call http://IP_or_hostname/file, what I want is http://IP_or_file/$bucket/file. This is based on https://github.com/anomalizer/ngx_aws_auth module which doesn't support variables as mentioned here: https://github.com/anomalizer/ngx_aws_auth/issues/49. Is it possible with Nginx?

Config:
worker_processes 1;

events {
worker_connections 1024;
}

http {
server {
listen 80;
client_max_body_size 100G;
aws_access_key 'AKI';
aws_signing_key "xyz";
aws_key_scope "20190226/eu-west-2/s3/aws4_request";
aws_s3_bucket 'bucket_name';

location / {
aws_sign;
aws_access_key "AKI";
aws_signing_key "xyz";
aws_key_scope "20190226/eu-west-2/s3/aws4_request";
aws_endpoint "s3.eu-west-2.amazonaws.com";
proxy_pass http://bucket_name.s3.eu-west-2.amazonaws.com/;
resolver 8.8.8.8 valid=300s;
resolver_timeout 10s;
}
}
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 308
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready