senyo
July 12, 2024, 7:49am
1
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
senyo
August 14, 2024, 9:00am
4
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
I would just like a bit more information about how it works
This feature should not be compared directly with a CDN, for the following reasons:
This feature does not exempt you from having to run a web service in your Machine.
Does that mean the static site “served directly from Tigris” still has to be routed via the machine?
If I scale my machine to zero does the “static site” become unreachable?
Can I combine this with a real CDN like Cloudflare somehow?