How to generate custom signed URL and signed cookies using cloud CDN, storage bucket and LB?

671 Views Asked by At

It's been two days since I have been working on generating a custom URL to access cloud storage private contents.

  • I have created CDN and load balancer to access the bucket.
  • I have a CDN IP address to access the files.

When I grant a file in storage bucket as public I can able to access using CDN IP. Example: https://<CDN IP Address>/filename.pdf

Since all are confidential files I can not make the file as public in my storage bucket, so I wanted to use custom signed URL and signed cookies to generate custom signed URL. I am following htafoya answer to generate a custom URL link. While doing so I am confused about the URL part. Which URL is should use? Is it https://<CDN IP Address>/filename.pdf and followed by ?Expires=1600316057&KeyName=demo-key&Signature=jxkWfkEZ_Jl6OKP83Cf13U-gy-e? I am getting an error 403 by using the mentioned URL. Does anybody have an idea of how to generate a custom signed URL using node js?

Update

  1. I can able to fix it by recreating everything.
  2. It is working only for one file. When trying to access the remaining files browser is throwing 403.

Update 1

I found the problem why it is not working:

  1. If any file name contains space, CDN is throwing a 403 permission issue error.

Example: Working: https://<CDN IP Address>/filename.pdf?Expires=1600316057&KeyName=demo-key&Signature=jxkWfkEZ_Jl6OKP83Cf13U-gy-e

Not Working:https://<CDN IP Address>/network architecture.pdf?Expires=1600316057&KeyName=demo-key&Signature=jxkWfkEZ_Jl6OKP83Cf13U-gy-e

Does anyone have any idea on how to resolve this?

0

There are 0 best solutions below