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

URL returned error: 403 #342

Closed aletuba closed 2 years ago

aletuba commented 2 years ago

Hello! Been using images.weserv.nl, recently I've noticed that now 403 errors, no matter what image I used. I suspect it might be a user agent problem. Can you help me?

The URL we are trying to reach: https://images.weserv.nl/?url=https://www.tomnegociosimobiliarios.com.br/fotos_imoveis/16/123514-3.jpg

kleisauke commented 2 years ago

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

$ curl -s -o /dev/null -w "%{http_code}\n" https://www.tomnegociosimobiliarios.com.br/fotos_imoveis/16/123514-3.jpg
200
$ curl -s -o /dev/null -w "%{http_code}\n" -A "Mozilla/5.0 (compatible; ImageFetcher/9.0; +http://images.weserv.nl/)" https://www.tomnegociosimobiliarios.com.br/fotos_imoveis/16/123514-3.jpg
403

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.