Rewritten backend of bandwidth-hero-proxy
Requirements:
- Have Go installed
- Have libvips 8.18.0 installed
- Have ffmpeg installed [optional. only for animation]
Install:
go install -v github.com/Yonle/go-bwhero@latest
or via an ready-to-use docker image:
docker run -d -p 8080:8080 --name bwhero yonle/bwhero
or via docker compose:
docker compose up --build
env LISTEN=localhost:8080 go-bwhero
If you want to increase libvips ConcurrencyLevel, You could change it by setting CONCURRENCY_LEVEL environment variable.
The bigger the file size, The longer it takes to process and the more CPU cycles are being used. By default, go-bwhero did not have any limit on file size.
You can set one (or two) of the following in environment variable to adjust:
IMAGESIZELIMITANIMATIONSIZELIMIT(by default, it follows IMAGESIZELIMIT. If it's "-1", Then it will completely disable animation)VIDEOSIZELIMIT(the same as above, except for thumbnailing only)
# Max image size from upstream: 50 MB
# Max animation size from upstream: 50 MB
env IMAGESIZELIMIT=50000000 ANIMATIONSIZELIMIT=50000000 go-bwhero
You will need to have ffmpeg installed in your system in order for the animation conversion to work. You can still run go-bwhero without it by disabling animation via ANIMATIONSIZELIMIT=-1.
Due to Golang's garbage cleaner nature, You might want to adjust GOMEMLIMIT, GOGC, and GOMAXPROCS environment variable, where:
GOMEMLIMIT: Heap Limit (example:512MiB)GOGC: Level of GC (example:50oroff). The less, the more aggresiveGOMAXPROCS: Maximum parallel allocations. (example:2)
Example:
env GOMEMLIMIT=512MiB GOMAXPROCS=2 GOGC=30 ./bwhero
go-bwhero's default user agent is go-bwhero [https://github.com/Yonle/bwhero], and it can be changed by overriding USER_AGENT variable.
By default, go-bwhero will redirect to the original image URL when it was found that user is opening the image in new tab. To make testing possible, You must add nr query tag in your request.
Your request should look like this:
http://localhost:8080/?url=....&nr=1