【发布时间】:2022-01-11 19:51:06
【问题描述】:
我有一个使用 3005 端口运行的节点 fastify 服务器。 以及 nginx 上的反向代理,它应该代理为节点服务器提供服务。
我尝试了很多配置,但都没有成功。如果有人得到提示,那就太好了。
nginx.conf
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
upstream client {
server md_license_server:3005;
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://client;
proxy_set_header Host $host;
}
}
}
docker-compose.yml
version: "3.3"
services:
md_license_server:
image: root/md-license-server
expose:
- 3005
ports:
- 3005:3005
nginx:
image: nginx:latest
container_name: nginx
ports:
- 80:80
- 443:443
volumes:
- /etc/ssl/certs:/etc/ssl/certs
- /etc/ssl/private:/etc/ssl/private
- /root/docker/nginx.conf:/etc/nginx/nginx.conf
从浏览器测试一些端点返回:
<html>
<head>
<title>502 Bad Gateway</title>
</head>
<body>
<center>
<h1>502 Bad Gateway</h1>
</center>
<hr>
<center>nginx/1.21.4</center>
</body>
</html>
【问题讨论】:
-
您正在测试的这些端点是什么?您的测试(用于测试的命令)或邮递员或...等如何?您是否尝试绕过 nginx 并直接测试,然后通过 nginx 进行测试?如果是这样:所有这些测试的结果是什么。
-
我尝试通过在内部使用 curl 来绕过 nginx。从那里可以访问节点 js 应用程序。示例:curl 127.0.0.1:3005/ping 返回:true
标签: nginx docker-compose