@@ -176,7 +176,17 @@ text = re.sub(
176176
177177route_template = """
178178{indent}# CodexAuditBridge route start
179- {indent}location /v1/codex-audit {{
179+ {indent}location = /v1/codex-audit {{
180+ {indent} proxy_pass http://127.0.0.1:{port};
181+ {indent} proxy_http_version 1.1;
182+ {indent} proxy_set_header Host $host;
183+ {indent} proxy_set_header X-Real-IP $remote_addr;
184+ {indent} proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
185+ {indent} proxy_set_header X-Forwarded-Proto https;
186+ {indent} proxy_read_timeout 3600s;
187+ {indent} proxy_send_timeout 3600s;
188+ {indent}}}
189+ {indent}location ^~ /v1/codex-audit/ {{
180190{indent} proxy_pass http://127.0.0.1:{port};
181191{indent} proxy_http_version 1.1;
182192{indent} proxy_set_header Host $host;
@@ -289,9 +299,28 @@ import re
289299import sys
290300
291301text = Path(sys.argv[1]).read_text(encoding="utf-8")
292- for block in re.findall(r"server\s*\{.*?\n\}", text, flags=re.S):
302+
303+
304+ def server_blocks(source: str):
305+ for match in re.finditer(r"\bserver\s*\{", source):
306+ open_brace = source.find("{", match.start())
307+ depth = 0
308+ for index in range(open_brace, len(source)):
309+ char = source[index]
310+ if char == "{":
311+ depth += 1
312+ elif char == "}":
313+ depth -= 1
314+ if depth == 0:
315+ yield source[match.start() : index + 1]
316+ break
317+
318+
319+ for block in server_blocks(text):
293320 if not re.search(r"\blisten\s+443\b", block):
294321 continue
322+ if "# CodexAuditBridge route start" not in block:
323+ continue
295324 match = re.search(r"\bserver_name\s+([^;\s]+)", block)
296325 if match and match.group(1) not in {"_", "localhost"}:
297326 print(match.group(1))
0 commit comments