I have a problem that nginx returns 501 error or 200 OK for same requests. I don't know why.
I guess nginx doesn't have enough connections for upstream.(I connect nginx and tomcat by reverse proxy. using upstream.) So it returns 501. I know it will return 502 not 501 in this case. But I think it is weird "sometimes" nginx returns 501 error for same requests. not "always". They are exactly same requests. Same url, header, and body.
So I tried to increase "keepalive_requests", "keepalive_timeout" and "keepalive"(for upstream). The frequency has been reduced but not completely eliminated.
Please help me....
access.log
10.xxx.35.46 - [24/Oct/2019:22:33:01 +0900] "GET /monitor/l7check HTTP/1.1" [-] - [501] 1120 0.001 "-" "-"
10.xxx.35.46 - [24/Oct/2019:22:33:06 +0900] "GET /monitor/l7check HTTP/1.1" [-] - [200] 31 0.002 "-" "-"
I found why tomcat returns 501! But still I don't know why it happens.
nginx access.log
10.33.xxx.xxx - [25/Oct/2019:16:21:19 +0900] "POST /ajax/test?ts=1571988079124 HTTP/1.1" [501] 1147 0.006 "https://test.com" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36"
tomcat access.log
127.0.0.1 - - [25/Oct/2019:16:21:19 +0900] "01POST /ajax/test?ts=1571988079124 HTTP/1.1" 501 1147 "https://test.com" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36"
As you can see, client requests POST method but tomcat receives 01POST method.
I try to set proxy method to request method like this.
proxy_method $request_method;
But it doesn't work. It still happens. Why does nginx(or tomcat??) change method??
error.log
? it would be better if you edited your question and post all the logs in the formatted style.