在我进入它之前,我已经查看了我能找到的每个类似问题,并且我发现没有解决我的问题.
我正在运行2个docker容器,1个用于nginx,1个用于nodejs api.我使用nginx作为反向代理.
当我请求localhost/api/x时,我收到一个502坏网关和nginx日志
nginx_1 | 2015/08/15 15:30:30 [error] 9#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: X.X.X.X, server: _, request: "GET /api/x HTTP/1.1", upstream: "http://127.0.0.1:8543/x", host: "localhost"
Run Code Online (Sandbox Code Playgroud)
我能够在我的计算机上使用docker ps获取8543映射到的端口,并且可以在那里访问应用程序.这使我得出节点应用程序正在运行并监听正确端口的结论(8543).我还能够从错误消息和重写日志中判断出请求uri正在被正确地重写.
我一直在反对这个问题,并且无法弄清楚什么是错的,任何帮助都将不胜感激!
我的nginx.conf:
user nginx nginx;
worker_processes auto;
worker_rlimit_nofile 8192;
events {
worker_connections 8000;
}
error_log /dev/stderr notice;
pid /var/run/nginx.pid;
http {
# Hide nginx version
server_tokens off;
rewrite_log on;
# mime types
include mime.types;
default_type application/octet-stream;
# Update charset_types due to updated mime.types
charset_types text/xml text/plain …Run Code Online (Sandbox Code Playgroud)