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 187 forks source link

Request returned 400 error #355

Closed snipd-min closed 1 year ago

snipd-min commented 1 year ago

Hi, I've run into this error {"status":"error","code":404,"message":"The requested URL returned error: 400"} on the following request https://images.weserv.nl/?url=https%3A%2F%2Funemployable.com%2Fwp-content%2Fuploads%2F2020%2F01%2F7-figure-small-podcast.png%0A (or https://images.weserv.nl/?url=https://unemployable.com/wp-content/uploads/2020/01/7-figure-small-podcast.png&width=300&height=300)

The original image is in PNG and is working: https://unemployable.com/wp-content/uploads/2020/01/7-figure-small-podcast.png

Thanks!

kleisauke commented 1 year ago

I could reproduce this, it seems that this website has blocked our User-Agent.

$ curl -sL -o /dev/null -A "curl/7.82.0" -w "%{http_code}\n" https://unemployable.com/wp-content/uploads/2020/01/7-figure-small-podcast.png
200
$ curl -sL -o /dev/null -A "Mozilla/5.0 (compatible; ImageFetcher/9.0; +http://images.weserv.nl/)" -w "%{http_code}\n" https://unemployable.com/wp-content/uploads/2020/01/7-figure-small-podcast.png
400
$ curl -sL -o /dev/null -A "ImageFetcher" -w "%{http_code}\n" https://unemployable.com/wp-content/uploads/2020/01/7-figure-small-podcast.png
400

If you are able to host this project yourself, you can use this to change the outgoing User-Agent within the nginx configuration:

--- a/etc/nginx/imagesweserv.conf
+++ b/etc/nginx/imagesweserv.conf
@@ -54,6 +54,7 @@ server {
     location / {
         resolver 8.8.8.8; # Use Google's open DNS server
         weserv proxy;
+        weserv_user_agent "Mozilla/5.0 (compatible; ImageFetcher/9.0; http://images.weserv.nl/)";

         add_header X-Upstream-Response-Length $weserv_response_length;
     }

Otherwise there's not much we can do for this. Please report this to this website if it continues to be a problem.