Re: Nginx upstream return name instead of server ip

2021-09-29 Thread rjvbzeoibvpzie
Got it!
Thanks.

Posted at Nginx Forum: 
https://forum.nginx.org/read.php?2,292491,292502#msg-292502

___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx


Re: Nginx upstream return name instead of server ip

2021-09-29 Thread Maxim Dounin
Hello!

On Wed, Sep 29, 2021 at 10:41:20AM -0400, rjvbzeoibvpzie wrote:

> You are right, those lines are logged (i've forced upstreams to fail by
> stopping them).
> 
> But i can't see such problem using "proxy_pass http://127.0.0.1:81; instead
> of "proxy_pass http://http_backend; (no more 502 errors).
> 
> Strange...

That's because max_fails/fail_timeout are not used when only one 
server is available in an upstream group, and "no live upstreams" 
errors cannot happen.

-- 
Maxim Dounin
http://mdounin.ru/
___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx


Re: Nginx upstream return name instead of server ip

2021-09-29 Thread rjvbzeoibvpzie
You are right, those lines are logged (i've forced upstreams to fail by
stopping them).

But i can't see such problem using "proxy_pass http://127.0.0.1:81; instead
of "proxy_pass http://http_backend; (no more 502 errors).

Strange...

Posted at Nginx Forum: 
https://forum.nginx.org/read.php?2,292491,292498#msg-292498

___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx


Re: Nginx upstream return name instead of server ip

2021-09-29 Thread Maxim Dounin
Hello!

On Wed, Sep 29, 2021 at 09:43:54AM -0400, rjvbzeoibvpzie wrote:

> Well, I was just assuming that no live upstreams were availbale, but this is
> not the case. At least, this is not logged (access or error).

The "no live upstreams" error is expected to be logged to the 
error log at the "error" level.  If you don't see it in the error 
log, check your logging configuration.

-- 
Maxim Dounin
http://mdounin.ru/
___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx


Re: Nginx upstream return name instead of server ip

2021-09-29 Thread rjvbzeoibvpzie
Well, I was just assuming that no live upstreams were availbale, but this is
not the case. At least, this is not logged (access or error).

Here are the lines from access_log i'm talking about (see the difference on
$upstream_addr):


log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
  '$status $body_bytes_sent "$http_referer" '
  '"$http_user_agent" "$http_x_forwarded_for" '
  '$request_length $request_time '
  '"$upstream_addr" "$upstream_response_length"
"time=$upstream_response_time" "$host" "$limit_req_status"';



208.115.199.18 - - [29/Sep/2021:12:42:43 +0200] "GET /login HTTP/1.1" 200
150 "https://example.com; "Mozilla/5.0+(compatible; UptimeRobot/2.0;
http://www.uptimerobot.com/)" "-" 408 0.105 "127.0.0.1:81" "0" "time=0.000"
"example.com" "PASSED"



208.115.199.18 - - [29/Sep/2021:12:43:35 +0200] "GET /login HTTP/1.1" 502
150 "https://example.com; "Mozilla/5.0+(compatible; UptimeRobot/2.0;
http://www.uptimerobot.com/)" "-" 408 0.000 "http_backend" "0" "time=0.000"
"example.com" "PASSED"


Posted at Nginx Forum: 
https://forum.nginx.org/read.php?2,292491,292494#msg-292494

___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx


Re: Nginx upstream return name instead of server ip

2021-09-29 Thread Maxim Dounin
Hello!

On Wed, Sep 29, 2021 at 09:20:20AM -0400, rjvbzeoibvpzie wrote:

> Here is my config:
> 
> -
> upstream http_backend {
> server 127.0.0.1:81;
> server 10.1.1.2 backup;
> }
> 
> server {
> ...
> 
> location /http/ {
> proxy_pass http://http_backend;
> ...
> }
> }
> -
> 
> As long as everything is working, $upstream_addr returns the IP
> (127.0.0.1:81). But when any backend returns HTTP/502, $upstream_addr
> returns the upstream name (http_backend) as the $upstream_addr.
> 
> Shouldn't this return the lastest server IP tried before failure?

The upstream name can be seen in $upstream_addr as long as nginx 
is not able to select an upstream server because all servers are 
not available per max_fails/fail_timeout.  The "no live upstreams" 
error is logged at the same time.

-- 
Maxim Dounin
http://mdounin.ru/
___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx