- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我有以下设置:
以 supervisord 作为入口点的 Docker 容器,supervisord 运行一个 Node.js 进程和 Nginx 代理。Nginx 端口暴露在外。
在主机上,另一个 Nginx 用于 SSL 终止和 vhost 路由/负载平衡,它用作 Docker 容器的代理。
我遇到了一些奇怪的问题,有时 Docker 容器内的 Nginx 服务器在连接到上游 Node.js 服务器时报告错误。似乎 HTTP 请求是 200,所以即使只有一个上游,它也可能会自动重试?!
另外,在 Node.js 进程 stdout/stderr.. 中没有错误或崩溃的迹象。
这是我看到的错误:
2014/07/31 12:48:54 [error] 15#0: *10 connect() failed (111: Connection refused) while connecting to upstream, client: 172.17.42.1, server: f074d2f4389f, request: "GET /users/me HTTP/1.1", upstream: "http://[::1]:3000/users/me", host: "xxx.xxx.com", referrer: "https://xxx.xxx.com/"
可能是什么问题?
这是 supervisord 配置文件:
[supervisord]
nodaemon=true
logfile=/var/log/supervisor/supervisord.log ; supervisord log file
logfile_maxbytes=50MB ; maximum size of logfile before rotation
logfile_backups=10 ; number of backed up logfiles
loglevel=info ; info, debug, warn, trace
pidfile=/var/run/supervisord.pid ; pidfile location
childlogdir=/var/log/supervisor/ ; where child log files will live"
并且这个文件包含在其他文件中:
[include]
files = /etc/supervisor/conf.d/supervisord.conf
[program:api]
command=node api-cluster.js
directory=/src
autorestart=true
startretries=100000000
stdout_logfile=/var/log/supervisor/api_stdout.log
stderr_logfile=/var/log/supervisor/api_stderr.log
[program:nginx]
command=/usr/sbin/nginx
autorestart=true
startretries=100000000
stdout_logfile=/var/log/supervisor/nginx_stdout.log
stderr_logfile=/var/log/supervisor/nginx_stderr.log"
这是 Docker 容器内的 Nginx conf 文件:
# -------------------------------------------------------------------
# Nginx configuraiton
# -------------------------------------------------------------------
worker_processes 4;
daemon off;
error_log stderr info;
pid /var/run/nginx.pid;
events {
#use epoll;
worker_connections 768;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main 'ip=\$http_x_real_ip [\$time_local] '
'"\$request" \$status \$body_bytes_sent "\$http_referer" '
'"\$http_user_agent"' ;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
upstream app_proxy {
server localhost:3000; # nodejs server
}
server {
listen 80 deferred;
server_name \$hostname;
access_log /dev/stdout main;
location ~ ^/(images/|img/|javascript/|js/|css/|stylesheets/|flash/|media/|static/|scripts/|views/|styles/|bower_components/|robots.txt|humans.txt|favicon.ico|home/|html|xml) {
root /src/web/public;
access_log off;
expires max;
}
location / {
proxy_redirect off;
#proxy_set_header X-Real-IP \$remote_addr;
#proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_set_header Host \$http_host;
proxy_set_header X-NginX-Proxy true;
proxy_intercept_errors off;
proxy_pass http://app_proxy/;
}
}
}
最佳答案
Nginx 在 IPv6 环回 [::1] 上连接到 nodejs。 nodejs 可能只是在监听 IPv4。
尝试设置
upstream api {
server 127.0.0.1:5000;
}
关于node.js - Nginx 连接在连接到 Docker 容器内的 Node.js 上游时被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25059691/
我有一个无所事事的盒子,已经运行了一段时间,今天,由于某种原因,当我尝试重新启动nginx时,得到了以下提示。 nginx: [emerg] host not found in upstream "w
我注意到,当我使用 ubuntu 命令“nginx”启动 nginx 并执行 systemctl status nginx 时。它表明 systemctl 已禁用。此外,如果我首先使用命令 syste
我的 nginx 配置如下: proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $re
周围有两个配置文件,/etc/nginx/conf.d/default.conf和 /etc/nginx/nginx.conf,但是启用了哪一个呢?我运行的是 CentOS6.4 和 nginx/1.
我的 Nginx 配置仅适用于根位置,所有其他位置都返回“Cannot GET {location}”,其中位置是域后地址的其余部分。 这是我的/etc/nginx/sites-enabled/def
我在 nginx 中为 node.js 服务器设置了反向代理。 server { listen 80; server_name sub.domain.tld; location
我的应用程序将在两个位置提供静态文件,一个是/my/path/project/static,另一个是/my/path/project/jsutils/static。 我很难让网络服务器在两个目录中查找
我的域名注册商的 DNS 访问我的服务器并获取 nginx 默认页面,因此配置正确 我复制了一个当前正在工作的 nginx 虚拟主机,更改了 server_name和 conf 文件的名称,仅此而已。
这个问题在这里已经有了答案: Can't login in to phpPgAdmin (2 个回答) 3年前关闭。 我在centos中遇到了phpPgAdmin登录的奇怪问题,我做了所有需要的事情
我要为PoC进行的操作是向来自动态后端服务器的网页添加href。使用“ subs_filter”可以很容易地添加href,但是我需要使用响应中嵌入的信息来构造href。 是否可以使用LUA处理来自pr
我有网站服务器,它有两个代理(鱿鱼,CF),它们使用不同的 header 来获取真实的 ip。 我猜 nginx 命令 set_real_ip_from ;real_ip_header X-Forwa
在控制台显示如下: Job for nginx.service failed because the control process exited witherror code. See "syste
我有一个问题,我怀疑是 NGINX 问题。基本上,当我尝试登录到我创建的网站时,出现以下错误…… 您要查找的页面暂时不可用。请稍后再试。 有没有人以前遇到过这个? 最佳答案 如果 NGINX 虚拟主机
这是我的 nginx 配置文件: server { listen 80; server_name localhost; location / {
在我的/etc/nginx/nginx.conf 文件中,我有配置。作为:- user nginx; worker_processes 1; error_log /var/log/nginx/e
有谁知道nginx支持软退出吗?这意味着它会一直运行直到所有连接都消失或超时(超过特定时间间隔)并且在此期间也不允许新连接吗? 例如: nginx stop nginx running (2 conn
有没有办法将 Nginx 配置为类似这样的直接服务器返回 (DSR) 负载平衡器: http://blog.haproxy.com/2011/07/29/layer-4-load-balancing-
我通过 apt-get 安装了 Nginx不久前在 Debian 上,我有几个网站在上面。现在我需要安装一些额外的模块,因为我不想搞砸任何事情,所以我想在执行之前仔细检查我的过程。希望这也能帮助其他不
我知道 Apache 的 pagespeed 模块可以使页面访问更快,所以,我想知道 Nginx 是否有等效的模块? 提前致谢! 最佳答案 https://github.com/pagespeed/n
如何将worker_rlimit_nofile设置为一个更大的数字,它可以是或建议最大为多少? 我正在尝试遵循以下建议: 大多数人遇到的第二个最大限制是 与您的操作系统有关。打开一个shell,su给
我是一名优秀的程序员,十分优秀!