mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-01-08 10:45:04 +02:00
Add IMGPROXY_BASE_URL param
This commit is contained in:
parent
04871c8b7f
commit
bcd9dfe809
@ -164,6 +164,10 @@ You can also specify a secret to enable authorization with the HTTP `Authorizati
|
||||
* `IMGPROXY_QUALITY` — quality of the resulting image, percentage. Default: `80`;
|
||||
* `IMGPROXY_GZIP_COMPRESSION` — GZip compression level. Default: `5`;
|
||||
|
||||
#### Miscellaneous
|
||||
|
||||
* `IMGPROXY_BASE_URL` - base URL part which will be added to every requestsd image URL. For example, if base URL is `http://example.com/images` and `/path/to/image.png` is requested, imgproxy will download the image from `http://example.com/images/path/to/image.png`. Default: blank.
|
||||
|
||||
## Generating the URL
|
||||
|
||||
The URL should contain the signature and resize parameters, like this:
|
||||
|
@ -101,6 +101,8 @@ type config struct {
|
||||
|
||||
ETagEnabled bool
|
||||
ETagSignature []byte
|
||||
|
||||
BaseURL string
|
||||
}
|
||||
|
||||
var conf = config{
|
||||
@ -155,6 +157,8 @@ func init() {
|
||||
|
||||
boolEnvConfig(&conf.ETagEnabled, "IMGPROXY_USE_ETAG")
|
||||
|
||||
strEnvConfig(&conf.BaseURL, "IMGPROXY_BASE_URL")
|
||||
|
||||
if len(conf.Key) == 0 {
|
||||
log.Fatalln("Key is not defined")
|
||||
}
|
||||
|
@ -106,7 +106,9 @@ func readAndCheckImage(res *http.Response) ([]byte, imageType, error) {
|
||||
}
|
||||
|
||||
func downloadImage(url string) ([]byte, imageType, error) {
|
||||
res, err := downloadClient.Get(url)
|
||||
fullURL := fmt.Sprintf("%s%s", conf.BaseURL, url)
|
||||
|
||||
res, err := downloadClient.Get(fullURL)
|
||||
if err != nil {
|
||||
return nil, UNKNOWN, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user