I'd like to serve static ressources such as images, js bundles, html pages... with Traefik like I was able to do with nginx
# nginx config
server {
root /www/data;
location ~ \.js {
root /www/bundles;
}
}
Many thanks Cheers
I'd like to serve static ressources such as images, js bundles, html pages... with Traefik like I was able to do with nginx
# nginx config
server {
root /www/data;
location ~ \.js {
root /www/bundles;
}
}
Many thanks Cheers
Traefik doesn't serve static files (it's a not a web server it's a reverse proxy/load balancer).
You must use a container, which contains a web server with your files.
To extend the answer related to how files can be served:
If you are already serving files with nginx and want to migrate to Traefik you can still have nginx serving static files behind Traefik. I do this myself in hobby projects running docker standalone on a VM.
The best way is probably still to use containers/buckets such as S3 or Swift for static files as it will offload the traffic to the application server and provide a single location for these files (makes things easy when clustering) .. but if you don't have a lot of traffic and use a very simple setup, the nginx way is more than fine.
The issue around static files was discussed here : https://github.com/containous/traefik/issues/4240
npm run build
on a CDN? I'm using DigitalOcean Spaces CDN. Do I literally just upload that build folder to the CDN to serve the static files and just use Traefik for the API - no Nginx? If so, how does the initial request to my server know to route to the CDN for the static files?
Sep 11 at 13:29