Open kadamwhite opened 4 years ago
Yeah as you say, Tachyon is accessed directly and nginx does not handle 404s for those requests. It could be configured with details for the live S3 bucket and given appropriate credentials but would need to handle image paths that aren't served by Tachyon as well.
I'm not keen on being able to upload or interact with media files on cloud stacks, I think it should be read-only as a fallback from the local environment, unless you really know what you are doing.
We could explore having a composer.json
config setting for the fallback URL for uploads, and then seeing if it's possible to route 404s to nginx via traefik.
I think it only supports modifying incoming requests but there's a traefik errors middleware that allows for routing error pages to another service. That might let us route errors to nginx.
Alternatively we'll have to look more seriously at moving to something like Caddy which I think can do response modification, or a Caddy / Traefik combo.
💥 adding the following labels to the tachyon container worked for redirecting 404s to the nginx container:
- "traefik.frontend.errors.tachyon.status=400-499"
- "traefik.frontend.errors.tachyon.backend=nginx"
- "traefik.frontend.errors.tachyon.query=/tachyon-{status}.html"
I think we perhaps still need #159 first but this approach certainly has legs.
Raises a further question about adding support for custom error pages on our production stacks too 🤔
WP VIP's lando-based environment has a media proxy option which does what we've been describing here: https://docs.wpvip.com/how-tos/dev-env-add-media/#h-proxy-media-files
Describe the solution you'd likec
In Chassis we recently implemented a
media_fallback
extension, which adds an nginx config file to try loading media from another fallback host (e.g. a staging environment) if the file does not exist within the local VM:This is really useful, because it means the database itself is the only thing you need to download and import when setting up your Chassis VM — media and images can be ignored, and your local will magically work by downloading the images from the staging site instead of your local.
To speed up local-server setup times for Altis projects, and to reduce the amount of exported data that has to live on your local machine, I propose we document how to do something like this in Altis, as well.
I assume that given Tachyon, this may be more a matter of re-pointing to actual S3 buckets or something, rather than strictly nginx-rewriting ourselves to use production. But I'm not entirely clear on what the solution would look like, so I'm opening this to track a discussion.
Per @roborourke,