I have a NodeJS (ExpressJS) application containerized on Docker that is exposed through an NGINX reverse proxy also containerized on Docker. Sometimes, a request sent to NGINX takes 60 seconds before being sent to the application. In my monitoring on Sentry, I see that the server responded to the request in 600ms, but on the browser the download time is 61 seconds.
Here is my Nginx configuration
worker_processes 1;
error_log /dev/stderr warn;
events {
worker_connections 1024;
}
# make sure to set plaintext JWT_SECRET environment variable
env JWT_SECRET;
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /dev/stdout main;
lua_package_path "/usr/local/openresty/lualib/?.lua;;";
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS +RC4 RC4";
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
# API
upstream application_server {
server application_server _1:3000 max_fails=1 fail_timeout=5s;
server application_server _8:3000 max_fails=1 fail_timeout=5s;
server application_server _2:3000 max_fails=1 fail_timeout=5s;
server application_server _3:3000 max_fails=1 fail_timeout=5s;
server application_server _4:3000 max_fails=1 fail_timeout=5s;
server application_server _5:3000 max_fails=1 fail_timeout=5s;
server application_server _6:3000 max_fails=1 fail_timeout=5s;
server application_server _7:3000 max_fails=1 fail_timeout=5s;
}
server {
listen 443 ssl http2;
server_name api.application.dev;
client_max_body_size 200M;
ssl_certificate /etc/letsencrypt/live/api.application.dev/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/api.application.dev/privkey.pem;
location / {
expires -1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $remote_addr;
proxy_pass http://application_server;
}
}
}
What can I do to track more this issue and fix it?