在站点页面和主页上的某些时间之间切换时显示 502 错误网关错误,但不是主页上的第一个请求,只有在另一个页面重定向到它时才会显示。它发生在一些 javascript 文件中
在两个上游配置的负载均衡 php1 php2 都是 apache 服务器。
当我检查错误日志时,我喜欢:
no live upstreams while connecting to upstream
[error] 27212#0: *314 no live upstreams while connecting to upstream, client: ip_address , server: example.com, request: "GET / HTTP/1.1", upstream: "http://example.com", host: "example.com", referrer: "http://example.com/mypages/"
Run Code Online (Sandbox Code Playgroud)
这是负载平衡服务器配置
upstream example.com {
# ip_hash;
server php01 max_fails=3 fail_timeout=15s;
server php02 max_fails=3 fail_timeout=15s;
}
server {
listen IP:80;
server_name example.com;
access_log /var/log/nginx/example.com.access;
error_log /var/log/nginx/example.com.error error;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header …
Run Code Online (Sandbox Code Playgroud) 有没有办法模拟这些错误?我为它创建了一些自定义文件,但我想确保它们显示正确。我为每个虚拟主机发送了不同的消息。
先感谢您。
我使用本指南进行了设置,它为我的 django 应用程序服务了一段时间,但是在添加新的 django 模块后,没有触及任何 nginx 或 uwsgi 配置,现在服务器导致 502 502 Bad Gateway 错误。nginx error.log 说:
*1 上游在从上游读取响应头时提前关闭连接,客户端:xxxx,服务器:blabla.com,请求:“GET / HTTP/1.1”,上游:“uwsgi://127.0.0.1:4000”,主机:“ xxx"
我很欣赏你的提示来解决这个问题。
我正在尝试将 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",上游:$
我想使用 Nginx 作为一个简单的反向代理,但如果 Nginx 背后的服务器关闭,我只是显示一个空白页面。出于某种原因,此配置没有在错误 502 上显示空白页,我不知道为什么。
user www-data;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
# multi_accept on;
}
http {
keepalive_timeout 65;
proxy_read_timeout 200;
upstream tornado {
server 127.0.0.1:8001;
}
server {
listen 80;
server_name www.something.com;
location / {
error_page 502 = @blank;
proxy_pass http://tornado;
}
location @blank {
index index.html;
root /web/blank;
}
}
}
Run Code Online (Sandbox Code Playgroud)