Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit28df044

Browse files
author
Audrey M. Roy Greenfeld
committed
Modify add_sub_reverse_proxy to be multi-port
1 parent51fb056 commit28df044

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

‎fastcaddy/core.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,18 @@ def add_wildcard_route(domain):
177177
add_route(route)
178178

179179
# %% ../nbs/00_core.ipynb 48
180-
defadd_sub_reverse_proxy(domain,subdomain,port,host='localhost'):
181-
"Add a reverse proxy to a wildcard subdomain"
180+
defadd_sub_reverse_proxy(domain,subdomain,ports,host='localhost'):
181+
"Add a reverse proxy to a wildcard subdomain supporting multiple ports"
182182
wildcard_id=f"wildcard-{domain}"
183183
route_id=f"{subdomain}.{domain}"
184+
ifisinstance(ports, (int,str)):ports= [ports]
185+
upstreams= [{"dial":f"{host}:{port}"}forportinports]
184186
new_route= {
185187
"@id":route_id,
186188
"match": [{"host": [route_id]}],
187189
"handle": [{
188190
"handler":"reverse_proxy",
189-
"upstreams":[{"dial":f"{host}:{port}"}]
191+
"upstreams":upstreams
190192
}]
191193
}
192194
pid([new_route],f"{wildcard_id}/handle/0/routes/...")

‎nbs/00_core.ipynb‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,16 +609,18 @@
609609
"outputs": [],
610610
"source": [
611611
"#| export\n",
612-
"def add_sub_reverse_proxy(domain, subdomain,port, host='localhost'):\n",
613-
"\"Add a reverse proxy to a wildcard subdomain\"\n",
612+
"def add_sub_reverse_proxy(domain, subdomain,ports, host='localhost'):\n",
613+
"\"Add a reverse proxy to a wildcard subdomain supporting multiple ports\"\n",
614614
" wildcard_id = f\"wildcard-{domain}\"\n",
615615
" route_id = f\"{subdomain}.{domain}\"\n",
616+
" if isinstance(ports, (int,str)): ports = [ports]\n",
617+
" upstreams = [{\"dial\": f\"{host}:{port}\"} for port in ports]\n",
616618
" new_route = {\n",
617619
"\"@id\": route_id,\n",
618620
"\"match\": [{\"host\": [route_id]}],\n",
619621
"\"handle\": [{\n",
620622
"\"handler\":\"reverse_proxy\",\n",
621-
"\"upstreams\":[{\"dial\": f\"{host}:{port}\"}]\n",
623+
"\"upstreams\":upstreams\n",
622624
" }]\n",
623625
" }\n",
624626
" pid([new_route], f\"{wildcard_id}/handle/0/routes/...\")"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp