【发布时间】:2022-01-25 04:16:13
【问题描述】:
我正在使用 pm2 为我的节点 js 应用程序提供服务。
nginx.conf 文件是
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
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 /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
#include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
在 **conf.d/** 文件夹中,我创建了如下配置文件(名称为 api.conf)
server {
listen 80;
server_name dev.xxxxxxx.com;
underscores_in_headers on;
# return 301 https://$host$request_uri;
location / {
proxy_pass http://localhost:3004/;
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;
}
}
当我停止节点应用程序 nginx server the ELB Health status is 502 并在我启动 nginx 服务器时启动然后 nginx server the ELB Health status is 404
我无法找到问题所在。谁能帮我理解和解决
即使我检查了如下的 nginx 错误日志
[02/Feb/2021:17:21:29 +0000] "GET / HTTP/1.1" 502 157 "-" "ELB-HealthChecker/2.0" "-"
[02/Feb/2021:17:21:38 +0000] "GET / HTTP/1.1" 404 60 "-" "ELB-HealthChecker/2.0" "-"
【问题讨论】:
-
应用程序是什么样的,是否有任何日志?您在应用程序运行时从 502 切换到 404 的事实意味着应用程序本身正在发回 404 错误。
-
当您 ssh 到实例并从内部卷曲它时,应用程序是否工作?问题仅在于 ELB 健康检查,还是没有任何实际作用?
-
@Marcin 是的,该应用与 http 一起工作正常,但当它与 https 一起使用时,它不工作
-
@tedivm 是的,我在问题中提到的日志相同。当我停止并重新启动 nginx 时,我收到这些 502 和 404 错误
-
你能告诉我们来自应用程序的日志,而不仅仅是来自 nginx 的日志吗?
标签: amazon-web-services nginx load-balancing amazon-elb aws-application-load-balancer