Skip to content

Instantly share code, notes, and snippets.

@DevWael
Created March 27, 2023 02:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DevWael/99bd8d056797c3ff58c80585e99e4fa4 to your computer and use it in GitHub Desktop.
Save DevWael/99bd8d056797c3ff58c80585e99e4fa4 to your computer and use it in GitHub Desktop.
Nginx configuration for imgproxy https://imgproxy.net/
location @imgproxy {
proxy_set_header Host localhost:8080;
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 http://localhost:8080;
expires max;
rewrite ^.+$ /insecure/plain/$scheme://$http_host$uri$webp_suffix break;
}
location ~* ^.+\.(jpe?g|png|webp|avif|gif|ico|svg|heic|bmp|tiff) {
# Redirect the 418 error to our imgproxy
error_page 418 = @imgproxy;
recursive_error_pages on;
# Abort if the requested file does not exist
if ( !-f $request_filename ) {
break;
}
# Raise a 418 error if the request is not from our proxy.
if ( $imgproxy != 1 ) {
return 418;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment