It is a seaweedfs webp convert service with docker
and golangs
.
There are two ways to construct it, either way.
docker pull yhan219/seaweedfs-webp
docker build -t yhan219/seaweedfs-webp:1.0 .
docker run -d --name seaweedfs-webp -e volumeServer="http://ip:8080" -p 18080:80 yhan219/seaweedfs-webp:1.0
the param volumeServer
is seaweedfs volume url
The service listens on port 18080 for GET requests on the path end with .webp
. Any other path suffix, returns a 404 not found status.
And then you just need add .webp
suffix with your image url.Optional,add a list of key-value request params that are passed on to the appropriate cwebp binary. Boolean values are interpreted as flag arguments (e.g.: -nostrong).
image url is:
then webp url is:
add convert param,eg:
http://ip:18080/file/96,0c6b879ca3780c.webp?q=1&nostrong=true&z=5
will have the effect of the following command-line being executed on the server:
cwebp -q 1 -nostrong -z 5 -o - -- -
In general, nginx
works better in combination.
docker build -t yhan219/seaweedfs-webp:1.0 .
docker run -d --name seaweedfs-webp -e volumeServer="http://www.xxx.com" -p 18080:80 yhan219/seaweedfs-webp:1.0
nginx config eg:
serer {
listen 80;
server_name www.xxx.com;
## ...
location /file/ {
proxy_pass http://localhost:8080/;
}
location ~* \.webp$ {
## cache
proxy_pass http://localhost:18080/;
}
}
now image url is:
and webp url is: