Skip to content

Commit 218bc6d

Browse files
committed
Add the latest environment variables from the upstream
1 parent 0d0bbe8 commit 218bc6d

File tree

6 files changed

+334
-120
lines changed

6 files changed

+334
-120
lines changed

.vscode/conf2doc.sh

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
BASE=$(dirname $0)
44
README=$BASE/../README.md
5-
# PATH="/opt/homebrew/opt/grep/libexec/gnubin:$PATH"
5+
PATH="/opt/homebrew/opt/grep/libexec/gnubin:$PATH"
66

77
USAGE="$(
88
grep -aPzo --color=never \

README.md

Lines changed: 102 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,53 +16,74 @@
1616
![docker-imgproxy](www/project.jpg)
1717

1818
- **Author**: Mai Nhut Tan <[email protected]>
19-
- **Copyright**: 2021-2023 SHIN Company <https://code.shin.company/docker-imgproxy#readme>
19+
- **Copyright**: 2021-2024 SHIN Company <https://code.shin.company/docker-imgproxy#readme>
2020

2121

2222
## Support my activities
2323

24-
If you like this repository, please hit the star button to follow further updates, or buy me a coffee 😉.
25-
26-
[![Donate via PayPal](https://img.shields.io/badge/Donate-Paypal-blue)](https://www.paypal.me/shinsenter) [![Become a sponsor](https://img.shields.io/badge/Donate-Patreon-orange)](https://www.patreon.com/appseeds) [![Become a stargazer](https://img.shields.io/badge/Support-Stargazer-yellow)](https://github.com/shinsenter/docker-imgproxy/stargazers) [![Report an issue](https://img.shields.io/badge/Support-Issues-green)](https://github.com/shinsenter/docker-imgproxy/discussions/new)
27-
28-
I really appreciate your love and supports.
24+
If you find this project useful, consider donating via [PayPal](https://www.paypal.me/shinsenter) or open an issue on [Github](https://github.com/shinsenter/docker-imgproxy/discussions/new/choose). Your support helps keep this project maintained and improved for the community.
2925

3026

3127
---
3228

3329

3430
## Why it's good
3531

36-
- Just download this project and run <sup>`(*)`</sup>.
37-
- Fast on-the-fly generating thumbnails thanks to `imgproxy`.
38-
- High availability and performance thanks to Nginx content caching.
39-
- Forget troubles of [Image URL signature](https://docs.imgproxy.net/configuration?id=url-signature), but still ensure the security of the service.
40-
- Easily serve local files as well as from other origin servers.
41-
- Flexible in customizing SEO-friendly URLs without exposing `imgproxy` options (which are long and hard to remember).
42-
- Flexible in selecting origin server for the request <sup>`(**)`</sup>.
43-
- Flexible in creating your own image presets for any request.
44-
- Flexible in serving fallback image when the source file is not available.
45-
- Easy SSL configuration (with your own certificates) with built-in HTTP/2 support.
46-
- Automatically detect and convert images to WebP or AVIF format if the browser supports.
47-
48-
<sup>`(*)` using Docker Compose.</sup>
49-
<sup>`(**)` which is [supported by imgproxy](#supported-origin-servers).</sup>
32+
Experience the ultimate in efficient image delivery with our cutting-edge solution:
33+
34+
- Lightning-fast on-the-fly thumbnail generation powered by [`imgproxy`](https://imgproxy.net).
35+
- High availability and unparalleled performance thanks to Nginx content caching.
36+
- Bid farewell to [URL signature](https://docs.imgproxy.net/usage/signing_url#configuring-url-signature) management hassles while maintaining top-notch security.
37+
- Effortless serving of local files or remote server content.
38+
- SEO-friendly URL crafting without exposing [complex `imgproxy` options](https://docs.imgproxy.net/usage/processing).
39+
- Unmatched flexibility:
40+
- Customize image presets for any request.
41+
- Dynamic origin server selection.
42+
- Graceful fallback image handling for unavailable sources.
43+
- Hassle-free SSL configuration with built-in HTTP/2 support for blazing-fast load times.
44+
- Intelligent image format conversion to WebP (or AVIF) for browser compatibility.
45+
- Seamless visual experience across devices.
46+
47+
Unleash the power of our cutting-edge solution and take your project to new heights with efficient image delivery.
5048

5149
---
5250

5351

5452
## Getting started
5553

54+
### Pull this project from Github
55+
56+
Please run the below command to download the project to your local machine:
57+
58+
```shell
59+
git clone https://github.com/shinsenter/docker-imgproxy.git docker-imgproxy
60+
```
61+
62+
Or:
63+
64+
```shell
65+
curl -skL https://github.com/shinsenter/docker-imgproxy/archive/refs/heads/main.zip -o docker-imgproxy.zip && unzip docker-imgproxy.zip
66+
rm -f docker-imgproxy.zip
67+
mv docker-imgproxy-main docker-imgproxy
68+
```
69+
5670
### Prepare your files
5771

58-
Please put your files to be served in the folder `www/`.
72+
Change your working directory to downloaded directory in the above step.
73+
74+
```shell
75+
cd docker-imgproxy
76+
```
77+
78+
Then put your image files to be served to the folder `www/`.
5979

6080
There are some sample files available (a sample image `cacti.jpg`, a watermark, and some fallback images).
6181

6282

6383
### Start the server
6484

65-
```bash
85+
```shell
86+
cd docker-imgproxy
6687
docker-compose up -d --build --remove-orphans --force-recreate
6788
```
6889

@@ -111,6 +132,14 @@ I already created some preset names, such as `_thumb` or `_w200`, and I add pres
111132
> http://localhost/_square/cacti.jpg
112133
113134

135+
> The image with preset `_masked` applied.<br/>
136+
> http://localhost/_masked/cacti.jpg
137+
138+
139+
> Or just to download the image (with filters applied).<br/>
140+
> http://localhost/_download/cacti.jpg
141+
142+
114143
See [my configurations](#advanced-settings) to know how it works.
115144

116145

@@ -148,6 +177,14 @@ With the same presets as above examples, we are going to serve an image [by NASA
148177
> http://localhost/@nasa/_square/40368_PIA22228.jpg
149178
150179

180+
> The image with preset `_masked` applied.<br/>
181+
> http://localhost/@nasa/_masked/40368_PIA22228.jpg
182+
183+
184+
> Or just to download the image (with filters applied).<br/>
185+
> http://localhost/@nasa/_download/40368_PIA22228.jpg
186+
187+
151188
#### Supported origin servers
152189

153190
This setup serve images from other public origin servers, as well as from Amazon S3 buckets, Google Cloud and Azure Blob.
@@ -225,7 +262,7 @@ curl -Isk 'http://localhost/_small/cacti.jpg?debug=1'
225262
HTTP/1.1 200 OK
226263
Server: nginx
227264
Content-Type: image/webp
228-
X-Debug: /unsafe/size:320:320:0:0/sharpen:0.3/preset:logo/plain/local:///cacti.jpg@webp
265+
X-Debug: /unsafe/size:320:320:0:0/sharpen:0.3/preset:logo/dpr:1/plain/local:///cacti.jpg
229266
```
230267

231268
Example 2 (remote file with preset `_w640`):
@@ -235,7 +272,7 @@ curl -Isk 'http://localhost/@nasa/_w640/40368_PIA22228.jpg?debug=1'
235272
HTTP/1.1 200 OK
236273
Server: nginx
237274
Content-Type: image/webp
238-
X-Debug: /unsafe/size:640:0:0:0/preset:logo/plain/https://mars.nasa.gov/system/downloadable_items/40368_PIA22228.jpg@webp
275+
X-Debug: /unsafe/size:640:0:0:0/preset:logo/dpr:1/plain/https://mars.nasa.gov/system/downloadable_items/40368_PIA22228.jpg
239276
```
240277

241278

@@ -260,15 +297,18 @@ We can use these URL query components to modify some requests.
260297

261298
> `skip=1`<br/>
262299
> Skip imgproxy processing for current request. The original file will be served.<br/>
263-
> E.g. http://localhost/cacti.jpg?skip=1
300+
> E.g. http://localhost/_small/cacti.jpg?skip=1 <br/>
301+
> E.g. http://localhost/@nasa/_small/40368_PIA22228.jpg?skip=1
264302
265303
> `nocache=1`<br/>
266304
> Disable Nginx caching for current request. The response will not be saved to a cache.<br/>
267-
> E.g. http://localhost/cacti.jpg?nocache=1
305+
> E.g. http://localhost/cacti.jpg?nocache=1 <br/>
306+
> E.g. http://localhost/@nasa/40368_PIA22228.jpg?nocache=1
268307
269308
> `bypass=1`<br/>
270309
> By pass Nginx caching for current request. The response will not be taken from a cache.<br/>
271-
> E.g. http://localhost/cacti.jpg?bypass=1
310+
> E.g. http://localhost/_small/cacti.jpg?bypass=1 <br/>
311+
> E.g. http://localhost/@nasa/_small/40368_PIA22228.jpg?bypass=1
272312
273313
If you like this setup, please [support my works](#support-my-activities) 😉.
274314

@@ -297,16 +337,16 @@ Then run the command in the [Start the server](#start-the-server) section to rec
297337

298338
### Serving files from private storage
299339

300-
Please uncomment settings in `docker-compose.yml` file to enable serving files from [Amazon S3 buckets](docker-compose.yml#L101~L107), [Google Cloud](docker-compose.yml#L109~L112) or [Azure Blob](docker-compose.yml#L114~L119). Then run the command in the [Start the server](#start-the-server) section to recreate and restart the service.
340+
Please uncomment settings in `docker-compose.yml` file to enable serving files from [Amazon S3 buckets](docker-compose.yml#L179~L184), [Google Cloud](docker-compose.yml#L186~L189) or [Azure Blob](docker-compose.yml#L191~L196), etc. Then run the command in the [Start the server](#start-the-server) section to recreate and restart the service.
301341

302-
You can find more details on [imgproxy documentation](https://docs.imgproxy.net/configuration?id=serving-files-from-amazon-s3).
342+
You can find more details on [imgproxy documentation](https://docs.imgproxy.net/configuration/options?#image-sources).
303343

304344

305345
### Flushing cache files
306346

307347
Just remove the folder `cache/`.
308348

309-
```bash
349+
```shell
310350
rm -rf cache/
311351
```
312352

@@ -315,7 +355,7 @@ Then run the command in the [Start the server](#start-the-server) section to res
315355

316356
### Advanced settings
317357

318-
All settings for handling image URLs are written in the [`imgproxy.conf`](imgproxy.conf#L70~L250) file using [Nginx's map directives](https://Nginx.org/en/docs/http/ngx_http_map_module.html#directives).
358+
All settings for handling image URLs are written in the [`imgproxy.conf`](imgproxy.conf#L70~L270) file using [Nginx's map directives](https://Nginx.org/en/docs/http/ngx_http_map_module.html#directives).
319359

320360
I keep all configurations in very simple variables. You can also make your own version from this base.
321361

@@ -405,17 +445,19 @@ I keep all configurations in very simple variables. You can also make your own v
405445
> ```nginx
406446
> map $preset_name $imgproxy_preset
407447
> {
408-
> default 'size:1600:0:0:0/preset:logo';
448+
> default 'size:1600:0:0:0/preset:logo'; # preset:logo adds watermark to the image
409449
>
410450
> # Dynamic preset
411451
> ~^max_w:(?<width>[0-9]+)$ 'size:${width}:0:0:0/preset:logo';
412452
>
413453
> # Static presets
414-
> blurry 'size:320:320:1:0/blur:10/quality:50';
415-
> small 'size:320:320:0:0/sharpen:0.3/preset:logo';
416-
> medium 'size:640:640:0:0/preset:logo';
417-
> thumb 'size:160:160:1:1/bg:ffffff/resizing_type:fill/sharpen:0.3';
418-
> square 'size:500:500:0:1/bg:ffffff/resizing_type:fill/preset:center_logo';
454+
> blurry 'size:320:320:1:0/blur:10/quality:50';
455+
> small 'size:320:320:0:0/sharpen:0.3/preset:logo';
456+
> medium 'size:640:640:0:0/preset:logo';
457+
> thumb 'size:160:160:1:1/bg:ffffff/resizing_type:fill/sharpen:0.3';
458+
> square 'size:500:500:0:1/bg:ffffff/resizing_type:fill/preset:logo';
459+
> masked 'size:500:0:0:1/bg:ffffff/resizing_type:fill/preset:repeated_logo';
460+
> download 'size:1600:0:0:0/preset:logo/return_attachment:1';
419461
> }
420462
> ```
421463
@@ -459,14 +501,34 @@ I keep all configurations in very simple variables. You can also make your own v
459501
> ```
460502
461503
504+
> **`$imgproxy_dpr` (controlling photo dimensions, aka Device Pixel Ratio)**<br/>
505+
> This will multiplying the image dimensions according to this factor for HiDPI (Retina) devices.
506+
> ```nginx
507+
> map $http_user_agent@$http_dpr $imgproxy_dpr
508+
> {
509+
> default '/dpr:1';
510+
>
511+
> # parse from DPR header
512+
> ~@(?<dpr>[1-4]) '/dpr:${dpr}';
513+
>
514+
> # Put your rewrite rules for DPR settings from here.
515+
> #> E.g. these lines will set custom DPR for smartphones.
516+
> # ~iPhone|iPad|Mac '/dpr:3';
517+
> # ~Android '/dpr:2';
518+
> }
519+
> ```
520+
521+
462522
> **`$imgproxy_extension`**<br/>
463523
> Detect WebP or AVIF supports from the request header `Accept`.
464524
> ```nginx
465525
> map $http_accept $imgproxy_extension
466526
> {
467527
> default '';
468-
> ~*webp '@webp';
469-
> ~*avif '@avif';
528+
>
529+
> # uncomment this lines to enable WebP or AVIF compression
530+
> # ~*webp '@webp';
531+
> # ~*avif '@avif';
470532
> }
471533
> ```
472534
@@ -477,7 +539,7 @@ I keep all configurations in very simple variables. You can also make your own v
477539
> ```nginx
478540
> map $arg_skip $imgproxy_options
479541
> {
480-
> default '/unsafe/${imgproxy_preset}${imgproxy_preset_query}${imgproxy_quality}/plain/${origin_server}${origin_uri}${imgproxy_extension}';
542+
> default '/unsafe/${imgproxy_preset}${imgproxy_preset_query}${imgproxy_quality}${imgproxy_dpr}/plain/${origin_server}${origin_uri}${imgproxy_extension}';
481543
> ~.+ '/unsafe/plain/${origin_server}${origin_uri}';
482544
> }
483545
> ```

0 commit comments

Comments
 (0)