Nginx reverse proxy: upstream timed out
Hello, I have 2 services: fastAPI backend and nginx frontend serving as reverse proxy. It works fine when backend starts first and then the frontend, however in the opposite case (for example after a git push backend takes longer to start) Nginx keeps failing with
any idea why it could be happening?
7 Replies
Project ID:
N/A
Here's my nginx config:
another strange thing that I found while trying to fix it is that if I use
it doesn't work at all with
but if I replace it with
it starts to work as described above (until the backend is restarted)
@Brody 👋
so would you be opposed to ditching nginx and moving to caddy?
read the description of this template https://railway.app/template/7uDSyj and if thats something you think would suite your needs, id be happy to help you modify the caddyfile to your needs
thanks, sure, I'll give it a try.
Do you know how I can serve static files directly from the caddy container instead of proxying to another service?
Kind of what this did in Nginx
untested, but this should do the job
however, i highly recommend the 3 service approach like the example project shows
@Brody , here's what I'm getting with caddy:
and this is a config I'm using:
It shouldn't be an issue with the backend because I can acess it directly
https://backend-production-XXXX.up.railway.app/api/health
actually my bad, according to caddy docs: Upstream addresses cannot contain paths or query stringsyeah as the comments said in the original caddyfile, if your backend does have an /api/ route then you don't want the handle_path block