I am trying to call a GET api with a parameter which has space in it:
https://abc.xyz/search/web/buildings/search/v2/city/new%20york
The endpoint hits load balancer (nginx) which redirects the request to a suitable machine.
In the response, I get 505 HTTP Version Not Supported error. But when I make the same request to the load balancer using HTTP (using internal IP), it returns the response successfully.
Here are the relevant access logs of both cases:
access log of nginx when called via http
"GET /search/web/buildings/search/v2/city/r%20c HTTP/1.1" S=200 487 T=0.005 R=- 10.140.15.199
access log of the machine when called via http
"GET /search/search/web/buildings/search/v2/city/r%20c HTTP/1.0" 200 36
The above request works fine. but when we request through https, the request in machine comes differently (it should have been d%20a instead of d a)
access log of nginx when called via https
"GET /search/web/buildings/search/v2/city/d%20a HTTP/1.1" S=505 168 T=0.001 R=- 35.200.191.89
access log of the machine when called via https
"GET /search/search/web/buildings/search/v2/city/d a HTTP/1.0" 505 -
Here is the relevant nginx configuration:
upstream searchtomcat {
least_conn;
server search-1:8080;
server search-2:8080;
}
server {
#listen 443 ssl http2;
listen 443;
client_max_body_size 100M;
...
location ~* ^/search/(.*)$ {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://searchtomcat/search/search/$1;
proxy_read_timeout 900;
}
}
There is nothing in error.log.
What could be the possible reason because of which the machine is getting request in a different manner?
The whole issue.is happening because of the space that is coming in your URL that is being sent over to tomcat. Because of it,
ais being interpreted as the HTTP version code and notHTTP/1.0. Solving the extra space issue will solve the problem.Using
rewriteinlocation{}block should solve the problem.Also, you have different configurations for
httpandhttpsservers, have a look at thehttpone. That one seems to be correct.