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.
https://docs.webp.sh
GNU General Public License v3.0
1.79k stars 173 forks source link

How do I configure and exclude links in MP4 format? #322

Closed zooyoyo closed 6 months ago

zooyoyo commented 6 months ago

Describe the bug {
"HOST": "0.0.0.0", "PORT": "3333", "QUALITY": "80",
"MAX_JOB_COUNT": "10",
"IMG_PATH": "http://10.0.2.189:10001",
"EXHAUST_PATH": "/home/webp_server_go/cache",
"ALLOWED_TYPES": ["jpg","png","jpeg","bmp"] } When I click on a video link, I am unable to access it properly

To Reproduce Error : sendfile: file /home/webp_server_go/cache/local/90036d54bb8e9260 not found

Expected behavior A clear and concise description of what you expected to happen.

Screenshots and logs If applicable, add screenshots and logs to help explain your problem.

Environment (please complete the following information):

Additional context Add any other context about the problem here.

n0vad3v commented 6 months ago

Thanks for reporting, as from your config, WebP Server Go is listening on port 3333, you've said "When I click on a video link", are you visiting something like http://<some_ip_or_domain>:3333/path/to/some.mp4?

Or is there any reverse proxy in front of WebP Server Go?

zooyoyo commented 6 months ago

Yes, I used nginx for proxy. My video link is similar to this: http://10.0.2.189/group1/11.mp4?name=11.mp4&download=0 Nginx configuration: location /group1 { proxy_pass http://10.0.2.189:3333; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }

n0vad3v commented 6 months ago

Great, maybe you can try proxy_pass only images to WebP Server Go(http://10.0.2.189:3333/) while other requests proxy_pass directly to your source(http://10.0.2.189:10001/), an example Nginx config might like this(I haven't tested this config so I'm not sure whether it works as intended)

location ~* ^/group1/.*\.(?:jpg|jpeg|gif|png|svg|heic|bmp|nef|webp)$ {
    proxy_pass http://10.0.2.189:3333;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location /group1/ {
    proxy_pass http://10.0.2.189:10001;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
zooyoyo commented 6 months ago

I tried it and it is correct. Currently, the link can be accessed normally; I need more tests, thank you!

n0vad3v commented 6 months ago

Glad it helps, closing this issue now, if you need more help free feel to reopen this.