node.js - 在 AWS 上的 NGINX Web 服务器上运行的 NodeJS 中无法找出 504 错误
问题描述
当我按顺序向 Facebook、Google 等第三方 API 发出 POST 请求时,我随机收到 504 错误。我无法确定导致错误的确切情况。
这是我发出 POST 请求的方式:
var options = { uri: uri,
headers: {
"Content-Type": "application/json",
},
strictSSL: true,
json: obj
};
request.post(options, function(err, response) {
});
这是我的 NGINX 配置文件:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
client_max_body_size 100M;
include /etc/nginx/mime.types;
default_type application/octet-stream;
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 /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
我在 AWS 的 2 个 EC2 实例上运行我的应用程序,并附加了一个负载均衡器。
这里可能是什么问题?
解决方案
我相信您在 http 块内缺少服务器块。使用位置块将客户端重定向到更精细调整的路线,而不仅仅是根
server {
listen 80;
listen [::]:80;
root /home/ubuntu/public_html;
server_name example-one.com www.example-one.com;
location /application1 {
proxy_pass http://localhost:8080/sampleApp;
}
location /images {
root /home/ubuntu/data;
}
}
推荐阅读
- java - Firebase - 新依赖项 - 问题:NoClassDefFoundError:解析失败(QueryListenOptions)
- python - 定义一个使用函数内部列表范围的函数
- r - 向配对图添加箭头
- spring-boot - Spring boot + spring数据依赖不起作用
- jhipster - Jhipster 用户朋友自我关系
- r - 如何使用一个变量连续填充 ggplot2 条形图
- image - 之后我安装了一个 ssl,图像滑块不起作用
- python - 如何在 setup.py 中指定括号依赖项?
- python - 忽略shell脚本中的特定文件for循环
- c# - Selenium C# ElementNotVisibleException:元素不可交互,但该元素实际上是可见的