nghttpx: Add --no-location-rewrite option
--no-location-rewrite option disallows location header rewrite on --http2-bridge, --client and default mode. This option is useful when connecting nghttpx proxy with --http2-bridge to backend nghttpx with http2-proxy mode.
This commit is contained in:
parent
d499803221
commit
24cfb52b5a
12
src/shrpx.cc
12
src/shrpx.cc
|
@ -569,6 +569,7 @@ void fill_default_config()
|
|||
|
||||
mod_config()->tls_proto_mask = 0;
|
||||
mod_config()->cached_time = generate_time();
|
||||
mod_config()->no_location_rewrite = false;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
@ -873,6 +874,12 @@ Misc:
|
|||
downstream request.
|
||||
--no-via Don't append to Via header field. If Via header
|
||||
field is received, it is left unaltered.
|
||||
--no-location-rewrite
|
||||
Don't rewrite location header field on
|
||||
--http2-bridge, --client and default mode. For
|
||||
--http2-proxy and --client-proxy mode, location
|
||||
header field will not be altered regardless of
|
||||
this option.
|
||||
--altsvc=<PROTOID,PORT[,HOST,[ORIGIN]]>
|
||||
Specify protocol ID, port, host and origin of
|
||||
alternative service. <HOST> and <ORIGIN> are
|
||||
|
@ -995,6 +1002,7 @@ int main(int argc, char **argv)
|
|||
{"errorlog-syslog", no_argument, &flag, 59},
|
||||
{"stream-read-timeout", required_argument, &flag, 60},
|
||||
{"stream-write-timeout", required_argument, &flag, 61},
|
||||
{"no-location-rewrite", no_argument, &flag, 62},
|
||||
{nullptr, 0, nullptr, 0 }
|
||||
};
|
||||
|
||||
|
@ -1263,6 +1271,10 @@ int main(int argc, char **argv)
|
|||
// --stream-write-timeout
|
||||
cmdcfgs.emplace_back(SHRPX_OPT_STREAM_WRITE_TIMEOUT, optarg);
|
||||
break;
|
||||
case 62:
|
||||
// --no-location-rewrite
|
||||
cmdcfgs.emplace_back(SHRPX_OPT_NO_LOCATION_REWRITE, "yes");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -124,6 +124,7 @@ const char SHRPX_OPT_ALTSVC[] = "altsvc";
|
|||
const char SHRPX_OPT_ADD_RESPONSE_HEADER[] = "add-response-header";
|
||||
const char SHRPX_OPT_WORKER_FRONTEND_CONNECTIONS[] =
|
||||
"worker-frontend-connections";
|
||||
const char SHRPX_OPT_NO_LOCATION_REWRITE[] = "no-location-rewrite";
|
||||
|
||||
namespace {
|
||||
Config *config = nullptr;
|
||||
|
@ -840,6 +841,12 @@ int parse_config(const char *opt, const char *optarg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if(util::strieq(opt, SHRPX_OPT_NO_LOCATION_REWRITE)) {
|
||||
mod_config()->no_location_rewrite = util::strieq(optarg, "yes");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(util::strieq(opt, "conf")) {
|
||||
LOG(WARNING) << "conf is ignored";
|
||||
|
||||
|
|
|
@ -114,6 +114,7 @@ extern const char SHRPX_OPT_PADDING[];
|
|||
extern const char SHRPX_OPT_ALTSVC[];
|
||||
extern const char SHRPX_OPT_ADD_RESPONSE_HEADER[];
|
||||
extern const char SHRPX_OPT_WORKER_FRONTEND_CONNECTIONS[];
|
||||
extern const char SHRPX_OPT_NO_LOCATION_REWRITE[];
|
||||
|
||||
union sockaddr_union {
|
||||
sockaddr sa;
|
||||
|
@ -259,6 +260,7 @@ struct Config {
|
|||
bool backend_ipv6;
|
||||
bool http2_no_cookie_crumbling;
|
||||
bool upstream_frame_debug;
|
||||
bool no_location_rewrite;
|
||||
};
|
||||
|
||||
const Config* get_config();
|
||||
|
|
|
@ -1174,7 +1174,8 @@ int Http2Upstream::on_downstream_header_complete(Downstream *downstream)
|
|||
}
|
||||
|
||||
downstream->normalize_response_headers();
|
||||
if(!get_config()->http2_proxy && !get_config()->client_proxy) {
|
||||
if(!get_config()->http2_proxy && !get_config()->client_proxy &&
|
||||
!get_config()->no_location_rewrite) {
|
||||
downstream->rewrite_norm_location_response_header
|
||||
(get_client_handler()->get_upstream_scheme(), get_config()->port);
|
||||
}
|
||||
|
|
|
@ -765,7 +765,8 @@ int HttpsUpstream::on_downstream_header_complete(Downstream *downstream)
|
|||
hdrs += http2::get_status_string(downstream->get_response_http_status());
|
||||
hdrs += "\r\n";
|
||||
downstream->normalize_response_headers();
|
||||
if(!get_config()->http2_proxy && !get_config()->client_proxy) {
|
||||
if(!get_config()->http2_proxy && !get_config()->client_proxy &&
|
||||
!get_config()->no_location_rewrite) {
|
||||
downstream->rewrite_norm_location_response_header
|
||||
(get_client_handler()->get_upstream_scheme(), get_config()->port);
|
||||
}
|
||||
|
|
|
@ -911,7 +911,8 @@ int SpdyUpstream::on_downstream_header_complete(Downstream *downstream)
|
|||
DLOG(INFO, downstream) << "HTTP response header completed";
|
||||
}
|
||||
downstream->normalize_response_headers();
|
||||
if(!get_config()->http2_proxy && !get_config()->client_proxy) {
|
||||
if(!get_config()->http2_proxy && !get_config()->client_proxy &&
|
||||
!get_config()->no_location_rewrite) {
|
||||
downstream->rewrite_norm_location_response_header
|
||||
(get_client_handler()->get_upstream_scheme(), get_config()->port);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue