4.5 KiB
KeyHelp: api.landwelle.de
Stand: Landwelle v1.5.20
Die Subdomain stellt zwei getrennte Schnittstellen bereit:
- öffentliche Radio-App-API unter
https://api.landwelle.de/v1, - interne Landwelle-IT-App-API unter
https://api.landwelle.de/api/mobile.
Die zusätzlichen Apache-Anweisungen gehören in KeyHelp bei der Subdomain in das Feld Anweisungen für HTTPS. Bei aktivierter HTTPS-Erzwingung ist ausschließlich dieses HTTPS-Feld für Aufrufe wie https://api.landwelle.de/v1/app/bootstrap maßgeblich. Eine funktionierende neutrale Startseite unter / beweist nicht, dass auch /v1/* weitergeleitet wird.
Das verbindliche, direkt kopierbare Fragment liegt zusätzlich in deploy/keyhelp-api-subdomain-https.conf. Es muss vollständig übernommen werden; eine einzelne Rewrite-Regel nur für / reicht nicht.
<IfModule mod_proxy.c>
ProxyRequests Off
ProxyPreserveHost On
RewriteEngine On
# Neutrale Startseite ohne Endpunktliste oder interne Versionsdetails.
RewriteRule ^/?$ http://127.0.0.1:2200/api/info [P,L]
# Interne Android-App „Landwelle IT“.
# Der externe und interne Pfad sind identisch; dadurch entsteht kein /api/api/.
ProxyPass /api/mobile/ http://127.0.0.1:2200/api/mobile/ connectiontimeout=5 timeout=45 retry=0
ProxyPassReverse /api/mobile/ http://127.0.0.1:2200/api/mobile/
ProxyPass /api/mobile http://127.0.0.1:2200/api/mobile connectiontimeout=5 timeout=45 retry=0
ProxyPassReverse /api/mobile http://127.0.0.1:2200/api/mobile
# Öffentliche Android-/iOS-Radio-App-API.
ProxyPass /v1/ http://127.0.0.1:2200/v1/ connectiontimeout=5 timeout=45 retry=0
ProxyPassReverse /v1/ http://127.0.0.1:2200/v1/
ProxyPass /v1 http://127.0.0.1:2200/v1 connectiontimeout=5 timeout=45 retry=0
ProxyPassReverse /v1 http://127.0.0.1:2200/v1
# Externe Dienstchecks.
ProxyPass /health http://127.0.0.1:2200/health connectiontimeout=5 timeout=10 retry=0
ProxyPassReverse /health http://127.0.0.1:2200/health
ProxyPass /ready http://127.0.0.1:2200/ready connectiontimeout=5 timeout=10 retry=0
ProxyPassReverse /ready http://127.0.0.1:2200/ready
</IfModule>
<IfModule mod_headers.c>
RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Forwarded-Port "443"
Header always set X-Content-Type-Options "nosniff"
Header always set Referrer-Policy "no-referrer"
Header always set X-Frame-Options "DENY"
Header always set X-Robots-Tag "noindex, nofollow, noarchive"
</IfModule>
Benötigte Apache-Module:
proxy
proxy_http
rewrite
headers
Fehlerbild „404 Not Found“ bei /v1
Wenn https://api.landwelle.de/ die Landwelle-API-Hinweisseite zeigt, aber https://api.landwelle.de/v1/app/bootstrap eine generische HTML-404-Seite liefert, erreicht nur die Root-Rewrite-Regel das Portal. Die ProxyPass-Regeln für /v1 fehlen dann im wirksamen HTTPS-VHost oder wurden nur in das HTTP-Feld eingetragen.
Nach dem Speichern in KeyHelp prüfen:
./scripts/verify-api-subdomain.sh
Der direkte Portalpfad kann unabhängig davon geprüft werden:
curl -i http://127.0.0.1:2200/v1/app/bootstrap
curl -i https://landwelle.de/v1/app/bootstrap
Antwortet einer dieser Pfade mit JSON und die API-Subdomain weiterhin mit HTML-404, liegt der Fehler sicher vor dem Go-Portal in der Reverse-Proxy-Konfiguration.
Prüfungen
Ohne Mobile-API-Token:
curl -i 'https://api.landwelle.de/api/mobile/todos?author=Jens'
curl -i 'https://api.landwelle.de/api/mobile/status'
Mit gesetztem LANDWELLE_MOBILE_API_TOKEN:
curl -i -H 'Authorization: Bearer <TOKEN>' \
'https://api.landwelle.de/api/mobile/todos?author=Jens'
curl -i -H 'Authorization: Bearer <TOKEN>' \
'https://api.landwelle.de/api/mobile/status'
Weitere Prüfungen:
curl -i https://api.landwelle.de/
curl -i https://api.landwelle.de/v1
curl -i https://api.landwelle.de/v1/app/bootstrap
curl -i https://api.landwelle.de/v1/does-not-exist
curl -i https://api.landwelle.de/health
curl -i https://api.landwelle.de/ready
Erwartungen:
/liefert die neutrale HTML-Hinweisseite./v1und/v1/...liefern JSON./api/mobile/todosund/api/mobile/statusliefern JSON und werden nicht zu/api/api/...umgeschrieben.- ein unbekannter
/v1/...-Pfad liefert JSON mit HTTP 404. /healthliefert den Liveness-Status und/readyden Abhängigkeitsstatus.- Adminpfade werden nicht über die API-Subdomain weitergereicht.