diff --git a/src/Application.php b/src/Application.php index 736c99d..94e02b2 100644 --- a/src/Application.php +++ b/src/Application.php @@ -71,6 +71,11 @@ public function swoole(Request $request, Response $response) $server['path_info'] = $_GET[$this->config->get('var_pathinfo')]; } + // Nginx兼容: proxy_set_header SERVER_PORT $server_port; + if(isset($header['server_port'])) { + $server['server_port'] = $header['server_port']; + } + $_SERVER = array_change_key_case($server, CASE_UPPER); // 重新实例化请求对象 处理swoole请求数据 @@ -81,10 +86,10 @@ public function swoole(Request $request, Response $response) ->withCookie($_COOKIE) ->withInput($request->rawContent()) ->withFiles($_FILES) - ->setBaseUrl($request->server['request_uri']) - ->setUrl($request->server['request_uri'] . (!empty($request->server['query_string']) ? '&' . $request->server['query_string'] : '')) - ->setHost($request->header['host']) - ->setPathinfo(ltrim($request->server['path_info'], '/')); + ->setBaseUrl($server['request_uri']) + ->setUrl($server['request_uri'] . (!empty($server['query_string']) ? '&' . $server['query_string'] : '')) + ->setHost($header['host']) + ->setPathinfo(ltrim($server['path_info'], '/')); // 更新请求对象实例 $this->route->setRequest($this->request);