php - AWS - Cloudfront - How To Use Origin Custom Headers -


i'm new aws , i'm going through different training courses right , 1 of interesting things i've stumbled upon ability add custom headers in cloudfront. said, can't seem figure out (or locate simple understand documentation) how use/leverage power feature offers.

can please let me know how:

  1. how access headers set? example used terminal run basic curl commands view headers cloudfront resources , assumed custom headers there there not.
  2. i these custom headers sent origin source i'm confused how use these headers improve application/asset logic.

if matters i'm programming in php. explanations, code examples or references helpful documentation appreciated. help.

how access headers set?

"you" browser/curl user can't see them. they're private between cloudfront , origin server, sent request.

you can access them server php code getallheaders().

i'm confused how use these headers

what allow 1 of 2 things:

  • if matching header comes in on request , sent origin, don't want sent received, overwrite new value

  • if matching header doesn't come in on request, add before sending origin server.

but if don't know them, may not have need them.

some potential applications:

  • if want use signed cloudfront urls or signed cookies, can add header secret value proves web server request came cloudfront, , your cloudfront distribution, because value matches. previously, origin server had publicly accessible because there no way of verifying requests arrived through (and authorized by) cloudfront -- standard headers forged anyone, , if checked ip address of incoming request, prove "some" cloudfront distribution, not your cloudfront distribution. (a malicious user set cloudfront distro , access content if implemented naive trust scenario that). since headers , values unknown to/unseen browser, can verify header present expected value using same mechanisms in code you'd use read other incoming request header. used if wanted deny requests didn't arrive through cloudfront other reason, other authentication , access control secure content. see http://docs.aws.amazon.com/amazoncloudfront/latest/developerguide/forward-custom-headers.html#forward-custom-headers-restrict-access.

  • you use them modify cors headers on way origin. see http://docs.aws.amazon.com/amazoncloudfront/latest/developerguide/header-caching.html#header-caching-web-cors

  • you use them track of multiple cloudfront distributions request arrived through, billing purposes, if had multiple cloudfront distros pointed same origin server.

  • you use them make kind of limitation in origin server, needed see header, whatever reason, didn't want forward header, since hurt cache hit ratio -- cloudfront caches responses against entire request sent origin, including path, forwarded headers (if enabled), query string (if enabled), and/or cookies (if enabled). serve request cache if request forward origin matches 1 sent in order receive response cached (and cloudfront can cache multiple variations of same resource, based on request parameters allow forwarded through). reason cache has obligation not make assumptions how server might vary response based on different request parameters. unless 2 requests semantically equivalent, can't considered equivalent caching purposes.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -