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.86k stars 187 forks source link

Random 404 #315

Closed Ivanezko closed 2 years ago

Ivanezko commented 2 years ago

Hello. I have a problem with self-hosted server (images.weserv.nl works like a charm) Here is an example https://t-news-weserv.x.co.ua/?w=200&h=200&fit=cover&aaa=q1234569a&url=https://t-news-api.x.co.ua/api/1.0/static/6/4/646c1d97774f3e26cd99f1c0a6ad98b5 Changing "&aaa=q1234569a" by adding random symbols, I get 50/50 200/404

`{ status: "error", code: 404, message: "The hostname of the origin is unresolvable (DNS) or blocked by policy." }

~ curl https://t-news-weserv.x.co.ua/\?w\=200\&h\=200\&fit\=cover\&aaa\=q12345a619a\&url\=https://t-news-api.x.co.ua/api/1.0/static/6/4/646c1d97774f3e26cd99f1c0a6ad98b5
{"status":"error","code":404,"message":"The hostname of the origin is unresolvable (DNS) or blocked by policy."}%

~ curl https://t-news-weserv.x.co.ua/\?w\=200\&h\=200\&fit\=cover\&aaa\=q12345a619a\&url\=https://t-news-api.x.co.ua/api/1.0/static/6/4/646c1d97774f3e26cd99f1c0a6ad98b5
{"status":"error","code":404,"message":"The hostname of the origin is unresolvable (DNS) or blocked by policy."}%

~ curl https://t-news-weserv.x.co.ua/\?w\=200\&h\=200\&fit\=cover\&aaa\=q12345a619a1\&url\=https://t-news-api.x.co.ua/api/1.0/static/6/4/646c1d97774f3e26cd99f1c0a6ad98b5
Warning: Binary output can mess up your terminal. Use "--output -" to tell Warning: curl to output it to your terminal anyway, or consider "--output Warning: " to save to a file.

~ curl https://t-news-weserv.x.co.ua/\?w\=200\&h\=200\&fit\=cover\&aaa\=q12345a619a1\&url\=https://t-news-api.x.co.ua/api/1.0/static/6/4/646c1d97774f3e26cd99f1c0a6ad98b5
{"status":"error","code":404,"message":"The hostname of the origin is unresolvable (DNS) or blocked by policy."}% ` Here only 1 attempt was success, and the next one with the same &aaa\=q12345a619a1 gave an error. Here is a docker-compose:

` weserv: image: ghcr.io/weserv/images:5.x restart: always environment: shm_size: 1gb ports:

kleisauke commented 2 years ago

Sounds like the IPv6 interface is not properly configured, see #206 for more information. If using Docker, you can try to switch to host networking by passing --network host to the command line (or you can use network_mode: "host", when using Docker compose).

Ivanezko commented 2 years ago

cant really use network_mode: "host", because its incompatible with port binding (80 used by nginx on the host) and as I can see, weserv cant get port from environment. looks like I need to build my own image just for resolver 8.8.8.8 ipv6=off; Would be great to turn off ipv6 with parameter, without building the whole project Anyway thanx

kleisauke commented 2 years ago

If you are using the pre-built Docker image, you don't need to rebuild anything if you want to set the ipv6=off parameter. Just change /etc/nginx/imagesweserv.conf in the running container, or mount a custom nginx configuration at this file location. #300 is also relevant here.

Ivanezko commented 2 years ago

thanx a lot, works good: ` weserv: image: ghcr.io/weserv/images:5.x restart: always environment: shm_size: '1gb' volumes:

kleisauke commented 2 years ago

Great, I'll close. Note that specifying the ipv6=off parameter is not always desirable, since there are a numerous hosts that only support IPv6 and/or provide broken IPv4 fallbacks.