14 lines
626 B
Python
14 lines
626 B
Python
"""Generate HTTP-only reverse proxy config. Certbot configures TLS afterward."""
|
|
import argparse,re
|
|
from pathlib import Path
|
|
p=argparse.ArgumentParser()
|
|
p.add_argument('--domain',required=True)
|
|
p.add_argument('--server',choices=['nginx','apache'],default='nginx')
|
|
p.add_argument('--output',required=True)
|
|
a=p.parse_args()
|
|
if not re.fullmatch(r'[A-Za-z0-9](?:[A-Za-z0-9.-]*[A-Za-z0-9])?',a.domain):p.error('Invalid domain')
|
|
src=Path(__file__).resolve().parents[1]/'deploy'/f'{a.server}-http.conf'
|
|
target=Path(a.output)
|
|
with target.open('x') as f:f.write(src.read_text().replace('dashboard.example.com',a.domain))
|
|
print(target)
|