Skip to content

Commit 8e15dc4

Browse files
[ReverseProxyPlugin] Remove redundant ca_file flag when wrapping upstream (#1046)
* Fix #1045 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * no conn log * Do not edit host header by default Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 25e6cb0 commit 8e15dc4

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

proxy/core/connection/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def connect(
4343
)
4444
self.closed = False
4545

46-
def wrap(self, hostname: str, ca_file: Optional[str]) -> None:
46+
def wrap(self, hostname: str, ca_file: Optional[str] = None) -> None:
4747
ctx = ssl.create_default_context(
4848
ssl.Purpose.SERVER_AUTH, cafile=ca_file,
4949
)

proxy/http/server/reverse.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from ...core.base import TcpUpstreamConnectionHandler
2121
from ...common.utils import text_
2222
from ...common.constants import (
23-
DEFAULT_HTTP_PORT, DEFAULT_HTTPS_PORT,
23+
HTTPS_PROTO, DEFAULT_HTTP_PORT, DEFAULT_HTTPS_PORT,
2424
DEFAULT_REVERSE_PROXY_ACCESS_LOG_FORMAT,
2525
)
2626

@@ -78,12 +78,18 @@ def handle_request(self, request: HttpParser) -> None:
7878
assert self.upstream
7979
try:
8080
self.upstream.connect()
81-
if self.choice.scheme == b'https':
81+
if self.choice.scheme == HTTPS_PROTO:
8282
self.upstream.wrap(
8383
text_(
8484
self.choice.hostname,
85-
), ca_file=str(self.flags.ca_file),
85+
),
8686
)
87+
# Update Host header
88+
# if request.has_header(b'Host'):
89+
# request.del_header(b'Host')
90+
# request.add_header(
91+
# b'Host', ('%s:%d' % self.upstream.addr).encode('utf-8'),
92+
# )
8793
self.upstream.queue(memoryview(request.build()))
8894
except ConnectionRefusedError:
8995
raise HttpProtocolException(

0 commit comments

Comments
 (0)