HTTPS: одна кнопка «Сохранить» на раздел (перенаправление, доменное имя, адрес без порта)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q7eREaYwUt1i4fNLZcGnjn
This commit is contained in:
fontvielle
2026-10-22 15:39:30 +03:00
parent 005c5e8368
commit 7fd4bd0af9
3 changed files with 137 additions and 123 deletions
@@ -929,24 +929,15 @@
<h2><span class="dot {{if and .Settings.HTTPS.RedirectOn (not $h.Err)}}ok{{else}}warn{{end}}"></span>HTTPS — шифрование входа в bj</h2>
<p class="muted">Пароли администратора, баз данных, хранилища и ключ продукта не должны идти по сети открытым текстом. bj всегда слушает HTTPS: <a href="https://{{serverIP}}:{{if .Settings.HTTPS.Port}}{{.Settings.HTTPS.Port}}{{else}}8443{{end}}/admin/">https://{{serverIP}}:{{if .Settings.HTTPS.Port}}{{.Settings.HTTPS.Port}}{{else}}8443{{end}}/</a>. Модули bj и API на этом сервере работают по HTTP, как раньше.</p>
<p style="margin:8px 0">{{if $h.Err}}<span style="color:var(--err)">✗ сертификат: {{$h.Err}}</span>{{else}}Сертификат: <b>{{$h.CN}}</b>, до {{$h.Until.Format "02.01.2006"}} — {{if .Settings.HTTPS.Custom}}сертификат организации{{else}}самоподписанный: браузер один раз попросит подтвердить исключение; чтобы не просил — загрузите сертификат организации{{end}}.{{end}}</p>
<form method="post" action="/admin/setup/https" style="margin:8px 0">
<form method="post" action="/admin/setup/https" style="margin:8px 0" onsubmit="var p=this.std_ports;return p.checked==p.defaultChecked||confirm('Сохранить? bj перезапустится на несколько секунд.')">
<input type="hidden" name="section" value="sec-https">
<label style="display:flex;align-items:center;gap:8px;font-weight:400"><input type="checkbox" name="redirect" style="width:auto"{{if .Settings.HTTPS.RedirectOn}} checked{{end}}> <b>Открывать bj только по HTTPS</b> — браузер с http:// перенаправляется на https://</label>
<button type="submit" class="btn" style="margin-top:8px">Сохранить</button>
</form>
<form method="post" action="/admin/setup/hostname" style="margin:12px 0 8px">
<input type="hidden" name="section" value="sec-https">
<label for="set-hostnames" style="display:block;margin-bottom:4px">Доменное имя сервера bj</label>
<div style="display:flex;gap:8px;flex-wrap:wrap">
<input id="set-hostnames" name="hostnames" value="{{range $i, $n := .Settings.HTTPS.Hostnames}}{{if $i}} {{end}}{{$n}}{{end}}" placeholder="например, m2m.corp.example.ru (несколько — через пробел)" style="min-width:320px;flex:1">
<button type="submit" class="btn">Сохранить</button>
</div>
<label for="set-hostnames" style="display:block;margin:12px 0 4px">Доменное имя сервера bj</label>
<input id="set-hostnames" name="hostnames" value="{{range $i, $n := .Settings.HTTPS.Hostnames}}{{if $i}} {{end}}{{$n}}{{end}}" placeholder="например, m2m.corp.example.ru (несколько — через пробел)" style="min-width:320px;width:100%">
<p class="muted" style="font-size:12.5px;margin:4px 0 0">Сначала администратор сети заводит в DNS запись A на этот сервер ({{range $i, $ip := serverIPs}}{{if $i}}, {{end}}{{$ip}}{{end}}); bj проверит, что имя находится и указывает сюда, и впишет его в сертификат. Адрес bj — <code>https://имя{{httpsPortSuffix}}/</code>.</p>
</form>
<form method="post" action="/admin/setup/https/stdports" style="margin:4px 0 8px">
<input type="hidden" name="section" value="sec-https">
<label style="display:flex;align-items:center;gap:8px;font-weight:400"><input type="checkbox" name="std_ports" style="width:auto"{{if .Settings.HTTPS.StdPorts}} checked{{end}}> <b>Адрес без номера порта</b> — https://имя/ вместо https://имя:{{httpsOwnPort}}/ (bj слушает 443, а 80 переводит на https://)</label>
<label style="display:flex;align-items:center;gap:8px;font-weight:400;margin-top:10px"><input type="checkbox" name="std_ports" style="width:auto"{{if .Settings.HTTPS.StdPorts}} checked{{end}}> <b>Адрес без номера порта</b> — https://имя/ вместо https://имя:{{httpsOwnPort}}/ (bj слушает 443, а 80 переводит на https://)</label>
{{with stdPortsState}}<p style="margin:4px 0 0;font-size:12.5px">{{if eq . "ok"}}<span style="color:var(--ok)">✓ работает: порты 443 и 80</span>{{else}}<span style="color:var(--warn)">⚠ {{.}} — нажмите «Сохранить» ещё раз</span>{{end}}</p>{{end}}
<button type="submit" class="btn" style="margin-top:8px" onclick="return confirm('Сохранить? bj перезапустится на несколько секунд.')">Сохранить</button>
<button type="submit" class="btn" style="margin-top:12px">Сохранить</button>
</form>
<details style="margin-top:8px"><summary style="cursor:pointer;color:var(--accent)">Сертификат организации</summary>
<form method="post" action="/admin/setup/https/cert" enctype="multipart/form-data" style="display:grid;gap:8px;max-width:520px;margin-top:8px">