Ich habe damit ein wenig zu kämpfen. OK, viel.
Ich habe beschlossen, mit dem Hinzufügen eines CDN zu einer meiner Websites zu experimentieren.
Nachdem ich die Dokumentation gelesen hatte, erkannte ich, dass es für meine Website besser war, von ihrer aktuellen Apex-Domain auf eine Subdomain umzuziehen, um die von Fastly empfohlenen Kriterien (und die allgemeine Empfehlung dazu) zu erfüllen.
Also dachte ich: „Ach, das wird ein Kinderspiel, das habe ich schon mal gemacht …“. Oh ja?! 
Die betreffende Website ist https://starzen.space.
Ich habe sie dieses Wochenende nach https://www.starzen.space verschoben, indem ich die Anleitung hier verwendet habe.
Alles lief gut, ABER natürlich muss ich immer noch die kleine Anzahl von Benutzern berücksichtigen, die ich bisher auf dieser Website gewonnen habe, also wollte ich eine Weiterleitung hinzufügen.
Nach meinem Verständnis muss ich dann auch den ursprünglichen Link mit einem Zertifikat ausstellen. Nach dieser Anleitung (die viel aufwendiger war?) habe ich dies zu app.yml hinzugefügt:
hooks:
after_ssl:
- replace:
filename: "/etc/runit/1.d/letsencrypt"
from: /--keylength/
to: "-d starzen.space --keylength"
- replace:
filename: "/etc/nginx/conf.d/discourse.conf"
from: /return 301 https.+/
to: |
return 301 https://$host$request_uri;
after_web_config:
- replace:
filename: /etc/nginx/nginx.conf
from: /sendfile.+on;/
to: |
server_names_hash_bucket_size 64;
sendfile on;
- file:
path: /etc/nginx/conf.d/discourse_redirect_1.conf
contents: |
server {
listen 80;
listen 443 ssl;
server_name starzen.space;
return 301 $scheme://www.starzen.space$request_uri;
}
Bei einem erneuten Build scheint alles gut zu laufen.
Wenn ich jedoch versuche, https://starzen.space über einen Browser aufzurufen, erhalte ich:
Und wenn ich curl verwende:
blah discourse % curl https://starzen.space
curl: (60) SSL: no alternative certificate subject name matches target host name 'starzen.space'
More details here: https://curl.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
Ich bin mir ziemlich sicher, dass das Zertifikat schuld ist, denn wenn ich dasselbe im unsicheren Modus ausführe, erhalte ich:
blah discourse % curl -k https://starzen.space
301 Moved Permanently
301 Moved Permanently
nginx/1.21.6
was meiner Meinung nach das ist, was ich will.
Ich denke, die geänderte Skriptdatei ist korrekt, hier ist, was ich habe:
root@starship-enterprise:/etc/runit/1.d# cat letsencrypt
#!/bin/bash
/usr/sbin/nginx -c /etc/nginx/letsencrypt.conf
issue_cert() {
LE_WORKING_DIR="${LETSENCRYPT_DIR}" /shared/letsencrypt/acme.sh --issue $2 -d www.starzen.space -d starzen.space --keylength $1 -w /var/www/discourse/public
}
cert_exists() {
[[ "$(cd /shared/letsencrypt/www.starzen.space$1 && openssl verify -CAfile <(openssl x509 -in ca.cer) fullchain.cer | grep "OK")"]]
}
########################################################
# RSA cert
########################################################
issue_cert "4096"
if ! cert_exists ""; then
# Try to issue the cert again if something goes wrong
issue_cert "4096" "--force"
fi
<SNIP>
Ich habe dies sogar von der Befehlszeile aus innerhalb des Containers ausgeführt, nachdem ich ALLE Zertifikatsdateien aus dem Zielverzeichnis in ein Backup-Verzeichnis verschoben hatte, damit der richtige Befehl für die doppelte Domain ausgeführt wird:
root@starship-enterprise:/etc/runit/1.d# ./letsencrypt
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
[Sun 25 Sep 2022 05:50:04 PM UTC] Using CA: https://acme-v02.api.letsencrypt.org/directory
[Sun 25 Sep 2022 05:50:04 PM UTC] Creating domain key
[Sun 25 Sep 2022 05:50:05 PM UTC] The domain key is here: /shared/letsencrypt/www.starzen.space/www.starzen.space.key
[Sun 25 Sep 2022 05:50:05 PM UTC] Multi domain='DNS:www.starzen.space,DNS:starzen.space'
[Sun 25 Sep 2022 05:50:05 PM UTC] Getting domain auth token for each domain
[Sun 25 Sep 2022 05:50:08 PM UTC] Getting webroot for domain='www.starzen.space'
[Sun 25 Sep 2022 05:50:08 PM UTC] Getting webroot for domain='starzen.space'
[Sun 25 Sep 2022 05:50:08 PM UTC] www.starzen.space is already verified, skip http-01.
[Sun 25 Sep 2022 05:50:08 PM UTC] Verifying: starzen.space
[Sun 25 Sep 2022 05:50:12 PM UTC] Pending
[Sun 25 Sep 2022 05:50:15 PM UTC] Success
[Sun 25 Sep 2022 05:50:15 PM UTC] Verify finished, start to sign.
[Sun 25 Sep 2022 05:50:15 PM UTC] Le_OrderFinalize='https://acme-v02.api.letsencrypt.org/acme/finalize/590255196/128806215177'
[Sun 25 Sep 2022 05:50:16 PM UTC] Downloading cert.
[Sun 25 Sep 2022 05:50:16 PM UTC] Le_LinkCert='https://acme-v02.api.letsencrypt.org/acme/cert/03ff6b1b76f8516165032c6c2e02205a529b'
[Sun 25 Sep 2022 05:50:17 PM UTC] Cert success.
-----BEGIN CERTIFICATE-----
Lotsofcrazytext
-----END CERTIFICATE-----
[Sun 25 Sep 2022 05:50:17 PM UTC] Your cert is in /shared/letsencrypt/www.starzen.space/www.starzen.space.cer
[Sun 25 Sep 2022 05:50:17 PM UTC] Your cert key is in /shared/letsencrypt/www.starzen.space/www.starzen.space.key
[Sun 25 Sep 2022 05:50:17 PM UTC] The intermediate CA cert is in /shared/letsencrypt/www.starzen.space/ca.cer
[Sun 25 Sep 2022 05:50:17 PM UTC] And the full chain certs is there: /shared/letsencrypt/www.starzen.space/fullchain.cer
[Sun 25 Sep 2022 05:50:17 PM UTC] Installing key to:/shared/ssl/www.starzen.space.key
[Sun 25 Sep 2022 05:50:17 PM UTC] Installing full chain to:/shared/ssl/www.starzen.space.cer
[Sun 25 Sep 2022 05:50:17 PM UTC] Run reload cmd: sv reload nginx
ok: run: nginx: (pid 579) 35281s
[Sun 25 Sep 2022 05:50:17 PM UTC] Reload success
[Sun 25 Sep 2022 05:50:18 PM UTC] Domains not changed.
[Sun 25 Sep 2022 05:50:18 PM UTC] Skip, Next renewal time is: Wed 23 Nov 2022 10:01:01 AM UTC
[Sun 25 Sep 2022 05:50:18 PM UTC] Add '--force' to force to renew.
[Sun 25 Sep 2022 05:50:18 PM UTC] Installing key to:/shared/ssl/www.starzen.space_ecc.key
[Sun 25 Sep 2022 05:50:18 PM UTC] Installing full chain to:/shared/ssl/www.starzen.space_ecc.cer
[Sun 25 Sep 2022 05:50:18 PM UTC] Run reload cmd: sv reload nginx
ok: run: nginx: (pid 579) 35282s
[Sun 25 Sep 2022 05:50:18 PM UTC] Reload success
Größtenteils ein voller Erfolg!!!, curl ist jetzt viel freundlicher und gibt mir die Weiterleitung:
blah discourse % curl https://starzen.space
301 Moved Permanently
301 Moved Permanently
nginx/1.21.6
Und https://starzen.space in Firefox & Chrome funktioniert jetzt und leitet zur richtigen Unterseite weiter, aber ich bekomme immer noch die gefürchtete Grafik des Verderbens in Safari, was ist los? Ich habe es sogar neu gestartet und die Caches für diese Website gelöscht:
Wenn ich mir das Zertifikat vom Browser aus ansehe, sehe ich: