Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
240255b2ff | ||
|
|
5c6fd90f37 | ||
|
|
64c3ae4c36 |
No files matched your search
@@ -538,12 +538,13 @@ Decision: Caddy, the `caddy` package of the Ubuntu archive and a dependency of t
|
||||
`127.0.0.1:9474` and rclone's WebDAV on `127.0.0.1:7446`, and Caddy calls them there. Once the
|
||||
server is configured, `linux-manager-setup` writes `/etc/caddy/linux-manager.Caddyfile`: plain
|
||||
HTTP sites on `web.port` (7081), the Manager's `port` (7080) and, while metrics are on,
|
||||
`metrics.port` (9464), on every address; while `https.enabled` is `true` and `wan.local_fqdn` is
|
||||
set, sites for `wan.local_fqdn` on `https.web_port` (7444), `https.manager_port` (7443),
|
||||
`metrics.https_port` (9465) and `sites.webdav_port` (7445). While HTTPS is on, the Manager's plain
|
||||
HTTP site redirects (308) to its HTTPS address unless `https.disable_auto_redirect` is set; the
|
||||
status page's never does, so monitors and clients that do not trust the server's certificate
|
||||
keep reaching it. The `listen` settings choose the interfaces the firewall opens each plain HTTP
|
||||
`metrics.port` (9464), on every address; and always sites for the HTTPS names (ADR-65) on
|
||||
`https.web_port` (7444), `https.manager_port` (7443), `metrics.https_port` (9465) and
|
||||
`sites.webdav_port` (7445). Unless `https.disable_auto_redirect` is set, both plain HTTP sites
|
||||
redirect (308) a request for an HTTPS name to the same host on HTTPS, and the Manager's redirects
|
||||
every other request to the first HTTPS name; the status page stays on plain HTTP by address, so
|
||||
monitors and clients that do not trust the server's certificate keep reaching it, and `/pki/`
|
||||
stays on plain HTTP on both, where the certificates name it. The `listen` settings choose the interfaces the firewall opens each plain HTTP
|
||||
port on, as Caddy listens on every address. The certificate comes from `https.certificate`
|
||||
(ADR-60); with `acme`, Caddy obtains and renews it with the HTTP challenge on port 80, which the
|
||||
firewall opens on the external interface then; `auto_https disable_redirects` keeps port 80 to the
|
||||
@@ -1708,10 +1709,8 @@ provisioned, as with a root the server creates, else `self-signed`. Until a setu
|
||||
succeeded, a file that does not set it is taken as empty, so a configuration written by hand or by
|
||||
a tool in place of the installer's file gets the same choice. An upgrade makes no choice: a
|
||||
configuration that names a source keeps it, and once a run has succeeded, one that names none is
|
||||
self-signed. Whether
|
||||
HTTPS is on is an installer question and is always respected, and so is
|
||||
`https.disable_auto_redirect`, which keeps Caddy's plain HTTP site of the Manager from
|
||||
redirecting to HTTPS (ADR-21).
|
||||
self-signed. `https.disable_auto_redirect`, an installer question, is always respected; it keeps
|
||||
Caddy's plain HTTP sites from redirecting to HTTPS (ADR-21).
|
||||
|
||||
Consequences: A browser trusts a self-signed certificate, or one of the server's PKI, only once
|
||||
its user trusts it or the root. An imported certificate is not renewed by the server, which warns
|
||||
@@ -1827,3 +1826,31 @@ Consequences: One file serves both kinds of slapd, so the definitions cannot dri
|
||||
is an ordinary one, made with its first member; until it exists, only root reads the keys, and
|
||||
renaming it takes the access away. A server whose slapd holds the PKI definitions inside
|
||||
`cn=linux-manager` is installed anew, as slapd refuses the same OIDs in a second entry.
|
||||
|
||||
## ADR-65: HTTPS is always on, for wan.local_fqdn or the host name, with IP addresses on request
|
||||
|
||||
Status: Accepted
|
||||
|
||||
Context: The status page and the Manager carry passwords, so they are to be served over HTTPS on
|
||||
every server; only the redirect from plain HTTP is a choice, for labs and development, where the
|
||||
name of a server behind a forward is the only way to reach it. A server without `wan.local_fqdn`,
|
||||
such as the first device of a network without DNS, still needs a name for its certificate, and an
|
||||
appliance that is set up by address needs a certificate that names its address.
|
||||
|
||||
Decision: HTTPS has no switch: `https.enabled` and the installer's question are gone, and a file
|
||||
that still has the setting loads without it. The HTTPS names are `wan.local_fqdn` alone when it is
|
||||
set, else the host name and `<host name>.local`, which Avahi announces with mDNS on the internal
|
||||
side while there is no FQDN. `https.ip_sans`, off by default, adds the server's addresses to the
|
||||
self-signed certificate and the Servers Issuing CA's, and Caddy then serves HTTPS on them too; an
|
||||
ACME certificate names `wan.local_fqdn` only, which `acme` requires. Unless
|
||||
`https.disable_auto_redirect` is set, a plain HTTP request for an HTTPS host is redirected to the
|
||||
same host on HTTPS, on the status page's port and the Manager's; the status page stays on plain
|
||||
HTTP by any other address, and `/pki/` stays on plain HTTP. A certificate whose names or addresses
|
||||
differ from the current ones is made or issued again at the next setup, so a changed DHCP address
|
||||
is followed. As Caddy always listens, the firewall is always set up.
|
||||
|
||||
Consequences: A browser warns about a self-signed certificate, or one of the server's PKI, until
|
||||
its user trusts it or the root; one reached by address warns unless `https.ip_sans` is on. A server
|
||||
whose addresses change gets a new certificate at each change while `https.ip_sans` is on. Avahi is
|
||||
a dependency, running only while there is no FQDN; it sends its announcements on every interface,
|
||||
and the firewall lets queries in on the internal side only.
|
||||
@@ -1,5 +1,47 @@
|
||||
# Changelog
|
||||
|
||||
## 0.45.2 - 2026-11-24 20:41:04 +0100
|
||||
|
||||
fix: the copy icons of the Manager are shown only on a page opened over HTTPS, where the browser
|
||||
offers the clipboard.
|
||||
|
||||
- The copy icons of the Addresses panel, the Remote access page and the Web Sites page, and the Copy
|
||||
button of a WireGuard configuration, are left out on a page opened over plain HTTP, where they
|
||||
did nothing.
|
||||
|
||||
## 0.45.1 - 2026-11-24 19:57:53 +0100
|
||||
|
||||
update: the development VM of lm-dev-vm.py keeps plain HTTP by name.
|
||||
|
||||
- tests/remote/configs/dev.json sets https.disable_auto_redirect, so the status page and the
|
||||
Manager of the development VM answer over plain HTTP by name as well as over HTTPS.
|
||||
|
||||
## 0.45.0 - 2026-11-24 19:26:51 +0100
|
||||
|
||||
feature: HTTPS is always on, for wan.local_fqdn or, without it, the host name and its mDNS name,
|
||||
optionally also for the server's addresses, and the redirect to HTTPS covers the status page by
|
||||
name.
|
||||
|
||||
- https.enabled and the installer's question whether to serve over HTTPS are gone; a
|
||||
linux-manager.json that still has https.enabled is read without it.
|
||||
- The HTTPS names are wan.local_fqdn alone when it is set, else the host name and
|
||||
<host name>.local, which Avahi, a new dependency, announces with mDNS on the internal side while
|
||||
there is no wan.local_fqdn; the firewall opens UDP 5353 there.
|
||||
- https.ip_sans, off by default and set in the HTTPS settings dialog of the Certificates page, adds
|
||||
the server's addresses to the self-signed certificate and the Servers Issuing CA's, and Caddy
|
||||
serves HTTPS on them too; a certificate is made again when its names or addresses change.
|
||||
- https.certificate acme needs wan.local_fqdn.
|
||||
- Unless https.disable_auto_redirect is true, a plain HTTP request for an HTTPS name is redirected
|
||||
to HTTPS on the status page's port too; the status page stays on plain HTTP by address, and
|
||||
/pki/ on plain HTTP on both ports. The Manager's redirect keeps the host it was asked for when
|
||||
that is an HTTPS host.
|
||||
- The Addresses panel of the Server page lists the HTTPS addresses of every HTTPS host, and the
|
||||
plain HTTP addresses by name only while the redirect is off; the HTTPS row of the Certificates
|
||||
page names the hosts HTTPS is served for.
|
||||
- The OpenID Provider, WebDAV and the ACME servers of the issuing CAs need wan.local_fqdn no
|
||||
longer; they are served on the first HTTPS name.
|
||||
- The firewall is always set up, as Caddy always serves HTTPS.
|
||||
|
||||
## 0.44.1 - 2026-11-24 18:23:42 +0100
|
||||
|
||||
fix: a configuration that names no HTTPS certificate source gets the first setup's choice, and the
|
||||
|
||||
@@ -75,7 +75,6 @@ linux-manager linux-manager/internal_interface string eth1
|
||||
linux-manager linux-manager/int_addr string 10.1.1.4
|
||||
linux-manager linux-manager/int_gateway_ip string 10.1.1.1
|
||||
linux-manager linux-manager/local_fqdn string router.example.com
|
||||
linux-manager linux-manager/https_enabled boolean true
|
||||
linux-manager linux-manager/local_cidrs string 10.0.0.0/24
|
||||
linux-manager linux-manager/remote_addrs string peer.example.net
|
||||
linux-manager linux-manager/remote_id string peer.example.net
|
||||
@@ -146,12 +145,12 @@ must have the type shown below; an unknown section or setting is an error.
|
||||
| `web` | `log_files` | list | | Absolute paths of the log files `/logs` shows, at most 32 (see The /logs API) |
|
||||
| `web` | `shell_auth_timeout` | integer | `15` | Minutes after the last use of a shell in which a new shell opens without signing in again, 0 (always sign in) to 1440 |
|
||||
| `ssh` | `ldap_login` | boolean | `false` | sshd accepts the directory password of the console accounts in the directory (see Console login and SSH) |
|
||||
| `https` | `enabled` | boolean | `true` | Caddy serves the status web service and the Manager over HTTPS for `wan.local_fqdn` |
|
||||
| `https` | `email` | string | | The e-mail address of the ACME account |
|
||||
| `https` | `web_port` | integer | `7444` | HTTPS port of the status web service |
|
||||
| `https` | `manager_port` | integer | `7443` | HTTPS port of the Manager |
|
||||
| `https` | `disable_auto_redirect` | boolean | `false` | The Manager answers on its plain HTTP port instead of redirecting there to its HTTPS address while `enabled` is `true`; the status page never redirects |
|
||||
| `https` | `certificate` | string | `self-signed` | Where the certificate of `wan.local_fqdn` comes from: `self-signed`, `ca`, `acme` or `external`; empty in a new installation's file, or absent before the first successful setup, for its first setup to choose `ca` or `self-signed` and write it here (see HTTPS) |
|
||||
| `https` | `disable_auto_redirect` | boolean | `false` | The status page and the Manager answer by their HTTPS names on their plain HTTP ports instead of redirecting there to HTTPS (see HTTPS) |
|
||||
| `https` | `ip_sans` | boolean | `false` | The self-signed certificate and the one of the Servers Issuing CA also name the server's addresses, so HTTPS is reached by address too (see HTTPS) |
|
||||
| `https` | `certificate` | string | `self-signed` | Where the certificate of the HTTPS names comes from: `self-signed`, `ca`, `acme` or `external`; empty in a new installation's file, or absent before the first successful setup, for its first setup to choose `ca` or `self-signed` and write it here (see HTTPS) |
|
||||
| `https` | `self_signed_days` | integer | `365` | Days the self-signed certificate is valid, 1 to 3650 |
|
||||
| `https` | `acme_provider` | string | `letsencrypt` | The ACME CA of the server and of the web sites with `tls` `acme`: `letsencrypt`, `zerossl` or `custom` (see HTTPS) |
|
||||
| `https` | `acme_url` | string | | The `https://` ACME directory URL of `custom` |
|
||||
@@ -159,10 +158,10 @@ must have the type shown below; an unknown section or setting is an error.
|
||||
| `https` | `acme_eab_mac_key` | string | | The EAB MAC key of `custom` |
|
||||
| `https` | `zerossl_api_key` | string | | The ZeroSSL API key; without it the EAB credentials come from `email` |
|
||||
| `https` | `acme_staging` | boolean | `false` | With `letsencrypt`, Caddy takes its certificates from Let's Encrypt's staging environment, whose certificates no browser trusts and whose rate limits are higher, for routers rebuilt often (see HTTPS) |
|
||||
| `oidc` | `enabled` | boolean | `false` | The OpenID Provider at the status web service's HTTPS site, which needs `web.enabled`, `https.enabled` and `wan.local_fqdn` (see OpenID Provider) |
|
||||
| `oidc` | `enabled` | boolean | `false` | The OpenID Provider at the status web service's HTTPS site, which needs `web.enabled` (see OpenID Provider) |
|
||||
| `sites` | `enabled` | boolean | `false` | Caddy serves the web sites (see Web sites) |
|
||||
| `sites` | `upload_max_mb` | integer | `512` | The largest upload of a site's file or zip archive, in MiB, 1 to 10240 |
|
||||
| `sites` | `webdav` | boolean | `false` | WebDAV of the sites' folders, which needs `https.enabled` and `wan.local_fqdn` (see WebDAV) |
|
||||
| `sites` | `webdav` | boolean | `false` | WebDAV of the sites' folders, served over HTTPS for the HTTPS names (see WebDAV) |
|
||||
| `sites` | `webdav_port` | integer | `7445` | HTTPS port of WebDAV |
|
||||
| `dns` | `enabled` | boolean | `false` | The primary name server of the server's domains, `wan.local_fqdn`, which must then be a DNS name (see Name server) |
|
||||
| `dns` | `secondary` | string | | The optional secondary name server of every domain, a host name other than `wan.local_fqdn`; it may transfer the domains; empty, `wan.local_fqdn` is the only name server |
|
||||
@@ -185,7 +184,7 @@ must have the type shown below; an unknown section or setting is an error.
|
||||
| `metrics` | `enabled` | boolean | `true` | The metrics service: collection, history and `/metrics` |
|
||||
| `metrics` | `listen` | string | `internal` | The interfaces the firewall opens `metrics.port` on: `internal`, `external` or `both` |
|
||||
| `metrics` | `port` | integer | `9464` | TCP port of `/metrics`, served by Caddy over plain HTTP |
|
||||
| `metrics` | `https_port` | integer | `9465` | HTTPS port of `/metrics`, served by Caddy while `https.enabled` is true |
|
||||
| `metrics` | `https_port` | integer | `9465` | HTTPS port of `/metrics`, served by Caddy |
|
||||
| `metrics` | `service_account` | string | `metrics` | The service account `/metrics` takes, which `linux-manager-setup` adds and keeps |
|
||||
| `metrics` | `otlp_endpoint` | string | | An OTLP/HTTP URL the metrics are pushed to every minute, for example `https://collector.example.com:4318/v1/metrics` |
|
||||
| `metrics` | `otlp_username` | string | | The user name of HTTP Basic authentication at the OTLP endpoint |
|
||||
@@ -752,8 +751,8 @@ setup code. A retired issuing CA is revoked in Simple CA, where the server canno
|
||||
|
||||
### ACME server
|
||||
|
||||
A general-purpose CA with `"acme": true` backs an ACME server of Caddy, while `https.enabled`, at
|
||||
`https://<wan.local_fqdn>:<https.web_port>/acme/<name>/directory`, so servers get and renew
|
||||
A general-purpose CA with `"acme": true` backs an ACME server of Caddy, at
|
||||
`https://<HTTPS name>:<https.web_port>/acme/<name>/directory`, so servers get and renew
|
||||
certificates with any ACME client:
|
||||
|
||||
```sh
|
||||
@@ -1624,21 +1623,33 @@ and the facts for `/config` from `/run/linux-manager/web.json` (readable by root
|
||||
Caddy, a dependency of the package, serves every HTTP and HTTPS port of the server's services; the
|
||||
services listen on `127.0.0.1` only. Over plain HTTP it serves the status web service on
|
||||
`web.port` (7081 by default), the Manager on its `port` (7080), and while metrics are enabled the
|
||||
metrics service on `metrics.port` (9464). While `https.enabled` is `true` and `wan.local_fqdn` is
|
||||
set, it also serves the status web service on `https.web_port` (7444), the Manager on
|
||||
`https.manager_port` (7443), and while metrics are enabled the metrics service on
|
||||
`metrics.https_port` (9465), all for `wan.local_fqdn`.
|
||||
metrics service on `metrics.port` (9464). HTTPS is always on: Caddy also serves the status web
|
||||
service on `https.web_port` (7444), the Manager on `https.manager_port` (7443), and while metrics
|
||||
are enabled the metrics service on `metrics.https_port` (9465), all for the HTTPS names:
|
||||
|
||||
The installer asks whether to serve over HTTPS (`https_enabled`) and, with HTTPS, whether to keep
|
||||
the Manager on plain HTTP (`https_disable_auto_redirect`). While HTTPS is on, Caddy answers the
|
||||
Manager's plain HTTP port with a redirect (308) to the same path at
|
||||
`https://<wan.local_fqdn>:<https.manager_port>`, unless `https.disable_auto_redirect` is `true`.
|
||||
The status page never redirects and stays available over plain HTTP on `web.port` whether HTTPS
|
||||
is on or not.
|
||||
- `wan.local_fqdn` alone, when it is set;
|
||||
- without it, the host name and `<host name>.local`, which Avahi announces with mDNS on the
|
||||
internal side (the external interface of a server with one), where the firewall opens UDP 5353;
|
||||
Avahi is stopped while `wan.local_fqdn` is set.
|
||||
|
||||
With `https.ip_sans`, the self-signed certificate and the one of the Servers Issuing CA also name
|
||||
the server's addresses, those of its interfaces and `wan.public_address`, without link-local ones,
|
||||
and Caddy serves HTTPS on them too. It is off by default, as a server is rarely reached by address;
|
||||
a server that is the first device of a network can then be set up over HTTPS by address, once its
|
||||
certificate is accepted. A client without SNI gets the certificate of the first HTTPS name. An ACME
|
||||
certificate names `wan.local_fqdn` only, which `https.certificate` `acme` needs.
|
||||
|
||||
The installer asks whether to keep plain HTTP (`https_disable_auto_redirect`). Unless
|
||||
`https.disable_auto_redirect` is `true`, Caddy answers a plain HTTP request for an HTTPS name with a
|
||||
redirect (308) to the same host and path on HTTPS: on `web.port` to `https.web_port`, on the
|
||||
Manager's port to `https.manager_port`; with `https.ip_sans`, a request by address is an HTTPS
|
||||
host too. The status page stays available over plain HTTP by any other address; every other
|
||||
request on the Manager's port is redirected to the first HTTPS name. `/pki/` stays on plain HTTP
|
||||
on both ports. With the redirect off, both answer over plain HTTP by name and by address.
|
||||
|
||||
### The server's certificate
|
||||
|
||||
`https.certificate` says where the certificate of `wan.local_fqdn` comes from; it is `self-signed`
|
||||
`https.certificate` says where the certificate of the HTTPS names comes from; it is `self-signed`
|
||||
when the file of a server already set up does not set it, and ACME only when it is set to `acme`. The file a new installation
|
||||
writes has it empty, and that installation's first setup chooses it and writes it into the file:
|
||||
`ca` when the root CA and the Servers Issuing CA are available, as with a root the server creates,
|
||||
@@ -1650,7 +1661,7 @@ the Manager or the file, stays.
|
||||
| Source | The certificate |
|
||||
|---|---|
|
||||
| `acme` | obtained and renewed by Caddy from the ACME CA of `https.acme_provider`, with the HTTP challenge, so `wan.local_fqdn` resolves to the server's public address and port 80 is reachable from the internet; kept in `/var/lib/caddy` |
|
||||
| `self-signed` (the default) | made by the server, valid for `https.self_signed_days`, and made again when a third of it is left or `wan.local_fqdn` changes |
|
||||
| `self-signed` (the default) | made by the server, valid for `https.self_signed_days`, and made again when a third of it is left or its names or addresses change |
|
||||
| `ca` | issued and renewed by the Servers Issuing CA, `servers`, of the server's PKI (see Certificates), with the template `mtls` |
|
||||
| `external` | another CA's certificate, imported, from a CSR the server makes or as a PFX file |
|
||||
|
||||
@@ -1726,9 +1737,9 @@ Caddy is a dependency of the package, the `caddy` package of the Ubuntu archive,
|
||||
|
||||
While `oidc.enabled` is `true`, the status web service is an OpenID Provider (OpenID Connect
|
||||
Core 1.0) for the users of the directory. Its issuer is the web service's HTTPS site,
|
||||
`https://<wan.local_fqdn>:<https.web_port>`, without the port when it is 443; the web service
|
||||
answers it only on `127.0.0.1`, where Caddy passes the requests, so the provider is never reached
|
||||
over plain HTTP. The setting needs `web.enabled`, `https.enabled` and `wan.local_fqdn`.
|
||||
`https://<HTTPS name>:<https.web_port>`, the first HTTPS name, without the port when it is 443; the
|
||||
web service answers it only on `127.0.0.1`, where Caddy passes the requests, so the provider is
|
||||
never reached over plain HTTP. The setting needs `web.enabled`.
|
||||
|
||||
```sh
|
||||
linux-manager-config-edit set --restart oidc.enabled true
|
||||
|
||||
@@ -67,7 +67,6 @@ fi
|
||||
db_go || true
|
||||
|
||||
db_input high linux-manager/local_fqdn || true
|
||||
db_input high linux-manager/https_enabled || true
|
||||
if [ "$ROUTER" = "true" ] || [ "$VPN" = "true" ]; then
|
||||
db_input high linux-manager/local_cidrs || true
|
||||
fi
|
||||
@@ -85,11 +84,8 @@ if [ "$VPN" = "true" ]; then
|
||||
fi
|
||||
db_go || true
|
||||
|
||||
db_get linux-manager/https_enabled
|
||||
if [ "$RET" = "true" ]; then
|
||||
db_input high linux-manager/https_disable_auto_redirect || true
|
||||
db_go || true
|
||||
fi
|
||||
db_input high linux-manager/https_disable_auto_redirect || true
|
||||
db_go || true
|
||||
|
||||
db_get linux-manager/pki_root
|
||||
if [ "$RET" = "local" ]; then
|
||||
|
||||
@@ -25,6 +25,7 @@ Depends: ${misc:Depends},
|
||||
python3-prometheus-client,
|
||||
python3-requests,
|
||||
caddy,
|
||||
avahi-daemon,
|
||||
postgresql,
|
||||
slapd,
|
||||
nslcd,
|
||||
|
||||
@@ -24,7 +24,6 @@ case "$1" in
|
||||
answer linux-manager/external_interface; LINUX_MANAGER_EXTERNAL_INTERFACE="$ANSWER"
|
||||
answer linux-manager/internal_interface; LINUX_MANAGER_INTERNAL_INTERFACE="$ANSWER"
|
||||
answer linux-manager/local_fqdn; LINUX_MANAGER_LOCAL_FQDN="$ANSWER"
|
||||
answer linux-manager/https_enabled; LINUX_MANAGER_HTTPS_ENABLED="$ANSWER"
|
||||
answer linux-manager/https_disable_auto_redirect; LINUX_MANAGER_HTTPS_DISABLE_AUTO_REDIRECT="$ANSWER"
|
||||
answer linux-manager/local_id_mode; LINUX_MANAGER_LOCAL_ID_MODE="$ANSWER"
|
||||
answer linux-manager/local_cidrs; LINUX_MANAGER_LOCAL_CIDRS="$ANSWER"
|
||||
@@ -46,7 +45,7 @@ case "$1" in
|
||||
LINUX_MANAGER_ROUTER_ENABLED LINUX_MANAGER_VPN_ENABLED \
|
||||
LINUX_MANAGER_EXTERNAL_INTERFACE \
|
||||
LINUX_MANAGER_INTERNAL_INTERFACE LINUX_MANAGER_LOCAL_FQDN \
|
||||
LINUX_MANAGER_HTTPS_ENABLED LINUX_MANAGER_HTTPS_DISABLE_AUTO_REDIRECT \
|
||||
LINUX_MANAGER_HTTPS_DISABLE_AUTO_REDIRECT \
|
||||
LINUX_MANAGER_LOCAL_ID_MODE LINUX_MANAGER_LOCAL_CIDRS \
|
||||
LINUX_MANAGER_INT_GATEWAY_IP \
|
||||
LINUX_MANAGER_REMOTE_ADDRS LINUX_MANAGER_REMOTE_ID \
|
||||
|
||||
@@ -95,22 +95,15 @@ Description: Local router FQDN:
|
||||
router.example.com). Used as the IKEv2 server identity and
|
||||
certificate common name.
|
||||
|
||||
Template: linux-manager/https_enabled
|
||||
Type: boolean
|
||||
Default: true
|
||||
Description: Serve the status page and the Manager over HTTPS?
|
||||
If enabled, Caddy serves the status page and the Manager over HTTPS for the
|
||||
router FQDN, with a certificate of the Servers Issuing CA when the server
|
||||
creates its root CA, and a self-signed one otherwise. The status page stays
|
||||
available over plain HTTP either way.
|
||||
|
||||
Template: linux-manager/https_disable_auto_redirect
|
||||
Type: boolean
|
||||
Default: false
|
||||
Description: Keep the Manager available over plain HTTP?
|
||||
If enabled, the Manager answers on its plain HTTP port. Otherwise, while
|
||||
HTTPS is on, it redirects there to its HTTPS address. The status page never
|
||||
redirects.
|
||||
Description: Keep the status page and the Manager available over plain HTTP?
|
||||
Caddy always serves the status page and the Manager over HTTPS, for the
|
||||
router FQDN or, without one, for the host name and <host name>.local. If
|
||||
enabled, both also answer on their plain HTTP ports by name. Otherwise a
|
||||
request by name on those ports is redirected to HTTPS; the status page stays
|
||||
available over plain HTTP by address.
|
||||
|
||||
Template: linux-manager/local_id_mode
|
||||
Type: select
|
||||
|
||||
@@ -43,7 +43,6 @@ ANSWERS = {
|
||||
'LINUX_MANAGER_EXTERNAL_INTERFACE': (('interfaces', 'external'),),
|
||||
'LINUX_MANAGER_INTERNAL_INTERFACE': (('interfaces', 'internal'),),
|
||||
'LINUX_MANAGER_LOCAL_FQDN': (('wan', 'local_fqdn'),),
|
||||
'LINUX_MANAGER_HTTPS_ENABLED': (('https', 'enabled'),),
|
||||
'LINUX_MANAGER_HTTPS_DISABLE_AUTO_REDIRECT': (('https', 'disable_auto_redirect'),),
|
||||
'LINUX_MANAGER_LOCAL_ID_MODE': ((*FIRST, 'local_id_mode'),),
|
||||
'LINUX_MANAGER_LOCAL_CIDRS': (('local', 'cidrs'), (*FIRST, 'local_cidrs')),
|
||||
|
||||
@@ -12,6 +12,7 @@ import os
|
||||
import pathlib
|
||||
import re
|
||||
import shutil
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -79,7 +80,7 @@ SCHEMA = {
|
||||
'status_content': 'basic', 'shell': False, 'shell_idle_minutes': 15, 'shell_auth_timeout': 15,
|
||||
'log_files': []},
|
||||
'ssh': {'ldap_login': False},
|
||||
'https': {'enabled': True, 'email': '', 'web_port': 7444, 'manager_port': 7443,
|
||||
'https': {'email': '', 'web_port': 7444, 'manager_port': 7443, 'ip_sans': False,
|
||||
'disable_auto_redirect': False, 'acme_staging': False, 'certificate': 'self-signed', 'self_signed_days': 365,
|
||||
'acme_provider': 'letsencrypt', 'acme_url': '', 'acme_eab_key_id': '', 'acme_eab_mac_key': '',
|
||||
'zerossl_api_key': ''},
|
||||
@@ -172,8 +173,8 @@ UPLOAD_MAX_MB = 10240
|
||||
|
||||
#: Settings that no longer exist, section -> options, left out when the file is read so that a file of an earlier
|
||||
#: version loads: the name server is wan.local_fqdn, a site chooses the address of its records, and the CA certificates
|
||||
#: and CRLs are always published.
|
||||
RETIRED = {'dns': ('nameserver', 'addresses'), 'pki': ('publish',)}
|
||||
#: and CRLs are always published, and HTTPS is always on.
|
||||
RETIRED = {'dns': ('nameserver', 'addresses'), 'pki': ('publish',), 'https': ('enabled',)}
|
||||
|
||||
#: The shortest and the longest dns.ttl, in seconds.
|
||||
DNS_TTL_RANGE = (60, 86400)
|
||||
@@ -684,19 +685,16 @@ def validate(cfg):
|
||||
for option in ('email', 'acme_url', 'acme_eab_key_id', 'acme_eab_mac_key', 'zerossl_api_key'):
|
||||
if any(character.isspace() or character in '{}"' for character in _get(cfg, 'https', option)):
|
||||
raise ConfigError(f'https.{option} must not hold spaces, braces or quotes')
|
||||
if _get(cfg, 'https', 'certificate') == 'acme' and not _get(cfg, 'wan', 'local_fqdn'):
|
||||
raise ConfigError('https.certificate: an ACME CA issues the certificate of wan.local_fqdn, which is not set')
|
||||
|
||||
if _get(cfg, 'oidc', 'enabled') and not (_get(cfg, 'web', 'enabled') and _get(cfg, 'https', 'enabled')
|
||||
and _get(cfg, 'wan', 'local_fqdn')):
|
||||
if _get(cfg, 'oidc', 'enabled') and not _get(cfg, 'web', 'enabled'):
|
||||
raise ConfigError('oidc.enabled: the OpenID Provider is the web service served by Caddy at '
|
||||
'https://<wan.local_fqdn>:<https.web_port>, which needs web.enabled, https.enabled and '
|
||||
'wan.local_fqdn')
|
||||
'https://<HTTPS name>:<https.web_port>, which needs web.enabled')
|
||||
|
||||
upload_max = _get(cfg, 'sites', 'upload_max_mb')
|
||||
if not 1 <= upload_max <= UPLOAD_MAX_MB:
|
||||
raise ConfigError(f'sites.upload_max_mb: {upload_max} is not between 1 and {UPLOAD_MAX_MB}')
|
||||
if _get(cfg, 'sites', 'webdav') and not (_get(cfg, 'https', 'enabled') and _get(cfg, 'wan', 'local_fqdn')):
|
||||
raise ConfigError('sites.webdav: WebDAV is served by Caddy at https://<wan.local_fqdn>:<sites.webdav_port>, '
|
||||
'which needs https.enabled and wan.local_fqdn')
|
||||
|
||||
_check_address(_get(cfg, 'wan', 'public_address'), 'wan.public_address')
|
||||
dns = cfg['dns']
|
||||
@@ -805,8 +803,6 @@ def validate(cfg):
|
||||
raise ConfigError(f'{prefix}.templates: {template!r} is not a template')
|
||||
if template in ROUTER_TEMPLATES:
|
||||
raise ConfigError(f'{prefix}.templates: {template} is issued by the P2S CA only')
|
||||
if authority['acme'] and not _get(cfg, 'https', 'enabled'):
|
||||
raise ConfigError(f'{prefix}.acme: the ACME server is Caddy\'s, which needs https.enabled')
|
||||
|
||||
taken = {web_port: 'web.port', ACME_HTTP_PORT: 'the HTTP challenge',
|
||||
https_ports[0]: 'https.web_port', https_ports[1]: 'https.manager_port'}
|
||||
@@ -898,9 +894,7 @@ def validate(cfg):
|
||||
f'docker.exposed_ports: {item!r} is not a port or a port range')
|
||||
weight += 2 if ':' in item else 1
|
||||
first, _, last = item.partition(':')
|
||||
caddy_ports = (web_port, manager_port(), _get(cfg, 'metrics', 'port'),
|
||||
*((ACME_HTTP_PORT, *https_ports)
|
||||
if _get(cfg, 'https', 'enabled') else ()))
|
||||
caddy_ports = (web_port, manager_port(), _get(cfg, 'metrics', 'port'), ACME_HTTP_PORT, *https_ports)
|
||||
for port in caddy_ports:
|
||||
if int(first) <= port <= int(last or first):
|
||||
raise ConfigError(f'docker.exposed_ports: {item!r} takes port {port}, which Caddy serves')
|
||||
@@ -973,9 +967,10 @@ def manager_listen():
|
||||
|
||||
|
||||
def oidc_issuer(cfg):
|
||||
"""The issuer of the OpenID Provider: the web service's HTTPS site, without the port when it is HTTPS_DEFAULT_PORT."""
|
||||
"""The issuer of the OpenID Provider: the web service's HTTPS site on the first HTTPS name, without the port when it
|
||||
is HTTPS_DEFAULT_PORT."""
|
||||
port = _get(cfg, 'https', 'web_port')
|
||||
return f'https://{_get(cfg, "wan", "local_fqdn")}' + ('' if port == HTTPS_DEFAULT_PORT else f':{port}')
|
||||
return f'https://{https_names(cfg)[0]}' + ('' if port == HTTPS_DEFAULT_PORT else f':{port}')
|
||||
|
||||
|
||||
def resolve_psk(connection, name):
|
||||
@@ -1177,7 +1172,9 @@ def build_context(cfg, public_ip=None):
|
||||
'web_enabled': _get(cfg, 'web', 'enabled'),
|
||||
'web_port': _get(cfg, 'web', 'port'),
|
||||
'web_listen': _get(cfg, 'web', 'listen'),
|
||||
'https_enabled': _get(cfg, 'https', 'enabled'),
|
||||
'https_names': https_names(cfg),
|
||||
'https_ips': https_addresses(cfg, local_addrs, int_addr),
|
||||
'mdns': not local_fqdn,
|
||||
'https_email': _get(cfg, 'https', 'email'),
|
||||
'https_certificate': _get(cfg, 'https', 'certificate'),
|
||||
'https_acme_provider': _get(cfg, 'https', 'acme_provider'),
|
||||
@@ -1241,9 +1238,30 @@ def vpn_pools(ctx):
|
||||
(wg_ready(ctx), ctx['wg_network'])) if ready]
|
||||
|
||||
|
||||
def https_ready(ctx):
|
||||
"""Caddy serves HTTPS once it is enabled and wan.local_fqdn names the certificate."""
|
||||
return bool(ctx['https_enabled'] and ctx['local_fqdn'])
|
||||
def https_names(cfg):
|
||||
"""The names of the server's HTTPS certificate and sites: wan.local_fqdn alone when it is set, else the host name
|
||||
and <host name>.local, which Avahi announces with mDNS."""
|
||||
fqdn = _get(cfg, 'wan', 'local_fqdn').lower()
|
||||
if fqdn:
|
||||
return [fqdn]
|
||||
host = socket.gethostname().split('.')[0].lower()
|
||||
return [host, f'{host}.local']
|
||||
|
||||
|
||||
def https_addresses(cfg, local_addrs, int_addr):
|
||||
"""The IP addresses of the server's HTTPS certificate and sites while https.ip_sans is on: those of its interfaces
|
||||
and wan.public_address, without link-local ones; [] while it is off."""
|
||||
if not _get(cfg, 'https', 'ip_sans'):
|
||||
return []
|
||||
found = []
|
||||
for value in (*local_addrs, int_addr, _get(cfg, 'wan', 'public_address')):
|
||||
try:
|
||||
address = ipaddress.ip_address(str(value).split('/')[0])
|
||||
except ValueError:
|
||||
continue
|
||||
if not address.is_link_local and str(address) not in found:
|
||||
found.append(str(address))
|
||||
return found
|
||||
|
||||
|
||||
def metrics_ready(ctx):
|
||||
@@ -1252,8 +1270,8 @@ def metrics_ready(ctx):
|
||||
|
||||
|
||||
def webdav_ready(ctx):
|
||||
"""WebDAV of the sites' folders is served by Caddy, on the server's own name, while it is on and HTTPS is ready."""
|
||||
return bool(ctx['webdav_enabled'] and https_ready(ctx))
|
||||
"""WebDAV of the sites' folders is served by Caddy, on the server's HTTPS names, while it is on."""
|
||||
return bool(ctx['webdav_enabled'])
|
||||
|
||||
|
||||
def packages_installed(packages):
|
||||
|
||||
@@ -592,11 +592,14 @@ def is_address(value):
|
||||
|
||||
def router_identities(name, ctx):
|
||||
"""The common name and the subject alternative names of one of the server's certificates (ROUTER_CERTS): the VPN
|
||||
server and the HTTPS certificates name wan.local_fqdn, and the site-to-site certificate also the local identity of each
|
||||
site_to_site connection with certificate authentication, the public or the internal address of its
|
||||
local_id_mode; None while such an identity is not known yet."""
|
||||
server certificate names wan.local_fqdn, the HTTPS certificate its HTTPS names and addresses (https_sans), and the
|
||||
site-to-site certificate wan.local_fqdn and the local identity of each site_to_site connection with certificate
|
||||
authentication, the public or the internal address of its local_id_mode; None while such an identity is not known
|
||||
yet."""
|
||||
fqdn = ctx['local_fqdn']
|
||||
if name in ('vpn-server', 'https'):
|
||||
if name == 'https':
|
||||
return https_sans(ctx)[0], https_sans(ctx)
|
||||
if name == 'vpn-server':
|
||||
return fqdn, [fqdn]
|
||||
names = [fqdn]
|
||||
for connection in ctx['connections']:
|
||||
@@ -620,7 +623,7 @@ def ensure_router_cert(connection, cfg, ctx, name, urls):
|
||||
return
|
||||
subject, sans = identities
|
||||
current = holders(connection, ca, router_condition(name))
|
||||
wanted = {f'IP:{value}' if is_address(value) else f'DNS:{value.lower()}' for value in sans}
|
||||
wanted = san_set(sans)
|
||||
if current:
|
||||
_, cert, _ = current[0]
|
||||
if not renewal_due(cert) and issued_by(cert, issuer['cert']) and common_name(cert) == subject and \
|
||||
@@ -916,10 +919,21 @@ def chain_pem(chain):
|
||||
return b''.join(cert_pem(cert) for cert in chain)
|
||||
|
||||
|
||||
def https_sans(ctx):
|
||||
"""The subject alternative names of the server's HTTPS certificate, the first its common name: its HTTPS names
|
||||
(linuxmanager.https_names) and, while https.ip_sans is on, its addresses (linuxmanager.https_addresses)."""
|
||||
return [*ctx['https_names'], *ctx['https_ips']]
|
||||
|
||||
|
||||
def san_set(values):
|
||||
"""The SAN values of a certificate (san_values) that names the DNS names and IP addresses of values name."""
|
||||
return {f'IP:{value}' if is_address(value) else f'DNS:{value.lower()}' for value in values}
|
||||
|
||||
|
||||
def served_certificate(connection, cfg):
|
||||
"""What Caddy serves for wan.local_fqdn: (served, chain, key), served being https.certificate, or self-signed while
|
||||
"""What Caddy serves for the HTTPS names: (served, chain, key), served being https.certificate, or self-signed while
|
||||
the chosen certificate is not available; (acme, [], None) with acme, and (None, [], None) while there is none."""
|
||||
source, fqdn = cfg['https']['certificate'], cfg['wan']['local_fqdn'].strip().lower()
|
||||
source, fqdn = cfg['https']['certificate'], linuxmanager.https_names(cfg)[0]
|
||||
if source == 'acme':
|
||||
return 'acme', [], None
|
||||
if source == 'ca':
|
||||
@@ -935,22 +949,25 @@ def served_certificate(connection, cfg):
|
||||
return None, [], None
|
||||
|
||||
|
||||
def ensure_host_cert(connection, cfg):
|
||||
"""Make the self-signed certificate of wan.local_fqdn while https.certificate is self-signed, or while the chosen
|
||||
certificate is not available, when there is none, it is due for renewal or it names another name; the notices."""
|
||||
source, fqdn = cfg['https']['certificate'], cfg['wan']['local_fqdn'].strip().lower()
|
||||
if source == 'acme' or not cfg['https']['enabled'] or not fqdn:
|
||||
def ensure_host_cert(connection, cfg, ctx):
|
||||
"""Make the self-signed certificate of the HTTPS names and addresses (https_sans) while https.certificate is
|
||||
self-signed, or while the chosen certificate is not available, when there is none, it is due for renewal or it names
|
||||
other names; the notices."""
|
||||
source, sans = cfg['https']['certificate'], https_sans(ctx)
|
||||
fqdn = sans[0]
|
||||
if source == 'acme':
|
||||
return []
|
||||
served, _, _ = served_certificate(connection, cfg)
|
||||
if served == source and served != 'self-signed':
|
||||
return []
|
||||
entry = host_entry(connection)
|
||||
current = entry['chain'][0] if entry and entry['kind'] == 'self-signed' and entry['chain'] else None
|
||||
if current is None or renewal_due(current) or not usable(current, fqdn) or common_name(current) != fqdn:
|
||||
if current is None or renewal_due(current) or not usable(current, fqdn) or common_name(current) != fqdn or \
|
||||
set(san_values(current)) != san_set(sans):
|
||||
template = linuxmanager.pki_templates(cfg)['mtls']
|
||||
key = new_key(template['key'])
|
||||
cert = sign(fqdn, key.public_key(), None, key, cfg['https']['self_signed_days'],
|
||||
leaf_extensions(cfg, template, general_names([fqdn], {'dns'})))
|
||||
leaf_extensions(cfg, template, general_names(sans, {'dns', 'ip'})))
|
||||
update_host(connection, {'linuxManagerCertificateChain': cert_pem(cert), 'linuxManagerPrivateKey': key_pem(key),
|
||||
'linuxManagerKind': b'self-signed'})
|
||||
if source == 'self-signed':
|
||||
@@ -961,7 +978,7 @@ def ensure_host_cert(connection, cfg):
|
||||
|
||||
|
||||
def https_files(cfg):
|
||||
"""The PEM chain and key Caddy serves for wan.local_fqdn, None with https.certificate acme or while there is none."""
|
||||
"""The PEM chain and key Caddy serves for the HTTPS names, None with https.certificate acme or while there is none."""
|
||||
with directory() as connection:
|
||||
served, chain, key = served_certificate(connection, cfg)
|
||||
if served in (None, 'acme'):
|
||||
@@ -988,14 +1005,13 @@ def https_status(cfg):
|
||||
|
||||
|
||||
def https_csr(cfg):
|
||||
"""Make a key and a CSR for wan.local_fqdn, to be signed by another CA, replacing a pending one: {csr} in PEM."""
|
||||
fqdn = cfg['wan']['local_fqdn'].strip().lower()
|
||||
if not fqdn:
|
||||
raise Failure('the server has no wan.local_fqdn', 4)
|
||||
"""Make a key and a CSR for the HTTPS names (linuxmanager.https_names), to be signed by another CA, replacing a
|
||||
pending one: {csr} in PEM."""
|
||||
names = linuxmanager.https_names(cfg)
|
||||
key = new_key(linuxmanager.pki_templates(cfg)['mtls']['key'])
|
||||
request = (x509.CertificateSigningRequestBuilder()
|
||||
.subject_name(x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, fqdn)]))
|
||||
.add_extension(x509.SubjectAlternativeName([x509.DNSName(fqdn)]), False)
|
||||
.subject_name(x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, names[0])]))
|
||||
.add_extension(x509.SubjectAlternativeName(general_names(names, {'dns', 'ip'})), False)
|
||||
.sign(key, digest(key)))
|
||||
pem = request.public_bytes(serialization.Encoding.PEM)
|
||||
with directory() as connection:
|
||||
@@ -1005,8 +1021,8 @@ def https_csr(cfg):
|
||||
|
||||
def keep_external(connection, cfg, chain, key):
|
||||
"""Keep an imported certificate of another CA as the server's HTTPS certificate: it must be the key's, valid now
|
||||
and name wan.local_fqdn; {subject, issuer, expires}."""
|
||||
fqdn = cfg['wan']['local_fqdn'].strip().lower()
|
||||
and name the first HTTPS name (linuxmanager.https_names); {subject, issuer, expires}."""
|
||||
fqdn = linuxmanager.https_names(cfg)[0]
|
||||
if cfg['https']['certificate'] != 'external':
|
||||
raise Failure('https.certificate is not external', 4)
|
||||
cert = chain[0]
|
||||
@@ -1160,11 +1176,11 @@ def provision(cfg, ctx):
|
||||
if not cfg['https']['certificate']:
|
||||
servers = authority(connection, 'servers')
|
||||
linuxmanager.choose_https_certificate(cfg, ctx, 'ca' if servers and servers['cert'] is not None else 'self-signed')
|
||||
https_ca = cfg['https']['enabled'] and cfg['https']['certificate'] == 'ca'
|
||||
https_ca = cfg['https']['certificate'] == 'ca'
|
||||
for name in ROUTER_CERTS:
|
||||
if component_on(ROUTER_CERTS[name][0]) and (name != 'https' or https_ca):
|
||||
ensure_router_cert(connection, cfg, ctx, name, urls)
|
||||
notices.extend(ensure_host_cert(connection, cfg))
|
||||
notices.extend(ensure_host_cert(connection, cfg, ctx))
|
||||
publish(connection)
|
||||
p2s = authority(connection, 'p2s')
|
||||
missing = connection.search_s(linuxmanager_ldap.USERS, ldap.SCOPE_ONELEVEL,
|
||||
@@ -1589,7 +1605,7 @@ def maintain(cfg):
|
||||
|
||||
def acme_url(cfg, name):
|
||||
"""The ACME directory of an issuing CA served by Caddy's ACME server."""
|
||||
return f'https://{cfg["wan"]["local_fqdn"].strip()}:{cfg["https"]["web_port"]}/acme/{name}/directory'
|
||||
return f'https://{linuxmanager.https_names(cfg)[0]}:{cfg["https"]["web_port"]}/acme/{name}/directory'
|
||||
|
||||
|
||||
def status(cfg):
|
||||
@@ -1691,7 +1707,7 @@ def status(cfg):
|
||||
if utc(cert, 'not_valid_after') <= soon:
|
||||
warnings.append(f'the server certificate {common_name(cert)} expires on {iso(utc(cert, "not_valid_after"))}')
|
||||
https_source = cfg['https']['certificate']
|
||||
if cfg['https']['enabled'] and https_source != 'acme':
|
||||
if https_source != 'acme':
|
||||
if served != https_source:
|
||||
warnings.append(f'the HTTPS certificate is {"self-signed" if served else "missing"} until the https.certificate '
|
||||
f'{https_source} certificate is available')
|
||||
|
||||
@@ -11,7 +11,7 @@ import linuxmanager_pki
|
||||
from .common import PKI_STATUS, section_change
|
||||
|
||||
#: The settings of the https section PUT /https/settings changes.
|
||||
CHANGEABLE = ('acme_staging', 'certificate', 'self_signed_days', 'acme_provider', 'acme_url', 'acme_eab_key_id',
|
||||
CHANGEABLE = ('acme_staging', 'certificate', 'self_signed_days', 'ip_sans', 'acme_provider', 'acme_url', 'acme_eab_key_id',
|
||||
'acme_eab_mac_key', 'zerossl_api_key')
|
||||
|
||||
#: The secrets of the https section, which the answers give as <name>_set instead.
|
||||
@@ -34,7 +34,7 @@ def https(method, path, body):
|
||||
server's HTTPS certificate (linuxmanager_pki.https_status)
|
||||
PUT /https/settings change any of CHANGEABLE; the other settings of the section are changed on the server
|
||||
with linux-manager-config-edit, and a body naming one is 400
|
||||
POST /https/csr make a key and a CSR for wan.local_fqdn: {"csr"}
|
||||
POST /https/csr make a key and a CSR for the HTTPS names: {"csr"}
|
||||
PUT /https/certificate take the certificate another CA signed for the CSR, PEM with its chain: {"certificate"}
|
||||
PUT /https/pfx take a PKCS#12 file of another CA's certificate: {"pfx" in base64, "password"}
|
||||
|
||||
|
||||
@@ -80,9 +80,15 @@ CADDY_PKI_DIR = pathlib.Path('/etc/caddy/linux-manager-pki')
|
||||
#: The certificates and keys of the sites of tls file, <site>/cert.pem and key.pem.
|
||||
CADDY_SITES_DIR = pathlib.Path('/etc/caddy/linux-manager-sites')
|
||||
|
||||
#: The certificate and key of wan.local_fqdn Caddy serves when they come from no ACME CA.
|
||||
#: The certificate and key of the HTTPS names Caddy serves when they come from no ACME CA.
|
||||
CADDY_HTTPS_DIR = pathlib.Path('/etc/caddy/linux-manager-https')
|
||||
|
||||
#: The units of Avahi, which announces <host name>.local with mDNS while wan.local_fqdn is not set.
|
||||
AVAHI_UNITS = ('avahi-daemon.socket', 'avahi-daemon.service')
|
||||
|
||||
#: The UDP port of mDNS.
|
||||
MDNS_PORT = 5353
|
||||
|
||||
#: The unit of dnsmasq, the resolver of the remote access clients.
|
||||
RESOLVER_UNIT = 'linux-manager-resolver.service'
|
||||
|
||||
@@ -122,6 +128,7 @@ BLOCKS = (
|
||||
('# BOOTSTRAP RULES START', '# BOOTSTRAP RULES END'),
|
||||
('# MANAGER RULES START', '# MANAGER RULES END'),
|
||||
('# HTTPS RULES START', '# HTTPS RULES END'),
|
||||
('# MDNS RULES START', '# MDNS RULES END'),
|
||||
('# METRICS RULES START', '# METRICS RULES END'),
|
||||
('# SITES RULES START', '# SITES RULES END'),
|
||||
('# DNS RULES START', '# DNS RULES END'),
|
||||
@@ -200,19 +207,6 @@ def strip_blocks(text):
|
||||
return ''.join(out)
|
||||
|
||||
|
||||
def is_configured(ctx):
|
||||
"""True once any feature is actually configured: routing, a VPN system, or a listener of the core.
|
||||
|
||||
While nothing is configured the package leaves the firewall alone: an
|
||||
install that has not been filled in yet must not start blocking traffic on
|
||||
a host that was working before.
|
||||
"""
|
||||
return any((linuxmanager.s2s_ready(ctx), linuxmanager.routing_ready(ctx),
|
||||
linuxmanager.p2s_ready(ctx), linuxmanager.wg_ready(ctx),
|
||||
linuxmanager.openvpn_ready(ctx), ctx['web_enabled'], linuxmanager.https_ready(ctx),
|
||||
linuxmanager.metrics_ready(ctx), linuxmanager.dns_ready(ctx), bool(ctx['sites'])))
|
||||
|
||||
|
||||
def filter_block(ctx):
|
||||
lines = []
|
||||
|
||||
@@ -277,6 +271,11 @@ def filter_block(ctx):
|
||||
if ctx['web_enabled']:
|
||||
lines += ['', '# WEB RULES START', *opened(ctx['web_listen'], ctx['web_port']), '# WEB RULES END']
|
||||
|
||||
# Without wan.local_fqdn, Avahi answers mDNS queries for <host name>.local on the internal side.
|
||||
if ctx['mdns'] and internal:
|
||||
lines += ['', '# MDNS RULES START', f'-A ufw-before-input -i {internal} -p udp --dport {MDNS_PORT} -j ACCEPT',
|
||||
'# MDNS RULES END']
|
||||
|
||||
if not SETUP_DONE.exists() and ctx['int_iface']:
|
||||
lines += [
|
||||
'',
|
||||
@@ -295,7 +294,7 @@ def filter_block(ctx):
|
||||
|
||||
# The ACME CA reaches the HTTP challenge on the external interface while it issues the server's certificate; the
|
||||
# HTTPS ports are open on both.
|
||||
if linuxmanager.https_ready(ctx) and interfaces:
|
||||
if interfaces:
|
||||
ports = [port for wanted, port in ((ctx['web_enabled'] or ctx['pki_acme'], ctx['https_web_port']),
|
||||
(True, ctx['https_manager_port']),
|
||||
(linuxmanager.metrics_ready(ctx), ctx['metrics_https_port']),
|
||||
@@ -431,17 +430,6 @@ def setup_ufw(ctx):
|
||||
if not BEFORE_RULES.is_file():
|
||||
fail(f'{BEFORE_RULES} does not exist')
|
||||
|
||||
# Nothing configured: remove anything left from an earlier configuration
|
||||
# and touch nothing else.
|
||||
if not is_configured(ctx):
|
||||
original = BEFORE_RULES.read_text(encoding='utf-8')
|
||||
text = strip_blocks(original)
|
||||
if text == original:
|
||||
return False
|
||||
BEFORE_RULES.write_text(text, encoding='utf-8')
|
||||
remove_stale_nat(original, text)
|
||||
return True
|
||||
|
||||
if UFW_DEFAULTS.is_file():
|
||||
text = UFW_DEFAULTS.read_text(encoding='utf-8')
|
||||
updated = ''.join(
|
||||
@@ -728,6 +716,16 @@ def caddy_address(host, port, tls):
|
||||
return f'{"http://" if tls == "none" else ""}{host}:{port}'
|
||||
|
||||
|
||||
def manage_mdns(ctx):
|
||||
"""Run Avahi, which announces <host name>.local, one of the HTTPS names, with mDNS, while wan.local_fqdn is not set,
|
||||
and stop it while it is."""
|
||||
active = unit_is_active(AVAHI_UNITS[1])
|
||||
if ctx['mdns'] and not active:
|
||||
run(['systemctl', 'enable', '--now', *AVAHI_UNITS], check=False)
|
||||
elif not ctx['mdns'] and active:
|
||||
run(['systemctl', 'disable', '--now', *AVAHI_UNITS], check=False)
|
||||
|
||||
|
||||
def manage_resolver(changed):
|
||||
"""Run dnsmasq, the resolver of the remote access clients, while configure wrote its configuration, restarting it when
|
||||
that changed, and stop it when not. It starts after systemd-resolved has left the addresses it takes."""
|
||||
@@ -745,11 +743,14 @@ def manage_caddy(cfg, ctx):
|
||||
"""Run Caddy, a dependency of the package, which serves every HTTP and HTTPS port of the server's services and the
|
||||
web sites; the services listen on loopback only.
|
||||
|
||||
CADDYFILE serves over plain HTTP the web service on web.port while it is enabled, the manager on its port, or a
|
||||
redirect (308) to its HTTPS address while HTTPS is ready and https.disable_auto_redirect is off, and while metrics
|
||||
are enabled the metrics service on metrics.port. While HTTPS is ready, it serves the web service on
|
||||
https.web_port, the manager on https.manager_port, while metrics are enabled the metrics service on
|
||||
metrics.https_port, and while WebDAV is ready WebDAV on sites.webdav_port, all for wan.local_fqdn. Every site calls
|
||||
CADDYFILE serves over plain HTTP the web service on web.port while it is enabled and the manager on its port, and
|
||||
while metrics are enabled the metrics service on metrics.port. While https.disable_auto_redirect is off, a request
|
||||
of the web service for an HTTPS host is redirected (308) to https.web_port, and every request of the manager to
|
||||
https.manager_port, on the host it named when that is an HTTPS host, else on the first HTTPS name. It serves the
|
||||
web service on https.web_port, the manager on https.manager_port, while metrics are enabled the metrics service on
|
||||
metrics.https_port, and while WebDAV is ready WebDAV on sites.webdav_port, all for the HTTPS hosts: the HTTPS names
|
||||
(linuxmanager.https_names) and, with https.ip_sans and a certificate of its own, the addresses its certificate
|
||||
names; a client without SNI gets the certificate of the first HTTPS name. Every site calls
|
||||
its service on its loopback port. The certificate comes from the ACME CA of https.acme_provider, the global issuer,
|
||||
with https.certificate acme, and otherwise is the one linuxmanager_pki.https_files gives, written to
|
||||
CADDY_HTTPS_DIR; while that cannot be read, the HTTPS sites are left out, so that no ACME CA is asked for it. It
|
||||
@@ -774,7 +775,7 @@ def manage_caddy(cfg, ctx):
|
||||
group = grp.getgrnam(CADDY_GROUP).gr_gid
|
||||
except KeyError:
|
||||
fail(f'the group {CADDY_GROUP} does not exist; is the caddy package installed?')
|
||||
https = linuxmanager.https_ready(ctx)
|
||||
https = True
|
||||
own = None
|
||||
if https and cfg['https']['certificate'] != 'acme':
|
||||
try:
|
||||
@@ -832,8 +833,12 @@ def manage_caddy(cfg, ctx):
|
||||
os.chown(folder / file, 0, group)
|
||||
linuxmanager_sites.ensure_folders(site['name'] for site in sites)
|
||||
names = linuxmanager.issuing_cas(cfg)
|
||||
hosts = [*ctx['https_names'], *(ctx['https_ips'] if own is not None else [])]
|
||||
caddy_ctx = dict(ctx, https=https, manager_port=linuxmanager.manager_port(),
|
||||
redirect=https and not cfg['https']['disable_auto_redirect'],
|
||||
https_name=ctx['https_names'][0],
|
||||
https_hosts=[f'[{host}]' if ':' in host else host for host in hosts],
|
||||
redirect_hosts=[host for host in hosts if ':' not in host],
|
||||
web_loopback_port=linuxmanager.WEB_LOOPBACK_PORT,
|
||||
manager_loopback_port=linuxmanager.MANAGER_LOOPBACK_PORT,
|
||||
metrics_loopback_port=linuxmanager.METRICS_LOOPBACK_PORT,
|
||||
@@ -1043,6 +1048,8 @@ def refresh_web(cfg, ctx):
|
||||
'external_addresses': ctx['local_addr_list'],
|
||||
'internal_address': ctx['int_addr'],
|
||||
'internal_gateway': ctx['int_gateway_ip'],
|
||||
'https_names': ctx['https_names'],
|
||||
'https_addresses': ctx['https_ips'],
|
||||
'local_cidrs': ctx['local_cidr_list'],
|
||||
'client_dns': ctx['p2s_resolver_addrs'] if linuxmanager.RESOLVER_CONF.exists() else [],
|
||||
'site_to_site': [{
|
||||
@@ -1136,16 +1143,13 @@ def main():
|
||||
|
||||
progress('running', 'firewall')
|
||||
rules_changed = setup_ufw(ctx)
|
||||
if is_configured(ctx):
|
||||
status = run(['ufw', 'status'], check=False)
|
||||
if not status.stdout.startswith('Status: active'):
|
||||
# Only ever enable the firewall after making sure SSH survives it.
|
||||
run(['ufw', 'allow', '22/tcp'], check=False)
|
||||
run(['ufw', '--force', 'enable'])
|
||||
elif rules_changed:
|
||||
run(['ufw', 'reload'])
|
||||
status = run(['ufw', 'status'], check=False)
|
||||
if not status.stdout.startswith('Status: active'):
|
||||
# Only ever enable the firewall after making sure SSH survives it.
|
||||
run(['ufw', 'allow', '22/tcp'], check=False)
|
||||
run(['ufw', '--force', 'enable'])
|
||||
elif rules_changed:
|
||||
run(['ufw', 'reload'], check=False)
|
||||
run(['ufw', 'reload'])
|
||||
|
||||
progress('running', 'strongSwan')
|
||||
manage_strongswan(ctx, changed)
|
||||
@@ -1168,6 +1172,8 @@ def main():
|
||||
manage_openvpn(ctx, changed)
|
||||
progress('running', 'HTTPS proxy')
|
||||
manage_caddy(cfg, ctx)
|
||||
progress('running', 'mDNS')
|
||||
manage_mdns(ctx)
|
||||
progress('running', 'WebDAV')
|
||||
manage_webdav(ctx)
|
||||
progress('running', 'name server')
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
# Written by linux-manager-setup from /etc/linux-manager/linux-manager.json and the web sites; edits are overwritten.
|
||||
{
|
||||
auto_https disable_redirects
|
||||
{%- if https_tls %}
|
||||
default_sni {{ https_name }}
|
||||
{%- endif %}
|
||||
{%- if https_email %}
|
||||
email {{ https_email }}
|
||||
{%- endif %}
|
||||
@@ -44,10 +47,18 @@
|
||||
file_server
|
||||
}
|
||||
{%- endmacro %}
|
||||
{#- The addresses of an HTTPS site on port: the HTTPS hosts. #}
|
||||
{%- macro https_site(port) %}{% for host in https_hosts %}{{ host }}:{{ port }}{{ ', ' if not loop.last else '' }}{% endfor %}{% endmacro %}
|
||||
{% if web_enabled %}
|
||||
http://:{{ web_port }} {
|
||||
header -Server
|
||||
{{- pki_files(pki_publish_dir) }}
|
||||
{%- if redirect %}
|
||||
@https host {{ redirect_hosts | join(' ') }}
|
||||
handle @https {
|
||||
redir https://{host}:{{ https_web_port }}{uri} 308
|
||||
}
|
||||
{%- endif %}
|
||||
handle {
|
||||
reverse_proxy {{ loopback }}:{{ web_loopback_port }} {
|
||||
header_down -Server
|
||||
@@ -58,9 +69,15 @@ http://:{{ web_port }} {
|
||||
http://:{{ manager_port }} {
|
||||
header -Server
|
||||
{{- pki_files(pki_publish_dir) }}
|
||||
{%- if redirect %}
|
||||
@https host {{ redirect_hosts | join(' ') }}
|
||||
handle @https {
|
||||
redir https://{host}:{{ https_manager_port }}{uri} 308
|
||||
}
|
||||
{%- endif %}
|
||||
handle {
|
||||
{%- if redirect %}
|
||||
redir https://{{ local_fqdn }}:{{ https_manager_port }}{uri} 308
|
||||
redir https://{{ https_name }}:{{ https_manager_port }}{uri} 308
|
||||
{%- else %}
|
||||
reverse_proxy {{ loopback }}:{{ manager_loopback_port }} {
|
||||
header_down -Server
|
||||
@@ -77,7 +94,7 @@ http://:{{ metrics_port }} {
|
||||
}
|
||||
{% endif %}
|
||||
{%- if https and (web_enabled or acme_cas) %}
|
||||
{{ local_fqdn }}:{{ https_web_port }} {
|
||||
{{ https_site(https_web_port) }} {
|
||||
header -Server
|
||||
{%- if https_tls %}
|
||||
tls {{ https_tls.cert }} {{ https_tls.key }}
|
||||
@@ -102,7 +119,7 @@ http://:{{ metrics_port }} {
|
||||
}
|
||||
{% endif %}
|
||||
{%- if https %}
|
||||
{{ local_fqdn }}:{{ https_manager_port }} {
|
||||
{{ https_site(https_manager_port) }} {
|
||||
header -Server
|
||||
{%- if https_tls %}
|
||||
tls {{ https_tls.cert }} {{ https_tls.key }}
|
||||
@@ -116,7 +133,7 @@ http://:{{ metrics_port }} {
|
||||
}
|
||||
{% endif %}
|
||||
{%- if https and metrics_enabled %}
|
||||
{{ local_fqdn }}:{{ metrics_https_port }} {
|
||||
{{ https_site(metrics_https_port) }} {
|
||||
header -Server
|
||||
{%- if https_tls %}
|
||||
tls {{ https_tls.cert }} {{ https_tls.key }}
|
||||
@@ -127,7 +144,7 @@ http://:{{ metrics_port }} {
|
||||
}
|
||||
{% endif %}
|
||||
{%- if webdav %}
|
||||
{{ local_fqdn }}:{{ webdav_port }} {
|
||||
{{ https_site(webdav_port) }} {
|
||||
header -Server
|
||||
{%- if https_tls %}
|
||||
tls {{ https_tls.cert }} {{ https_tls.key }}
|
||||
|
||||
@@ -16,8 +16,8 @@ Issue and Settings are on every tab but Server.
|
||||
|
||||
## Tabs
|
||||
|
||||
- **Server:** the first tab, shown also while the PKI cannot be read: HTTPS and the name it is
|
||||
for, with a chip while the server's certificate has a source other than ACME, and a settings
|
||||
- **Server:** the first tab, shown also while the PKI cannot be read: HTTPS and the names and
|
||||
addresses it is for, with a chip while the server's certificate has a source other than ACME, and a settings
|
||||
button; the server's certificate, when it is not ACME's, with its issuer and expiry; the ACME
|
||||
CA, with a chip while it is Let's Encrypt's staging environment, and a settings button (see
|
||||
Server HTTPS below); and Caddy, which serves every HTTP and HTTPS port of the server, with its
|
||||
@@ -47,16 +47,19 @@ Issue and Settings are on every tab but Server.
|
||||
## Server HTTPS
|
||||
|
||||
The settings button of the HTTPS row sets the **certificate of the server**: ACME; self-signed,
|
||||
with its validity in days; the Servers Issuing CA of the server's PKI; or another CA. Until the
|
||||
chosen certificate is available, the server serves a self-signed one and warns.
|
||||
with its validity in days; the Servers Issuing CA of the server's PKI; or another CA. Without
|
||||
ACME, a checkbox also names the server's IP addresses in the certificate, to reach it over HTTPS
|
||||
by address. Until the chosen certificate is available, the server serves a self-signed one and warns.
|
||||
|
||||
The source is self-signed unless the configuration names another; ACME is used only when it is
|
||||
chosen. The first setup of a new installation chooses the Servers Issuing CA when the root CA and
|
||||
that CA are available, as with a root the server creates, else self-signed; it does so also when
|
||||
the configuration it is given names no source.
|
||||
While HTTPS is on, the Manager's plain HTTP address redirects to its HTTPS address, unless the
|
||||
HTTPS is always on, for `wan.local_fqdn` or, without it, the host name and `<host name>.local`;
|
||||
with `https.ip_sans` the certificate also names the server's addresses. A plain HTTP request for
|
||||
those names is redirected to HTTPS, on the status page's port and the Manager's, unless the
|
||||
installer's `https_disable_auto_redirect` or `https.disable_auto_redirect` says otherwise; the
|
||||
status page never redirects.
|
||||
status page stays on plain HTTP by address, and `/pki/` on plain HTTP always.
|
||||
|
||||
The settings button of the ACME CA row sets the ACME CA of the server's certificate with ACME, and
|
||||
of the web sites with TLS ACME: Let's Encrypt, with **Staging environment** for routers rebuilt
|
||||
|
||||
@@ -39,7 +39,8 @@ their password and, when enrolled, the code.
|
||||
- The eye opens the device's configuration; the download gives `<user>-<n>.conf`, with a
|
||||
placeholder for the device's private key, which the server never has.
|
||||
- The remove button removes a peer after a confirmation.
|
||||
- **Server:** the server's public key with a copy icon, the endpoint and the allowed IPs a device
|
||||
needs; **Show config** opens a device configuration with placeholders.
|
||||
- **Server:** the server's public key with a copy icon on a page opened over HTTPS, the endpoint
|
||||
and the allowed IPs a device needs; **Show config** opens a device configuration with
|
||||
placeholders, with a Copy button over HTTPS.
|
||||
- In the configuration dialogs a switch leaves out the `[Interface]` and `PrivateKey` lines, which
|
||||
WireGuard for Windows fills in for a new empty tunnel.
|
||||
+5
-3
@@ -11,9 +11,11 @@ The Overview tab shows the state of the server, read every 10 seconds by default
|
||||
IKEv2, OpenVPN and WireGuard; and the status web service and its port.
|
||||
- **Services:** the state of each of the server's systemd services and of Caddy; the chip on the
|
||||
title bar tells whether the server's services are active.
|
||||
- **Addresses:** links to the status page over HTTPS and over plain HTTP, and to the
|
||||
Manager over HTTPS, each opening in a new tab; and the issuer and the discovery URL of the
|
||||
server's OpenID Provider, each with a copy icon, or off while the provider is disabled (see
|
||||
- **Addresses:** links to the status page and the Manager over HTTPS for the server's names (and
|
||||
its addresses with `https.ip_sans`), and over plain HTTP: the status page by address, and both
|
||||
by name and the Manager by address too while the redirect to HTTPS is off; each opens in a new
|
||||
tab. Then the issuer and the discovery URL of the server's OpenID Provider, each with a copy
|
||||
icon over HTTPS, or off while the provider is disabled (see
|
||||
[Service accounts](service-accounts.md#openid-provider)).
|
||||
- **Backup:** the result of the last run, the next run and Run now (see [Backup](backup.md)).
|
||||
- **PostgreSQL:** each cluster with its main settings and its databases with their sizes.
|
||||
|
||||
@@ -23,9 +23,9 @@ Collector reading the server's metrics. They cannot sign in to the Manager.
|
||||
## OpenID Provider
|
||||
|
||||
The server can sign its users in to other systems with OpenID Connect. Its issuer and discovery
|
||||
URL are on the Addresses panel of the [Overview](router.md), each with a copy icon, and while it is
|
||||
enabled the title of the list has the number of its clients. It is turned on on the server as
|
||||
root:
|
||||
URL are on the Addresses panel of the [Overview](router.md), each with a copy icon on a page
|
||||
opened over HTTPS, and while it is enabled the title of the list has the number of its clients.
|
||||
It is turned on on the server as root:
|
||||
|
||||
```sh
|
||||
linux-manager-config-edit set --restart oidc.enabled true
|
||||
|
||||
+2
-2
@@ -8,8 +8,8 @@ and the name server of their domain on the [DNS](dns.md) page.
|
||||
|
||||
- **State:** whether the sites are served.
|
||||
- **Largest upload:** the largest file or zip archive the Files tab and the server's API take.
|
||||
- **WebDAV:** whether the folders are served over WebDAV, and its URL with a copy icon. WebDAV is
|
||||
switched on the [System](system.md) tab, which installs rclone.
|
||||
- **WebDAV:** whether the folders are served over WebDAV, and its URL with a copy icon over HTTPS.
|
||||
WebDAV is switched on the [System](system.md) tab, which installs rclone.
|
||||
|
||||
**Settings** edits the state, the largest upload and the WebDAV port.
|
||||
|
||||
|
||||
@@ -128,7 +128,8 @@ it running. The VM is created in a project, the test project `lm-dev` by default
|
||||
project's default profile, and takes its address from DHCP. It gets the package with the
|
||||
administrator `admin`, whose password and TOTP token, unless `--no-otp` is given, are `password` and
|
||||
`otp_url` of `.lm-dev-config/vm-<project>-<vm>.json`, and a configuration from `configs/`,
|
||||
`dev.json` by default; `@ETH0@` is the interface of the VM's default route. A password or
|
||||
`dev.json` by default, which keeps the status page and the Manager on plain HTTP by name too
|
||||
(`https.disable_auto_redirect`); `@ETH0@` is the interface of the VM's default route. A password or
|
||||
`otp_url` the file lacks, or both when there is no file, is generated and kept in the file, so a VM
|
||||
made again has the same password and token; delete one from the file to have a new one made.
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"general": {"platform": "generic"},
|
||||
"interfaces": {"external": "@ETH0@"},
|
||||
"wan": {"local_fqdn": "@FQDN@"}
|
||||
"wan": {"local_fqdn": "@FQDN@"},
|
||||
"https": {"disable_auto_redirect": true}
|
||||
}
|
||||
@@ -1,14 +1,15 @@
|
||||
import { Alert, Button, Dialog, DialogActions, DialogContent, DialogTitle, MenuItem, Stack, TextField, Typography } from '@mui/material'
|
||||
import { Alert, Button, Checkbox, Dialog, DialogActions, DialogContent, DialogTitle, FormControlLabel, MenuItem, Stack, TextField, Typography } from '@mui/material'
|
||||
import { useState, type FormEvent } from 'react'
|
||||
import { HTTPS_CERTIFICATES, type HttpsCertificateSource, type HttpsChange, type HttpsSettings } from './api.ts'
|
||||
import { CERTIFICATE_LABELS } from './https.ts'
|
||||
|
||||
/**
|
||||
* A dialog that edits where the certificate of the server's FQDN comes from, https.certificate: the ACME CA of
|
||||
* A dialog that edits where the certificate of the server's HTTPS names comes from, https.certificate: the ACME CA of
|
||||
* AcmeSettingsDialog, a self-signed certificate valid for https.self_signed_days, the Servers Issuing CA, or another
|
||||
* CA's certificate, imported on the Server tab of the Certificates page; self-signed is selected while the first setup
|
||||
* has not chosen one. onSave sends the source and the validity
|
||||
* only; the dialog closes when it succeeds and shows the server's message when it fails.
|
||||
* has not chosen one. Without ACME, https.ip_sans adds the server's addresses to the self-signed certificate and the
|
||||
* Servers Issuing CA's. onSave sends the source, the validity and ip_sans only; the dialog closes when it succeeds and
|
||||
* shows the server's message when it fails.
|
||||
*/
|
||||
export default function HttpsSettingsDialog(props: {
|
||||
current: HttpsSettings
|
||||
@@ -17,6 +18,7 @@ export default function HttpsSettingsDialog(props: {
|
||||
}) {
|
||||
const [certificate, setCertificate] = useState<HttpsCertificateSource>(props.current.certificate || 'self-signed')
|
||||
const [days, setDays] = useState(String(props.current.self_signed_days))
|
||||
const [ipSans, setIpSans] = useState(props.current.ip_sans)
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
@@ -31,7 +33,8 @@ export default function HttpsSettingsDialog(props: {
|
||||
setSaving(true)
|
||||
setError(null)
|
||||
try {
|
||||
await props.onSave(certificate === 'self-signed' ? { certificate, self_signed_days: Number(days) } : { certificate })
|
||||
await props.onSave(certificate === 'self-signed' ? { certificate, self_signed_days: Number(days), ip_sans: ipSans }
|
||||
: certificate === 'acme' ? { certificate } : { certificate, ip_sans: ipSans })
|
||||
} catch (caught) {
|
||||
setError((caught as Error).message)
|
||||
setSaving(false)
|
||||
@@ -62,6 +65,12 @@ export default function HttpsSettingsDialog(props: {
|
||||
onChange={(event) => setDays(event.target.value.trim())}
|
||||
/>
|
||||
)}
|
||||
{(certificate === 'self-signed' || certificate === 'ca') && (
|
||||
<FormControlLabel
|
||||
control={<Checkbox checked={ipSans} onChange={(event) => setIpSans(event.target.checked)} />}
|
||||
label="Also name the server's IP addresses, to reach it over HTTPS by address"
|
||||
/>
|
||||
)}
|
||||
{certificate === 'external' && (
|
||||
<Typography variant="body2" color="text.secondary">
|
||||
The certificate is imported on this tab, from a CSR the server makes or as a PFX file. The server serves a self-signed certificate until then.
|
||||
|
||||
@@ -17,8 +17,8 @@ import {
|
||||
} from './api.ts'
|
||||
|
||||
/**
|
||||
* The Server tab of the Certificates page, the server's HTTPS from /config and /https/settings: whether HTTPS is on and
|
||||
* for which name, with a chip while the certificate has another source than ACME and a button that opens
|
||||
* The Server tab of the Certificates page, the server's HTTPS from /config and /https/settings: the names and addresses
|
||||
* HTTPS is served for, with a chip while the certificate has another source than ACME and a button that opens
|
||||
* HttpsSettingsDialog; the certificate of a source other than ACME, and, for one of another CA, Generate CSR, Import
|
||||
* certificate and Import PFX; the ACME CA with a chip while it is Let's Encrypt's staging environment and a button that
|
||||
* opens AcmeSettingsDialog; and Caddy, its version and the state of caddy.service. Until the first setup
|
||||
@@ -89,10 +89,9 @@ export default function ServerCertificatePanel() {
|
||||
}
|
||||
|
||||
const https = details?.configuration.https
|
||||
const fqdn = String(details?.configuration.wan?.local_fqdn ?? '')
|
||||
const httpsOn = https?.enabled === true
|
||||
const hosts = [...(details?.network.https_names ?? []), ...(details?.network.https_addresses ?? [])]
|
||||
const chosen = certificate !== null && certificate.source !== ''
|
||||
const other = httpsOn && certificate !== null && certificate.source !== 'acme'
|
||||
const other = certificate !== null && certificate.source !== 'acme'
|
||||
|
||||
return (
|
||||
<Box>
|
||||
@@ -106,9 +105,9 @@ export default function ServerCertificatePanel() {
|
||||
rows={[
|
||||
['HTTPS', (
|
||||
<Stack key="https" direction="row" sx={{ alignItems: 'center', gap: 1, flexWrap: 'wrap' }}>
|
||||
<span>{httpsOn ? (fqdn ? `on, for ${fqdn}` : 'on, but wan.local_fqdn is not set') : 'off'}</span>
|
||||
<span>{hosts.length > 0 ? `for ${hosts.join(', ')}` : 'on'}</span>
|
||||
{other && certificate.source !== '' && <Chip size="small" label={CERTIFICATE_LABELS[certificate.source]} color={certificate.served === certificate.source ? 'default' : 'warning'} />}
|
||||
{httpsOn && !chosen && <Typography variant="body2" color="text.secondary">certificate chosen by the next setup</Typography>}
|
||||
{!chosen && <Typography variant="body2" color="text.secondary">certificate chosen by the next setup</Typography>}
|
||||
<Tooltip title="HTTPS certificate">
|
||||
<IconButton size="small" aria-label="HTTPS certificate" onClick={() => void open('https')}>
|
||||
<Settings fontSize="small" />
|
||||
|
||||
+26
-17
@@ -23,9 +23,9 @@ const LAYOUT_KEY = 'linux-manager-ui.router-layout'
|
||||
* The server's state: its status, ok or degraded on the title bar of the Status panel, with the update information of
|
||||
* its packages (UpdatesNotice) at the top of that panel, its remote access clients, and from /config the status web
|
||||
* service; the state of each of its systemd services and of Caddy in the Services panel; the Addresses panel's links
|
||||
* to the status page, over HTTPS for wan.local_fqdn and over plain HTTP on the addresses web.listen names, and to the
|
||||
* Manager over HTTPS, and over plain HTTP on the addresses of its listen from /api/info while Caddy does not redirect
|
||||
* it, each address once, and the
|
||||
* to the status page and the Manager over HTTPS for the HTTPS names and addresses, and over plain HTTP: the status page
|
||||
* on the addresses web.listen names, the Manager on the addresses of its listen from /api/info only while the redirect
|
||||
* to HTTPS is off, and both by their HTTPS names only while it is off, each address once, and the
|
||||
* OpenID Provider's issuer and discovery URL, each with a copy icon, or off while it is disabled; its
|
||||
* backups with Run now, and its non-public details as tables and command output, with a panel per PostgreSQL
|
||||
* cluster: its settings from /config and its databases with their sizes from /postgresql. Read at once, then as the
|
||||
@@ -106,18 +106,22 @@ export default function ServerPanel() {
|
||||
const network = details?.network
|
||||
const web = details?.configuration.web
|
||||
const https = details?.configuration.https
|
||||
const fqdn = String(details?.configuration.wan?.local_fqdn ?? '')
|
||||
const httpsOn = https?.enabled === true
|
||||
// The hosts HTTPS is served for: its names, then its addresses while https.ip_sans is on.
|
||||
const httpsNames = network?.https_names ?? []
|
||||
const httpsHosts = [...httpsNames, ...(network?.https_addresses ?? [])].map((host) => (host.includes(':') ? `[${host}]` : host))
|
||||
const redirectOff = https?.disable_auto_redirect === true
|
||||
const httpsUrls = (port: unknown) => httpsHosts.map((host) => `https://${host}:${text(port)}`)
|
||||
// A request by name on a plain HTTP port is redirected to HTTPS unless the redirect is off.
|
||||
const plainNames = (port: unknown) => (redirectOff ? httpsNames.map((name) => `http://${name}:${text(port)}`) : [])
|
||||
// The plain HTTP URLs of a port on the addresses of the interfaces a listen setting names, each address once: without
|
||||
// the router the internal address is the external one.
|
||||
const plainUrls = (listen: string, port: unknown) => [...new Set([
|
||||
...(listen !== 'external' && network?.internal_address ? [network.internal_address] : []),
|
||||
...(listen !== 'internal' ? network?.external_addresses ?? [] : []),
|
||||
].map((address) => String(address).split('/')[0]))].map((address) => `http://${address}:${text(port)}`)
|
||||
const plain = web?.enabled === false ? [] : plainUrls(String(web?.listen ?? 'both'), web?.port)
|
||||
// The Manager over plain HTTP while Caddy does not redirect it to HTTPS.
|
||||
const managerPlain = manager && (!httpsOn || !fqdn || https?.disable_auto_redirect === true)
|
||||
? plainUrls(manager.listen, manager.port) : []
|
||||
// The status page stays on plain HTTP by address; the Manager only while the redirect is off.
|
||||
const plain = web?.enabled === false ? [] : [...plainNames(web?.port), ...plainUrls(String(web?.listen ?? 'both'), web?.port)]
|
||||
const managerPlain = manager && redirectOff ? [...plainNames(manager.port), ...plainUrls(manager.listen, manager.port)] : []
|
||||
|
||||
// The panels in their default order; a panel without data is left out, and keeps its place in the layout.
|
||||
const panels: BoardPanel[] = []
|
||||
@@ -258,8 +262,8 @@ export default function ServerPanel() {
|
||||
content: (
|
||||
<Pairs
|
||||
rows={[
|
||||
['Status page', <Links key="status" urls={[...(httpsOn && fqdn ? [`https://${fqdn}:${text(https?.web_port)}`] : []), ...plain]} />],
|
||||
['Ubuntu Linux Manager', <Links key="manager" urls={[...(httpsOn && fqdn ? [`https://${fqdn}:${text(https?.manager_port)}`] : []), ...managerPlain]} />],
|
||||
['Status page', <Links key="status" urls={[...(web?.enabled === false ? [] : httpsUrls(https?.web_port)), ...plain]} />],
|
||||
['Ubuntu Linux Manager', <Links key="manager" urls={[...httpsUrls(https?.manager_port), ...managerPlain]} />],
|
||||
...(details.oidc?.issuer
|
||||
? [
|
||||
['OpenID Provider', <Copyable key="issuer" value={details.oidc.issuer} label="issuer" />],
|
||||
@@ -400,16 +404,21 @@ export function Pairs(props: { rows: [string, string | ReactNode][] }) {
|
||||
)
|
||||
}
|
||||
|
||||
/** A value in monospace for Pairs with an action icon that puts it on the clipboard; label names it in the tooltip. */
|
||||
/**
|
||||
* A value in monospace for Pairs with an action icon that puts it on the clipboard, shown only on a page served over
|
||||
* HTTPS, where the browser offers the clipboard; label names it in the tooltip.
|
||||
*/
|
||||
export function Copyable(props: { value: string; label: string }) {
|
||||
return (
|
||||
<Stack direction="row" sx={{ alignItems: 'center', gap: 1 }}>
|
||||
<Box component="span" sx={{ fontFamily: 'monospace', fontSize: 13, wordBreak: 'break-all' }}>{props.value}</Box>
|
||||
<Tooltip title={`Copy the ${props.label}`}>
|
||||
<IconButton size="small" aria-label={`copy the ${props.label}`} onClick={() => void navigator.clipboard.writeText(props.value)}>
|
||||
<ContentCopy fontSize="small" />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
{window.isSecureContext && (
|
||||
<Tooltip title={`Copy the ${props.label}`}>
|
||||
<IconButton size="small" aria-label={`copy the ${props.label}`} onClick={() => void navigator.clipboard.writeText(props.value)}>
|
||||
<ContentCopy fontSize="small" />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
)}
|
||||
</Stack>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ const PREFILLED_LINES = 2
|
||||
* device's address, its peer's IPs, or a placeholder without them (ips null). The device's private key is a
|
||||
* placeholder, which the server never has; a switch leaves out the [Interface] and PrivateKey lines, which a client such
|
||||
* as WireGuard for Windows fills in for a new empty tunnel, and keeps its position in the browser's settings. Copy
|
||||
* puts the configuration as shown on the clipboard.
|
||||
* puts the configuration as shown on the clipboard; it is shown only on a page served over HTTPS, where the browser
|
||||
* offers the clipboard.
|
||||
*/
|
||||
export default function WireGuardConfigDialog(props: { title: string; server: WireGuardServer; ips: string[] | null; onClose: () => void }) {
|
||||
const [copied, setCopied] = useState(false)
|
||||
@@ -43,9 +44,11 @@ export default function WireGuardConfigDialog(props: { title: string; server: Wi
|
||||
</Box>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button startIcon={copied ? <Check /> : <ContentCopy />} onClick={() => void navigator.clipboard.writeText(text).then(() => setCopied(true))}>
|
||||
{copied ? 'Copied' : 'Copy'}
|
||||
</Button>
|
||||
{window.isSecureContext && (
|
||||
<Button startIcon={copied ? <Check /> : <ContentCopy />} onClick={() => void navigator.clipboard.writeText(text).then(() => setCopied(true))}>
|
||||
{copied ? 'Copied' : 'Copy'}
|
||||
</Button>
|
||||
)}
|
||||
<Button variant="contained" onClick={props.onClose}>Close</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
|
||||
+10
-4
@@ -91,6 +91,10 @@ export type RouterDetails = {
|
||||
external_addresses?: string[]
|
||||
internal_address?: string
|
||||
internal_gateway?: string
|
||||
/** The names HTTPS is served for: wan.local_fqdn, or the host name and <host name>.local without it. */
|
||||
https_names?: string[]
|
||||
/** The addresses HTTPS is served for while https.ip_sans is on. */
|
||||
https_addresses?: string[]
|
||||
local_cidrs?: string[]
|
||||
/** Each site-to-site connection with the identities and subnets the server resolved for it. */
|
||||
site_to_site?: { name: string; local_identity: string; remote_identity: string; local_cidrs: string[]; remote_cidrs: string[] }[]
|
||||
@@ -502,10 +506,10 @@ export type AcmeProvider = (typeof ACME_PROVIDERS)[number]
|
||||
* the certificate source, '' until the first setup chooses it, and the ACME settings.
|
||||
*/
|
||||
export type HttpsSettings = {
|
||||
enabled: boolean
|
||||
email: string
|
||||
web_port: number
|
||||
manager_port: number
|
||||
ip_sans: boolean
|
||||
acme_staging: boolean
|
||||
certificate: HttpsCertificateSource | ''
|
||||
self_signed_days: number
|
||||
@@ -517,8 +521,8 @@ export type HttpsSettings = {
|
||||
}
|
||||
|
||||
/** The changes PUT /https/settings takes; a secret left out keeps its value. */
|
||||
export type HttpsChange = Partial<Pick<HttpsSettings, 'acme_staging' | 'certificate' | 'self_signed_days' | 'acme_provider' |
|
||||
'acme_url' | 'acme_eab_key_id'>> & { acme_eab_mac_key?: string; zerossl_api_key?: string }
|
||||
export type HttpsChange = Partial<Pick<HttpsSettings, 'acme_staging' | 'certificate' | 'self_signed_days' | 'ip_sans' |
|
||||
'acme_provider' | 'acme_url' | 'acme_eab_key_id'>> & { acme_eab_mac_key?: string; zerossl_api_key?: string }
|
||||
|
||||
/**
|
||||
* The server's HTTPS certificate: the chosen source, '' until the first setup chooses it, the one served (self-signed while the chosen one is not
|
||||
@@ -700,6 +704,8 @@ export const DETAILS_SHAPE = object({
|
||||
external_addresses: optional(list(string)),
|
||||
internal_address: optional(string),
|
||||
internal_gateway: optional(string),
|
||||
https_names: optional(list(string)),
|
||||
https_addresses: optional(list(string)),
|
||||
local_cidrs: optional(list(string)),
|
||||
site_to_site: optional(list(object({
|
||||
name: string,
|
||||
@@ -1154,10 +1160,10 @@ export const METRICS_SETTINGS_SHAPE = object({
|
||||
/** The shape of GET and PUT /https/settings; GET also has the certificate. */
|
||||
export const HTTPS_SETTINGS_SHAPE = object({
|
||||
settings: object({
|
||||
enabled: boolean,
|
||||
email: string,
|
||||
web_port: number,
|
||||
manager_port: number,
|
||||
ip_sans: boolean,
|
||||
acme_staging: boolean,
|
||||
certificate: string,
|
||||
self_signed_days: number,
|
||||
|
||||
Reference in new issue
Block a user