cloudfront signed urls ip address

Question:

I have Signed URLs on Cloudfront working fine in PHP. Bucket policies work with HTTP referrers on S3 but because Cloudfront doesn’t support HTTP referrer checks I need to serve a file to one IP address only (the client that requested the file and generated the signed URL or my web server ideally).

Can someone please help me add the IP Address element to the JSON code so it works?

I’m lost with the PHP and Policy Statement but think it might be easy for someone who knows: http://tinyurl.com/9czr5lp

It does encoding/signing a bit differently for a custom policy: http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/private-content-creating-signed-url-custom-policy.html#private-content-custom-policy-statement

The below is an AWS example and works except not for the IP Address lock in.

I can test this very quickly if someone can please give me a hand for two minutes!

Thanks MASSIVELY for any help 🙂

Jon

Answer:


This is a valid JSON string with filled and escaped values.
If you pass the IP address as a variable make sure you escape the /

e.g.

Have a look at the php json extension
This would make things quite easier:

example statement as php array

Leave a Reply