[~] Refactor

This commit is contained in:
Siarhei Siniak 2024-09-08 21:52:10 +03:00
parent a7f5be4c8e
commit 92fe90b042
2 changed files with 35 additions and 1 deletions

@ -294,17 +294,48 @@ server {
) )
) )
if 'stream_server' in ssl_nginx:
stream_server = r'''
stream {
upstream web {
server {web};
}
map $ssl_preread_protocol $upstream {
default ssh;
"TLSv1.2" web;
"TLSv1.3" web;
}
# SSH and SSL on the same port
server {
listen 443;
proxy_pass $upstream;
ssl_preread on;
}
}
'''.replace(
'{web}', str(ssl_nginx['stream_server'])[:256]
)
else:
stream_server = ''
with io.open( with io.open(
output_conf, output_conf,
'w' 'w'
) as f: ) as f:
f.write( f.write(
r''' r'''
load_module "modules/ngx_stream_module.so";
events { events {
multi_accept on; multi_accept on;
worker_connections 64; worker_connections 64;
} }
{stream_server}
http { http {
log_format main log_format main
'[$time_local][$remote_addr:$remote_port, $http_x_forwarded_for, $t1, $http_host]' '[$time_local][$remote_addr:$remote_port, $http_x_forwarded_for, $t1, $http_host]'
@ -325,7 +356,9 @@ http {
'' close; '' close;
} }
} }
'''.replace('{servers}', '\n'.join(servers)) '''\
.replace('{servers}', '\n'.join(servers)) \
.replace('{stream_server}', stream_server)
) )

@ -7,6 +7,7 @@ RUN apk add nginx
RUN apk add tini RUN apk add tini
#RUN pip3 install requests certbot #RUN pip3 install requests certbot
RUN apk add certbot RUN apk add certbot
RUN apk add nginx-mod-stream
WORKDIR /app WORKDIR /app