通过 systemctl 运行 haproxy 与手动运行它不同。
这是通过 systemctl 启动时的输出:
> sudo systemctl status -l haproxy.service
haproxy.service - HAProxy Load Balancer
Loaded: loaded (/usr/lib/systemd/system/haproxy.service; enabled)
Active: active (running) since Wed 2014-12-24 08:08:49 EST; 4min 59s ago
Main PID: 20307 (haproxy)
CGroup: /system.slice/haproxy.service
??20307 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid
Dec 24 08:08:49 localhost.localdomain systemd[1]: Starting HAProxy Load Balancer...
Dec 24 08:08:49 localhost.localdomain systemd[1]: Started HAProxy Load Balancer.
Run Code Online (Sandbox Code Playgroud)
像这样,haproxy 只对我的后端说 503。
如果我现在停止 haproxy 服务,而是在命令行上手动运行它,如下所示:
sudo /usr/sbin/haproxy …
Run Code Online (Sandbox Code Playgroud) 我正在尝试将 NGINX 设置为我的 NodeJS 应用程序的前端,该应用程序已上线127.0.0.1:3000
,但我无法解决此 502 错误。NGINX 可在本地访问http://55.55.55.5/
或访问http://dev.example
dev.example(文件在:/etc/nginx/sites-available 并符号链接到启用站点)
upstream up_dev.example {
server 127.0.0.1:3000;
}
server {
listen 0.0.0.0:80;
server_name dev.example example;
access_log /var/log/nginx/dev.example.log;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://up_dev.example/;
proxy_redirect off;
}
}
Run Code Online (Sandbox Code Playgroud)
错误日志
2014/09/17 19:38:26 [错误] 1679#0:*1 connect() 失败(111:连接被拒绝),同时连接到上游,客户端:55.55.55.1,服务器:,请求:“GET / HTTP/ 1.1",上游:$