server { # Public-facing cache server. listen 8888; server_name localhost;
# Only serve widths of 768 or 1920 so we can cache effectively. location ~ "^/img/(?<image>.+)@(?<width>\d+)-(?<height>\d+)$" { # Proxy to internal image resizing server. proxy_pass http://localhost:8088/img/$image@$width-$height; proxy_cache images; proxy_cache_valid 200 24h; }
location /img { # Nginx needs you to manually define DNS resolution when using # variables in proxy_pass. Creating this dummy location avoids that. # The error is: "no resolver defined to resolve localhost". proxy_pass http://localhost:8088/; } } }