mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 10:16:27 +00:00
Adds --keep-host-header option (#2039)
This commit is contained in:
parent
391f28f78c
commit
14d8c91250
@ -72,6 +72,7 @@ class Options(optmanager.OptManager):
|
||||
upstream_bind_address: str = "",
|
||||
mode: str = "regular",
|
||||
no_upstream_cert: bool = False,
|
||||
keep_host_header: bool = False,
|
||||
|
||||
http2: bool = True,
|
||||
http2_priority: bool = False,
|
||||
@ -162,6 +163,7 @@ class Options(optmanager.OptManager):
|
||||
self.upstream_bind_address = upstream_bind_address
|
||||
self.mode = mode
|
||||
self.no_upstream_cert = no_upstream_cert
|
||||
self.keep_host_header = keep_host_header
|
||||
|
||||
self.http2 = http2
|
||||
self.http2_priority = http2_priority
|
||||
|
@ -290,7 +290,7 @@ class HttpLayer(base.Layer):
|
||||
request.first_line_format = "relative"
|
||||
|
||||
# update host header in reverse proxy mode
|
||||
if self.config.options.mode == "reverse":
|
||||
if self.config.options.mode == "reverse" and not self.config.options.keep_host_header:
|
||||
f.request.host_header = self.config.upstream_server.address.host
|
||||
|
||||
# Determine .scheme, .host and .port attributes for inline scripts. For
|
||||
|
@ -112,6 +112,7 @@ def get_common_options(args):
|
||||
replacements=args.replacements,
|
||||
replacement_files=args.replacement_files,
|
||||
setheaders=args.setheaders,
|
||||
keep_host_header=args.keep_host_header,
|
||||
server_replay=args.server_replay,
|
||||
scripts=args.scripts,
|
||||
stickycookie=stickycookie,
|
||||
@ -387,6 +388,11 @@ def proxy_options(parser):
|
||||
action="store", type=str, dest="upstream_bind_address",
|
||||
help="Address to bind upstream requests to (defaults to none)"
|
||||
)
|
||||
group.add_argument(
|
||||
"--keep-host-header",
|
||||
action="store_true", dest="keep_host_header",
|
||||
help="Keep the host header as proxy addres"
|
||||
)
|
||||
|
||||
|
||||
def proxy_ssl_options(parser):
|
||||
|
Loading…
Reference in New Issue
Block a user