Skip to content

Instantly share code, notes, and snippets.

@kovshenin
Last active February 10, 2022 12:31
Show Gist options
  • Save kovshenin/aba39a991a4fc9fdff817b13592e3828 to your computer and use it in GitHub Desktop.
Save kovshenin/aba39a991a4fc9fdff817b13592e3828 to your computer and use it in GitHub Desktop.
# Inside the server {} block
location @imgproxy {
proxy_ssl_server_name on;
proxy_ssl_name imgproxy.ondigitalocean.app;
proxy_set_header Host imgproxy.ondigitalocean.app;
proxy_set_header If-Modified-Since "";
proxy_set_header ETag "";
proxy_set_header Cache-Control "";
proxy_ignore_headers Cache-Control;
proxy_ignore_headers Set-Cookie;
proxy_ignore_headers Expires;
proxy_ignore_headers X-Accel-Expires;
proxy_cache_key $scheme$proxy_host$request_uri$webp_suffix;
proxy_cache imgproxy;
proxy_pass https://imgproxy.ondigitalocean.app:443;
rewrite ^.+$ /insecure/plain/$scheme://$http_host$uri$webp_suffix break;
}
location ~ \.(jpe?g|png|webp|avif|gif|ico|svg|heic|bmp|tiff) {
error_page 418 = @imgproxy;
recursive_error_pages on;
if ( !-f $request_filename ) {
break;
}
add_header Vary Accept;
# Avoid recursive requests.
if ( $imgproxy != 1 ) {
return 418;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment