How to use Nginx as a proxy for S3 compatible storage with version 4 signature?

Reinis Rozitis r at roze.lv
Wed Dec 14 13:54:09 UTC 2016


> It would be easy to proxy requests like this:
> https://mydomain.com/<bucket>/<files>

> but with version4 we need to send requests like:
> https://<bucket>.mydomain.com/<my_files>

> The problem is that s3storage is a private node which hasn't a public domain. Only Nginx (which is a public node) can see s3storage.
> Does somebody know how to properly proxy such requests?

If you allready have a previous working configuration for the above setup then changing the hostname which nginx uses for the backend is kind of simple – you just need to pass a Host header which works for the S3 backend (by default nginx uses whatever is in the proxy_pass directive either IP or the name from upstream {} block). 


It wasn’t exactly clear (to me) how the client interacts with nginx (which is the correct url)  I mean if it sends the request using https://<bucket>.mydomain.com/<my_files> to nginx you can just use a simple config:


A generic example (optionally the backend can be defined in seperate upstream {} block):

server {
        server_name <bucket>.mydomain.com;
        location / { 
                proxy_set_header Host <bucket>.mydomain.com;
                proxy_pass           https://yours3backendhostname;
        } 
}



rr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20161214/e78da9d0/attachment.html>


More information about the nginx mailing list