Reputation: 47
I have an express API accessible through a nginx reverse proxy. Everything is working fine except for one handler that uses bcrypt.
My api nginx config:
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name api.dev;
ssl_certificate /root/ssl/cert.crt;
ssl_certificate_key /root/ssl/cert.key;
access_log /root/nginx_logs/api_access.log;
error_log /root/nginx_logs/api_error.log;
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_pass http://api:8880;
# Big timeout to test
proxy_connect_timeout 1200s;
proxy_send_timeout 1200s;
proxy_read_timeout 1200s;
}
}
My express handler:
try {
const hashedPassword = await bcrypt.hash(payload.password, 10);
return handlerResult.ok({});
} catch (err) {
console.error(err);
}
When I request my api on any other route it works but with this handler nginx get this error:
[error] 29#29: *27 upstream prematurely closed connection while reading response header from upstream
If I comment const hashedPassword = await bcrypt.hash(payload.password, 10);
the error dissapear.
At the begining I thought it was a timeout error but as you can see I wrote overkill timeout in nginx.
Thank you, for reading, if you have any question please ask me :)
PS: Sorry for my poor english
Upvotes: 1
Views: 3476