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
2.05k stars 200 forks source link

404 Not found another container in docker-compose #403

Closed maffinca69 closed 8 months ago

maffinca69 commented 10 months ago

Hi!

I have my own service that can give out pictures. For example, the address (server in docker-compose) http://localhost:81/media/image.png will return a valid and correct picture image.png But if the same address is used to get a thumbnail image, I get a 404. At the same time curl call inside weserv container successfully downloads my image

WESERV_PORT - 8086
PUBLIC_PORT - 85
version: '3'

services:
  server:
    build: ./unit
    working_dir: /var/www/
    restart: unless-stopped
    ports:
      - "${PUBLIC_PORT}:81"
    volumes:
      - ./unit/config.json:/docker-entrypoint.d/config.json
      - ./../.:/var/www
      - ${PUBLISH_FOLDER}:/media

  redis:
    image: redis:alpine
    restart: unless-stopped
    volumes:
      - ./data/redis:/data

  weserv:
    image: maffinca69/weserv-arm64
    restart: unless-stopped
    ports:
      - "${WESERV_PORT}:80"
    shm_size: '1GB'

maffinca69/weserv-arm64 - image for my mac (arm) without changes

curl --output te2.jpg http://server:81/media/image.png
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 16.9M  100 16.9M    0     0   320M      0 --:--:-- --:--:-- --:--:--  326M
image
andrieslouw commented 10 months ago

Could it be that the issue is due to IPv6? Is the result different if you pass the -6 flag to curl? Otherwise I suspect some DNS issue, might be that the resolver in the nginx config does not know how to resolve server.

maffinca69 commented 10 months ago

I disabled ipv6 listening in all nginx config files, but that didn't help. I also disabled google and open-dns servers by commenting out resolver in the configuration files I tried setting ipv6only=off, but that didn't help either Even with seemingly disabled ipv6 curl with option -6 gives the following: Could not resolve host: server

i can rename my server container if it's helped

UPD: response weserv:

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

So far I've solved the problem by just embedding the files I need directly into the container (everything works locally anyway) and using via /static This is probably even better since everything works locally

kleisauke commented 10 months ago

I think you could make it work by setting the DNS resolver to Docker's embedded DNS server within the nginx configuration, see: https://github.com/weserv/images/issues/206#issuecomment-1752740666.

But indeed, using the weserv filter mode (available on /static) is probably a better solution for this.

kleisauke commented 8 months ago

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