Skip to content

Instantly share code, notes, and snippets.

@oalders
Created February 25, 2021 15:07
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 oalders/ca0100049e91c71992e2a2d9f8f54c1f to your computer and use it in GitHub Desktop.
Save oalders/ca0100049e91c71992e2a2d9f8f54c1f to your computer and use it in GitHub Desktop.
cpan.metacpan.org nginx Fastly config
http://nginx.org/en/docs/http/request_processing.html
# nginx first searches for the most specific prefix
# location given by literal strings regardless of the
# listed order. In the example configuration the only prefix
# location is ''/'�~] and since it matches any request it will
# be used as a last resort. Then nginx checks locations
# given by regular expression in the order listed in the
# configuration file. The first matching expression stops
# the search and nginx will use this location. If no regular
# expression matches a request, then nginx uses the most
# specific prefix location found earlier.
location ~ /authors/.*/CHECKSUMS$ {
# checksum files can change with any upload
}
location ~* /authors/.*(readme|\.html|\.txt|\.[xy]ml|\.json|\.[pr]df|\.pod)(\.gz|\.bz2)?$ {
# allowed to be overwritten by authors see:
# http://pause.perl.org/pause/query?ACTION=pause_04about#upload
}
location ~ /authors/.*/$ {
# directories
autoindex on;
}
location ~ /authors/id/[^/]+$ {
# files directly in /id/
}
location ~ /authors/.*/.*$ {
# files in author directories, basically the
# other regexes are above are the exceptions for this rule
# See: https://www.fastly.com/blog/stale-while-revalidate/
add_header Surrogate-Control 'max-age=31104000, stale-while-revalidate=31104000, stale-if-error=31104000';
}
location ~ /robots.txt$ {
# robots gets requested a lot - let fastly cache
# for an hour, revalidate in the background (up to a day) and serve from cache if error revalidating
add_header Surrogate-Control 'max-age=3600, stale-while-revalidate=86400, stale-if-error=31104000';
}
location ~ /authors/ {
# anything else
autoindex on;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment