Update to start without working upstream

This commit is contained in:
2024-01-01 19:34:01 +00:00
parent 7af75ad55d
commit 40f9459826
5 changed files with 15 additions and 9 deletions

View File

@@ -7,7 +7,9 @@ import sys
REDIRECT_TEMPLATE = "\n".join(
(
"\tlocation / {{",
"\t\tproxy_pass {redirection_host}/;",
"\t\tresolver 127.0.0.11 valid=30s;",
"\t\tset $host_{i} {redirection_host};",
"\t\tproxy_pass $host_{i}/;",
"\t\tinclude proxy_common.conf;",
"\t}}",
)
@@ -57,7 +59,7 @@ class Server:
if self.options is None:
self.options = []
def format(self, indent: str = " ", base_indent: int = 1) -> str:
def format(self, i: int, indent: str = " ", base_indent: int = 1) -> str:
"""Format server to place inside nginx.conf"""
res = (indent * base_indent) + (
SERVER_HTTPS_TEMPLATE if self.certificate is not None else SERVER_HTTP_TEMPLATE
@@ -67,7 +69,7 @@ class Server:
redirection=(
REDIRECT_TEMPLATE.replace("\n", "\n" + indent * base_indent)
.replace("\t", indent)
.format(redirection_host=self.redirect)
.format(i=i, redirection_host=self.redirect)
if self.redirect is not None
else ""
),
@@ -190,7 +192,7 @@ def main() -> None:
Server(domain, None, domain if not args.http_only else None, certificates_path=args.certificates_path)
)
nginx_servers_part = "\n\n".join(server.format() for server in nginx_servers)
nginx_servers_part = "\n\n".join(server.format(i) for i, server in enumerate(nginx_servers))
print(f"Using following servers part for nginx.conf:\n\n{nginx_servers_part}")