当创建一个带有nodejs的网站时。在这个网站上,我有一个可以将图像上传到服务器的页面。我在我的电脑上测试了它的工作正常。在将其部署到服务器后,它无法正常工作。我读了日志。我同时从访问和错误日志中获得了两个。NodeJS无法上传文件导致上游过早关闭连接
这是一个error.log中
upstream prematurely closed connection while reading response header from upstream , client: xx.xx.xx.xx, server: example.com, request: "POST /admin/place/thumbnanil/upload HTTP/1.1", upstream: "http://127.0.0.1:3002/admin/place/thumbnanil/upload", host: "example.com", referrer: "https://example.com/admin/place/detail"
这是一个access.log的
POST /admin/place/thumbnanil/upload HTTP/1.1" 502 583 "https://example.com/admin/place/detail"
这是我的Nginx虚拟主机
upstream example {
server 127.0.0.1:3002;
keepalive 8;
}
server {
listen 80;
server_name example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
location/{
proxy_pass http://127.0.0.1:3002;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_buffering on;
proxy_buffer_size 8k;
proxy_buffers 2048 8k;
}
}
我使用Ubuntu 14.04上AWS EC2。 的NodeJS v4.4.7
这是我使用后的网址:https://example.com/admin/place/thumbnanil/upload
你可以发布你正在使用后的完整网址? –
@AkshayKumar当然。 – Natsathorn