Static websites on Fly.io with Tigris bucket statics

We’ve added support for serving index documents for statics hosted on Tigris. With this, running a static site on us becomes a little easier. You can set this up by specifying the index document name (typically index.html) along with the statics configuration

[[statics]]
url_prefix = "/assets"
guest_path = "/site"
tigris_bucket = "mybucket"
index_document "index.html"

This will serve the index document any time a request is made to the root of the given prefix URL e.g https://example.fly.dev/assets or any of its subfolders.

P.S: To serve a static site, set the URL prefix and the guest path to the same value

3 Likes

Looks like the documentation needs a bit of updating
Fly Launch configuration (fly.toml) · Fly Docs

1 Like

I tried using this today and I’m getting a ListBucketResult on domain root instead of my index page:

my fly.toml:

app = '<snip>-site-prod'
primary_region = 'ams'

[build]

[http_service]
  internal_port = 8080
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 0
  processes = ['app']

[[vm]]
  size = 'shared-cpu-1x'

[[statics]]
url_prefix = "/"
guest_path = "/"
tigris_bucket = "<snip>-site-prod"
index_document = "index.html"

looking at the resulting machine config through Machines API, the index_document is missing:

"statics": [
  {
    "guest_path": "/",
    "url_prefix": "/",
    "tigris_bucket": "<snip>-site-prod",
    "index_document": ""
  }
],

updating the machine myself with index_document fixes the issue.

1 Like

which version of flyctl are you running? I haven’t been able to reproduce

looks like it’s working now, it must’ve been fixed sometime since my post. thanks!

1 Like