nghttpx: Fix bug that api and healthmon params do not work with http2 proxy
This commit is contained in:
parent
09c647fd1b
commit
4807e71b7d
|
@ -306,8 +306,11 @@ int Http2Upstream::on_request_headers(Downstream *downstream,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For HTTP/2 proxy, we request :authority.
|
auto faddr = handler_->get_upstream_addr();
|
||||||
if (method_token != HTTP_CONNECT && get_config()->http2_proxy && !authority) {
|
|
||||||
|
// For HTTP/2 proxy, we require :authority.
|
||||||
|
if (method_token != HTTP_CONNECT && get_config()->http2_proxy &&
|
||||||
|
!faddr->alt_mode && !authority) {
|
||||||
rst_stream(downstream, NGHTTP2_PROTOCOL_ERROR);
|
rst_stream(downstream, NGHTTP2_PROTOCOL_ERROR);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -331,7 +334,7 @@ int Http2Upstream::on_request_headers(Downstream *downstream,
|
||||||
if (method_token == HTTP_OPTIONS &&
|
if (method_token == HTTP_OPTIONS &&
|
||||||
path->value == StringRef::from_lit("*")) {
|
path->value == StringRef::from_lit("*")) {
|
||||||
// Server-wide OPTIONS request. Path is empty.
|
// Server-wide OPTIONS request. Path is empty.
|
||||||
} else if (get_config()->http2_proxy) {
|
} else if (get_config()->http2_proxy && !faddr->alt_mode) {
|
||||||
req.path = path->value;
|
req.path = path->value;
|
||||||
} else {
|
} else {
|
||||||
req.path = http2::rewrite_clean_path(downstream->get_block_allocator(),
|
req.path = http2::rewrite_clean_path(downstream->get_block_allocator(),
|
||||||
|
|
|
@ -202,7 +202,7 @@ int htp_hdr_valcb(http_parser *htp, const char *data, size_t len) {
|
||||||
namespace {
|
namespace {
|
||||||
void rewrite_request_host_path_from_uri(BlockAllocator &balloc, Request &req,
|
void rewrite_request_host_path_from_uri(BlockAllocator &balloc, Request &req,
|
||||||
const StringRef &uri,
|
const StringRef &uri,
|
||||||
http_parser_url &u) {
|
http_parser_url &u, bool http2_proxy) {
|
||||||
assert(u.field_set & (1 << UF_HOST));
|
assert(u.field_set & (1 << UF_HOST));
|
||||||
|
|
||||||
// As per https://tools.ietf.org/html/rfc7230#section-5.4, we
|
// As per https://tools.ietf.org/html/rfc7230#section-5.4, we
|
||||||
|
@ -271,7 +271,7 @@ void rewrite_request_host_path_from_uri(BlockAllocator &balloc, Request &req,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_config()->http2_proxy) {
|
if (http2_proxy) {
|
||||||
req.path = path;
|
req.path = path;
|
||||||
} else {
|
} else {
|
||||||
req.path = http2::rewrite_clean_path(balloc, path);
|
req.path = http2::rewrite_clean_path(balloc, path);
|
||||||
|
@ -338,6 +338,7 @@ int htp_hdrs_completecb(http_parser *htp) {
|
||||||
|
|
||||||
downstream->inspect_http1_request();
|
downstream->inspect_http1_request();
|
||||||
|
|
||||||
|
auto faddr = handler->get_upstream_addr();
|
||||||
auto &balloc = downstream->get_block_allocator();
|
auto &balloc = downstream->get_block_allocator();
|
||||||
|
|
||||||
if (method != HTTP_CONNECT) {
|
if (method != HTTP_CONNECT) {
|
||||||
|
@ -349,7 +350,7 @@ int htp_hdrs_completecb(http_parser *htp) {
|
||||||
}
|
}
|
||||||
// checking UF_HOST could be redundant, but just in case ...
|
// checking UF_HOST could be redundant, but just in case ...
|
||||||
if (!(u.field_set & (1 << UF_SCHEMA)) || !(u.field_set & (1 << UF_HOST))) {
|
if (!(u.field_set & (1 << UF_SCHEMA)) || !(u.field_set & (1 << UF_HOST))) {
|
||||||
if (get_config()->http2_proxy) {
|
if (get_config()->http2_proxy && !faddr->alt_mode) {
|
||||||
// Request URI should be absolute-form for client proxy mode
|
// Request URI should be absolute-form for client proxy mode
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -372,7 +373,9 @@ int htp_hdrs_completecb(http_parser *htp) {
|
||||||
req.scheme = StringRef::from_lit("http");
|
req.scheme = StringRef::from_lit("http");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rewrite_request_host_path_from_uri(balloc, req, req.path, u);
|
rewrite_request_host_path_from_uri(balloc, req, req.path, u,
|
||||||
|
get_config()->http2_proxy &&
|
||||||
|
!faddr->alt_mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,8 +414,6 @@ int htp_hdrs_completecb(http_parser *htp) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto faddr = handler->get_upstream_addr();
|
|
||||||
|
|
||||||
if (faddr->alt_mode) {
|
if (faddr->alt_mode) {
|
||||||
// Normally, we forward expect: 100-continue to backend server,
|
// Normally, we forward expect: 100-continue to backend server,
|
||||||
// and let them decide whether responds with 100 Continue or not.
|
// and let them decide whether responds with 100 Continue or not.
|
||||||
|
|
|
@ -267,7 +267,11 @@ void on_ctrl_recv_callback(spdylay_session *session, spdylay_frame_type type,
|
||||||
} else {
|
} else {
|
||||||
req.scheme = scheme->value;
|
req.scheme = scheme->value;
|
||||||
req.authority = host->value;
|
req.authority = host->value;
|
||||||
if (get_config()->http2_proxy) {
|
|
||||||
|
auto handler = upstream->get_client_handler();
|
||||||
|
auto faddr = handler->get_upstream_addr();
|
||||||
|
|
||||||
|
if (get_config()->http2_proxy && !faddr->alt_mode) {
|
||||||
req.path = path->value;
|
req.path = path->value;
|
||||||
} else if (method_token == HTTP_OPTIONS &&
|
} else if (method_token == HTTP_OPTIONS &&
|
||||||
path->value == StringRef::from_lit("*")) {
|
path->value == StringRef::from_lit("*")) {
|
||||||
|
|
Loading…
Reference in New Issue