Serve static files directly from Tigris

Serving things with Tigris on your own domain usually requires you to go through their custom domain flow, which means that you need to allocate a second domain for your static uploads (eg: cdn.example.com). We have a new middle ground for you: Tigris bucket statics. Tigris bucket statics let you serve a path of your application with the contents of a Tigris bucket.

One of the main reasons you’d want to do this is if you are moving your uploads from something like Backblaze B2 to Tigris. With Backblaze B2 you can use a custom domain, but you have to prefix the name of your bucket to every single path, like this:

cdn.example.com/file/mybucket/path/to/object

To mount mybucket on the same path as Backblaze B2, you can use a statics definition like this:

[[statics]]
url_prefix = "/file/mybucket"
guest_path = "/"
tigris_bucket = "mybucket"

The guest_path directive also lets you change where the bucket is being served from. You can also use this for user uploads, or anything that would involve putting files in buckets. Imagine a photo upload app where the originals are stored in /orig in shashin-uploads and the optimized versions for the public are stored in /public:

[[statics]]
url_prefix = "/uploads/public"
guest_path = "/public"
tigris_bucket = "shashin-uploads"

This will serve all of the optimized public assets in /public while keeping all of the original assets away from prying eyes.

Of course, if you want, you can serve your entire app from a bucket:

[[statics]]
url_prefix = "/"
guest_path = "/"
tigris_bucket = "evilcorp_website_prod"
10 Likes

Will this be billed as outbound data from the app, or free outbound data from Tigris?

1 Like

Good point!

Any data served from Tigris bucket(s) follows the Tigris pricing policy, which is basically free egress out of Tigris as mentioned in our pricing docs.

Great, I just wanted to confirm that Fly does not add on a data egress charge when using the statics feature introduced here, as opposed to serving directly out of Tigris using a Tigris URL. Is that correct?

We still charge egress when we serve stuff, even though you won’t pay egress for us to get it out of Tigris.

To clarify, this will incur egress cost opposed to just using tigris with a custom domain?

Does each request count as a Class B (GET) request in tigris? Will we be charged for that?

Hi, I am actively exploring Tigris and I’d like to generate upload and download tokens (presigned urls) in combination with CNAMEd buckets. But when I try this I get an error. I don’t get an error when I use the global endpoint.

So my question is: is this even possible with custom domains? Or are the custom domains only meant for static file serving?

Thanks in advance.

Hi @hakoptak - this is a current known limitation that presigned URL are specific to the standard host and not CNAME(ed) host. We can prioritize this if this is a blocking issue for you - Please let us know.

Hi @jmj - thanks for following up.

Functionally it’s not a deal breaker, but it would add value to branding and trust. But for now I can work around it by just using the global endpoint. At least it’s good to know that it was not yet possible. It saves me some banging my head against the wall :wink: