Welcome! Log In Create A New Profile

Advanced

Re: input required on proxy_next_upstream

February 21, 2017 04:45AM
Thanks Francis! I was able to test that above works.

But problem is when we have proxy buffering off and when we try to send large file say 1gb, it fails with 502 without trying next instance.
proxy_request_buffering off;
proxy_http_version 1.1;

Docs say so, http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_request_buffering
"When buffering is disabled, the request body is sent to the proxied server immediately as it is received. In this case, the request cannot be passed to the next server if nginx already started sending the request body."

Problem is we want best of both worlds, proxy buffering to be off so it works like streaming and some way to try next instance on 503 from first instance.

Any suggestions? May be is there a way where nginx can expect-100 from upstream before starting to send data to it, so if expect-100 fails, it can try next instance without losing data already sent otherwise?


Here is the error with nginx.conf and command where it fails

nginx.conf
http {
client_max_body_size 5G;

upstream local {
server 127.0.0.2:8008;
server 127.0.0.2:8009;
}

server {
listen 80;
location / {
proxy_pass http://local;
proxy_next_upstream error timeout invalid_header http_502 http_503 http_504;
proxy_http_version 1.1;
proxy_request_buffering off;
}
}

server {
listen 8008;
access_log /var/log/nginx/503.log combined;
return 503;
}

server {
listen 8009;
access_log /var/log/nginx/200.log combined;
return 200 "Got $request on port 8009\n";
}
}


$ cat 1gb.img | curl -H "Expect:" -v -T - http://127.0.0.1/one

* About to connect() to 127.0.0.1 port 80 (#0)
* Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 80 (#0)
> PUT /one HTTP/1.1
> User-Agent: curl/7.29.0
> Host: 127.0.0.1
> Accept: */*
> Transfer-Encoding: chunked
>
< HTTP/1.1 502 Bad Gateway
< Server: nginx/1.9.15
< Date: Tue, 21 Feb 2017 09:23:09 GMT
< Content-Type: text/html
< Content-Length: 173
< Connection: keep-alive
* HTTP error before end of send, stop sending
<
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.9.15</center>
</body>
</html>
* Closing connection 0
Subject Author Posted

input required on proxy_next_upstream

kaustubh February 15, 2017 12:18PM

Re: input required on proxy_next_upstream

kaustubh February 17, 2017 09:10AM

Re: input required on proxy_next_upstream

Igor A. Ippolitov February 17, 2017 04:12PM

Re: input required on proxy_next_upstream

kaustubh February 17, 2017 11:29PM

Re: input required on proxy_next_upstream

Francis Daly February 18, 2017 05:46AM

Re: input required on proxy_next_upstream

kaustubh February 21, 2017 04:45AM

Re: input required on proxy_next_upstream

Francis Daly February 21, 2017 03:20PM

Re: input required on proxy_next_upstream

kaustubh February 22, 2017 11:55AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 324
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready