webp-sh / webp_server_go

Go version of WebP Server. A tool that will serve your JPG/PNG/BMP/SVGs as WebP/AVIF format with compression, on-the-fly.

Home Page:https://docs.webp.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't get webp_server_go work

greenhost87 opened this issue · comments

Describe the bug

any requests ends with: Empty reply from server

curl -H 'Host: test.mydomain.com' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7'  http://127.0.0.1:3333/image/thumbnail/0000120d-0ce3-4daa-b8e1-f460d88e0fb7.jpg -v

To Reproduce
Steps to reproduce the behavior

Expected behavior
Everything work

Environment (please complete the following information):

  • OS: Ubuntu
  • version 0.9.11

Additional context

Docker run command:

docker run -d -p 3333:3333 -v /opt/data/webp/config.json:/etc/config.json -v /opt/data/webp/exhaust:/opt/exhaust -v /opt/data/webp/metadata:/opt/metadata --name webp-server webpsh/webp-server-go

My configuration

{
  "HOST": "127.0.0.1",
  "PORT": "3333",
  "QUALITY": "80",
  "IMG_PATH": "/opt/pics",
   "IMG_MAP": {
    "http://test.mydomain.com/image": "https://test-media.ams3.digitaloceanspaces.com/image"
  },
  "EXHAUST_PATH": "/opt/exhaust",
  "ALLOWED_TYPES": ["jpg","png","jpeg","bmp","gif","svg"],
  "ENABLE_EXTRA_PARAMS": true
}

Also I try "http://test.mydomain.com": "https://test-media.ams3.digitaloceanspaces.com" as part of IMG_MAP

Thanks for feedback, could you add some more details about this issue:

  • What's your original image address, is it https://test-media.ams3.digitaloceanspaces.com/image/thumbnail/0000120d-0ce3-4daa-b8e1-f460d88e0fb7.jpg ?
  • What are the logs from WebP Server Go after executing cURL command.

@n0vad3v

  • I upload image to another bucket

  • In docker logs I have only two lines

time="2023-09-26 15:08:33" level=info msg="WebP Server Go ready." func="[46:main.setupLogger]"
WebP Server Go is Running on http://127.0.0.1:3333

Current config

{
  "HOST": "127.0.0.1",
  "PORT": "3333",
  "QUALITY": "80",
  "IMG_PATH": "/opt/pics",
   "IMG_MAP": {
    "http://test.mydomain.com": "https://bf-test-media.ams3.digitaloceanspaces.com"
  },
  "EXHAUST_PATH": "/opt/exhaust",
  "ALLOWED_TYPES": ["jpg","png","jpeg","bmp","gif","svg"],
"ENABLE_EXTRA_PARAMS": true
}

My curl that I run on docker host:
curl -H 'Host: test.mydomain.com' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7' http://127.0.0.1:3333/image/thumbnail/0000120d-0ce3-4daa-b8e1-f460d88e0fb7.jpg -v

Curl response is

*   Trying 127.0.0.1:3333...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 3333 (#0)
> GET /image/thumbnail/0000120d-0ce3-4daa-b8e1-f460d88e0fb7.jpg HTTP/1.1
> Host: test.mydomain.com
> User-Agent: curl/7.68.0
> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
>
* Empty reply from server
* Connection #0 to host 127.0.0.1 left intact
curl: (52) Empty reply from server

Oh, I think I got the reason!

Your config is written "HOST": "127.0.0.1", , thus WebP Server is listening on http://127.0.0.1:3333 inside your container, thus it's not able to serve requests from outside of the container.

You should change "HOST": "127.0.0.1", to "HOST": "0.0.0.0",.

I've tested and it's working after changing HOST.

curl -H 'Host: test.mydomain.com' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7'  http://127.0.0.1:3333/image/thumbnail/0000120d-0ce3-4daa-b8e1-f460d88e0fb7.jpg
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: <FILE>" to save to a file.

Logs from WebP Server Go:

time="2023-09-26 15:35:56" level=info msg="Remote Addr is https://bf-test-media.ams3.digitaloceanspaces.com/image/thumbnail/0000120d-0ce3-4daa-b8e1-f460d88e0fb7.jpg, pinging for info..." func="[81:webp_server_go/handler.fetchRemoteImg]"
time="2023-09-26 15:35:57" level=warning msg="can't read metadata: open metadata/bf-test-media.ams3.digitaloceanspaces.com/16da62fb3a2c526b.json: no such file or directory" func="[36:webp_server_go/helper.ReadMetadata]"
time="2023-09-26 15:35:57" level=info msg="Remote file not found in remote-raw, re-fetching..." func="[88:webp_server_go/handler.fetchRemoteImg]"
time="2023-09-26 15:35:58" level=info msg="WebP@80%: remote-raw/bf-test-media.ams3.digitaloceanspaces.com/16da62fb3a2c526b->/opt/exhaust/bf-test-media.ams3.digitaloceanspaces.com/16da62fb3a2c526b.webp 87721->47028 53.61% deflated" func="[295:webp_server_go/encoder.convertLog]"
time="2023-09-26 15:35:58" level=warning msg="/opt/exhaust/bf-test-media.ams3.digitaloceanspaces.com/16da62fb3a2c526b.avif not found on filesystem" func="[174:webp_server_go/helper.FindSmallestFiles]"
 - [2023-09-26 15:35:56] GET /image/thumbnail/0000120d-0ce3-4daa-b8e1-f460d88e0fb7.jpg 200  curl/8.0.1

@n0vad3v Yes, now it work's... but I have no idea how to figure that out without your help

No problem 😉, I've also updated documentation (webp-sh/docs.webp.sh@ac53f80) to make it clearer for users to read.