Why does $_SERVER[“SERVER_PROTOCOL”] show HTTP/1.0

2020-04-11 05:41发布

I'm trying to know the HTTP version the user used to connect to my server. The code at http://test.yccau.com (PHP 5.3.26 and Apache 2.2.24) looks like this:

<?php
    echo $_SERVER["SERVER_PROTOCOL"];
?>

For some reason, the page shows HTTP/1.0 even when the request and response were both HTTP/1.1:

enter image description here

What may be causing the problem? How do we get the HTTP version the web-client use to connect to the server?

1条回答
啃猪蹄的小仙女
2楼-- · 2020-04-11 06:22

Interesting problem! You have two connections here because you have a end-point proxy in between. The request from your version of nginx to apache is going over HTTP 1.0.

CLIENT <---- (HTTP 1.1) ----> NGINX <----- (HTTP 1.0) ----> SERVER

Nginx 1.1.4 onwards supports HTTP 1.1 to upstream servers.

查看更多
登录 后发表回答