I have my FastAPI server deployed on AWS EC2 and I am using Nginx as reverse proxy. Also, I am using uvicorm to start fastapi server.
When I sent requests from localhost, it successfully send the response to all the endpoint, even if they take more than a minute to respond.
However, when I send a request from front end deployed on vercel, it does give responses for endpoints which do not take a lot of time to respond. But, it gives 502 error exactly after 35s, for the endpoint which takes about a minute to respond.
When I used ngrok server and sent request from vercel front end, it successfully responded to all the endpoints. This confirms that the issue is at the ngnix end, not at vercel or fastapi end.
This is my nginx config file which is at /etc/nginx/sites-enabled/fastapi_ngix :