Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取505 HTTP版本在HTTPS上不受支持,但在HTTP上不受支持_Http_Tomcat_Nginx_Https_Http Status Code 505 - Fatal编程技术网

获取505 HTTP版本在HTTPS上不受支持,但在HTTP上不受支持

获取505 HTTP版本在HTTPS上不受支持,但在HTTP上不受支持,http,tomcat,nginx,https,http-status-code-505,Http,Tomcat,Nginx,Https,Http Status Code 505,我正在尝试使用一个包含空格的参数调用GET api: https://abc.xyz/search/web/buildings/search/v2/city/new%20york 端点点击负载平衡器(nginx),它将请求重定向到合适的机器 在响应中,我得到505HTTP版本不支持错误。但是,当我使用HTTP(使用内部IP)向负载平衡器发出相同的请求时,它会成功地返回响应 以下是两种情况的相关访问日志: 通过http调用nginx时的访问日志 "GET /search/web/building

我正在尝试使用一个包含空格的参数调用GET api:

https://abc.xyz/search/web/buildings/search/v2/city/new%20york
端点点击负载平衡器(nginx),它将请求重定向到合适的机器

在响应中,我得到505HTTP版本不支持错误。但是,当我使用HTTP(使用内部IP)向负载平衡器发出相同的请求时,它会成功地返回响应

以下是两种情况的相关访问日志:

通过http调用nginx时的访问日志

"GET /search/web/buildings/search/v2/city/r%20c HTTP/1.1" S=200 487 T=0.005 R=- 10.140.15.199
"GET /search/search/web/buildings/search/v2/city/r%20c HTTP/1.0" 200 36
通过http调用时的计算机访问日志

"GET /search/web/buildings/search/v2/city/r%20c HTTP/1.1" S=200 487 T=0.005 R=- 10.140.15.199
"GET /search/search/web/buildings/search/v2/city/r%20c HTTP/1.0" 200 36
上述要求很有效。但是,当我们通过https请求时,机器中的请求不同(它应该是
d%20a
而不是
da

通过https调用nginx时的访问日志

"GET /search/web/buildings/search/v2/city/d%20a HTTP/1.1" S=505 168 T=0.001 R=- 35.200.191.89
"GET /search/search/web/buildings/search/v2/city/d a HTTP/1.0" 505 -
通过https调用时的计算机访问日志

"GET /search/web/buildings/search/v2/city/d%20a HTTP/1.1" S=505 168 T=0.001 R=- 35.200.191.89
"GET /search/search/web/buildings/search/v2/city/d a HTTP/1.0" 505 -
以下是相关的nginx配置:

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;
    }

}
错误日志中没有任何内容


机器以不同的方式接收请求的可能原因是什么?

整个问题的发生是因为URL中的空间被发送到tomcat。因此,
a
被解释为HTTP版本代码,而不是
HTTP/1.0
。解决额外空间问题将解决问题

location /search/ {
    rewrite ^/search(/.*) /search/search$1 break;

    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;
    proxy_read_timeout 900;
}
location{}
块中使用
rewrite
可以解决问题

location /search/ {
    rewrite ^/search(/.*) /search/search$1 break;

    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;
    proxy_read_timeout 900;
}

另外,您对
http
https
服务器有不同的配置,请查看
http
一个。这个似乎是正确的

请显示您的Nginx配置和
错误。日志
。非常感谢。工作得很有魅力!