502 bad gateway error displayed when switching between site pages and some times on home page but not for the first request on the home page it is only when another page redirect to it. and it happens for some javascript files
load balancing configured on two upstreams php1 php2 both are apache server.
When I checked error log i fond:
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/"
and this is load balancing server configuration
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 X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://$server_name/$uri;
proxy_cache_bypass $cookie_nocache $arg_nocache $arg_comment;
proxy_cache_bypass $http_pragma $http_authorization;
proxy_no_cache $cookie_nocache $arg_nocache $arg_comment;
proxy_no_cache $http_pragma $http_authorization;
}
}
I searched for hours and nothing helpful found my streams are up and no problems with them.