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

@@ -1,6 +1,6 @@
version: '3.4'
project: ssl_nginx
name: ssl_nginx
services:
certbot:
@@ -14,6 +14,7 @@ services:
- letsencrypt:/etc/letsencrypt
depends_on:
- nginx
restart: unless-stopped
nginx:
container_name: 'global-nginx'
@@ -26,6 +27,7 @@ services:
- 443:443
networks:
- hosting_net
restart: unless-stopped
volumes:
ssl:

View File

@@ -5,7 +5,7 @@ COPY servers.json /servers.json
COPY domains.txt /domains.txt
COPY nginx.conf /nginx.conf
RUN python /add_servers.py --nginx /nginx.conf --domains_list_txt /domains.txt --servers_config_json server.json --certificates_path /ssl
RUN python /add_servers.py --nginx /nginx.conf --domains_list_txt /domains.txt --servers_config_json servers.json --certificates_path /ssl
FROM nginx:alpine

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}")

View File

@@ -14,7 +14,7 @@ COPY server_common.conf /etc/nginx/server_common.conf
COPY --from=builder /nginx.conf /etc/nginx/nginx.conf
COPY domains.txt /domains.txt
RUN echo "(sleep 30 && killall nginx) &" > /entrypoint && \
RUN echo "(sleep 60 && killall nginx) &" > /entrypoint && \
echo "cp /domains.txt /ssl/domains.txt" >> /entrypoint && \
echo "nginx -g 'daemon off;'" >> /entrypoint && \
echo "nginx" >> /entrypoint

View File

@@ -27,4 +27,6 @@ services:
volumes:
ssl:
name: ssl_nginx_ssl
letsencrypt:
name: ssl_nginx_letsencrypt