weserv / images

Source code of wsrv.nl (formerly images.weserv.nl), to be used on your own server(s).
https://wsrv.nl/
BSD 3-Clause "New" or "Revised" License
1.84k stars 188 forks source link

I am confused how can I use it for s3 images? #413

Closed milanpoudelwebdeveloper closed 1 month ago

milanpoudelwebdeveloper commented 2 months ago

is it same as adding https://wsrv.nl/?url=s3 image url....? I am getting 404 this way

kleisauke commented 2 months ago

Images on public S3 buckets can be reached via <bucket-name>.s3.<region>.amazonaws.com, for example: https://wsrv.nl/?url=https://libvips-packaging.s3.eu-west-1.amazonaws.com/zebra.jpg

Private S3 buckets requires HTTP basic authentication which is not something we'd support on our public service (see #341). If you're able to host your own solution, you can support this by doing something like this within the ngnix configuration:

location /s3/ {
    weserv filter;

    # The S3 bucket we use
    proxy_pass http://libvips-packaging.s3.amazonaws.com/;
    proxy_set_header Host libvips-packaging.s3.amazonaws.com;

    # Authorization should not be needed on public buckets
    proxy_set_header Authorization '';

    # Header configuration
    proxy_hide_header x-amz-id-2;
    proxy_hide_header x-amz-request-id;
    proxy_hide_header x-amz-meta-server-side-encryption;
    proxy_hide_header x-amz-server-side-encryption;
    proxy_hide_header Set-Cookie;
    proxy_ignore_headers Set-Cookie;

    # Intercept proxy errors
    proxy_intercept_errors on;

    # Enable the upstream persistent connection
    proxy_http_version 1.1;
    proxy_set_header Connection '';
}
$ curl -s -o /dev/null -w "%{http_code}" http://localhost/s3/zebra.jpg?w=512
200
kleisauke commented 1 month ago

I hope this information helped. Please feel free to re-open if questions remain.