Zum Inhalt

Domain, DNS und Reverse Proxy

Ziel

Diese Seite dokumentiert die konkrete Domain-, DNS-, Reverse-Proxy- und HTTPS-Konfiguration für Immohai.

Die allgemeine, wiederverwendbare Anleitung zu Domainkauf, DNS, Nginx Reverse Proxy, Docker-Port-Strategie und Certbot liegt im Developer-Playbook-Staging-Bereich:

playbook-staging/deployment/01-domain-dns-reverse-proxy.md

Diese Datei beschreibt nur die konkrete Umsetzung für Immohai.


Aktuelle öffentliche URLs

Zweck URL
Immohai App https://immohai.ohaisoft.com
Immohai Dokumentation https://docs.immohai.ohaisoft.com
Developer Playbook später https://playbook.ohaisoft.com

Domain

Für Immohai wird folgende Hauptdomain verwendet:

ohaisoft.com

Die Domain wurde bei IONOS gekauft.

Die DNS-Verwaltung erfolgt ebenfalls bei IONOS.


Server

Eigenschaft Wert
Anbieter Hetzner Cloud
Hetzner-Projekt AppsOhai
Servername ubuntu-4gb-nbg1-1
Standort Nürnberg
Öffentliche IPv4-Adresse 46.225.28.194
Server-Benutzer fober
Aktueller Projektpfad /home/fober/projects/immohai
Reverse Proxy Nginx
Containerbetrieb Docker Compose
HTTPS Certbot / Let's Encrypt

Zielstruktur der Subdomains

ohaisoft.com                    → optionale Hauptseite / Übersicht
www.ohaisoft.com                → optionale Hauptseite / Übersicht
playbook.ohaisoft.com           → später Developer Playbook
immohai.ohaisoft.com            → Immohai App
docs.immohai.ohaisoft.com       → Immohai Dokumentation

Aktuell produktiv genutzt werden:

https://immohai.ohaisoft.com
https://docs.immohai.ohaisoft.com

DNS-Einträge

Bei IONOS sind folgende A-Records eingerichtet:

Typ Hostname Ziel
A @ 46.225.28.194
A www 46.225.28.194
A playbook 46.225.28.194
A immohai 46.225.28.194
A docs.immohai 46.225.28.194

Damit zeigen folgende Domains auf den Hetzner-Server:

ohaisoft.com
www.ohaisoft.com
playbook.ohaisoft.com
immohai.ohaisoft.com
docs.immohai.ohaisoft.com

DNS-Prüfung

DNS wurde mit nslookup geprüft:

nslookup ohaisoft.com
nslookup playbook.ohaisoft.com
nslookup immohai.ohaisoft.com
nslookup docs.immohai.ohaisoft.com

Alle Einträge zeigten korrekt auf:

46.225.28.194

Damit war die DNS-Einrichtung für Immohai abgeschlossen.


Docker-Portstruktur

Die Immohai-Container laufen nicht direkt öffentlich auf Port 80 oder 443.

Stattdessen werden sie lokal auf dem Server gebunden.

Dienst Lokaler Port Öffentliche URL
Immohai App 127.0.0.1:8200 https://immohai.ohaisoft.com
Immohai Dokumentation 127.0.0.1:8201 https://docs.immohai.ohaisoft.com

Die öffentliche Weiterleitung erfolgt über Nginx.


Docker Compose

Datei:

/home/fober/projects/immohai/docker-compose.yml

Aktuelle relevante Port-Konfiguration:

services:
  web:
    image: nginx:latest
    container_name: immohai-web
    restart: always
    ports:
      - "127.0.0.1:8200:80"
    volumes:
      - ./frontend:/usr/share/nginx/html:ro

  docs:
    image: squidfunk/mkdocs-material:latest
    container_name: immohai-docs
    restart: always
    ports:
      - "127.0.0.1:8201:8000"
    volumes:
      - ./:/docs
    command: serve -a 0.0.0.0:8000

Prüfung:

docker compose config
docker ps --format "table {{.Names}}\t{{.Ports}}"

Erwartung:

immohai-web     127.0.0.1:8200->80/tcp
immohai-docs    127.0.0.1:8201->8000/tcp

Wichtig:

Kein Immohai-Container darf direkt auf 0.0.0.0:80 oder 0.0.0.0:443 laufen.

Nginx Reverse Proxy

Nginx übernimmt die öffentlichen Ports 80 und 443.

Aktuelle Weiterleitungen:

Domain Lokaler Dienst
immohai.ohaisoft.com http://127.0.0.1:8200
docs.immohai.ohaisoft.com http://127.0.0.1:8201

Nginx-Dateien

Die Immohai-App ist hier konfiguriert:

/etc/nginx/sites-available/immohai.ohaisoft.com
/etc/nginx/sites-enabled/immohai.ohaisoft.com

Die Immohai-Dokumentation ist hier konfiguriert:

/etc/nginx/sites-available/docs.immohai.ohaisoft.com
/etc/nginx/sites-enabled/docs.immohai.ohaisoft.com

Nginx wurde geprüft mit:

sudo nginx -t
sudo systemctl status nginx

Erwartung:

syntax is ok
test is successful
nginx.service active (running)

Port-80-Konflikt beim Einrichten

Beim Einrichten war Port 80 zunächst durch einen alten Container belegt.

Blockierender Container:

atlas-web

Typisches Fehlerbild:

bind() to 0.0.0.0:80 failed (98: Address already in use)

Prüfung:

sudo ss -ltnp | grep ':80'
docker ps --format "table {{.Names}}\t{{.Ports}}"

Lösung:

docker stop atlas-web
docker rm atlas-web

Danach konnte Nginx Port 80 übernehmen.


Firewall

Die Ubuntu-Firewall erlaubt SSH sowie HTTP/HTTPS.

Aktive Regeln:

OpenSSH
Nginx Full

Prüfung:

sudo ufw status verbose

Erwartung:

22/tcp        ALLOW IN
80,443/tcp    ALLOW IN

oder sinngemäß:

OpenSSH       ALLOW IN
Nginx Full    ALLOW IN

Externe Port-Prüfung

Port 80 wurde zusätzlich von außen mit Windows PowerShell geprüft.

Test-NetConnection immohai.ohaisoft.com -Port 80
Test-NetConnection docs.immohai.ohaisoft.com -Port 80

Ergebnis:

TcpTestSucceeded : True

Damit war bestätigt, dass Let's Encrypt den Server für die HTTP-Challenge erreichen kann.


HTTP-Prüfung

Vor der HTTPS-Einrichtung wurde HTTP geprüft:

curl -I http://immohai.ohaisoft.com
curl -I http://docs.immohai.ohaisoft.com

Ergebnis:

HTTP/1.1 200 OK

Damit waren DNS, Nginx und die lokalen Docker-Weiterleitungen korrekt eingerichtet.


HTTPS

HTTPS wurde mit Certbot und Let's Encrypt eingerichtet.

Verwendeter Certbot-Befehl:

sudo certbot --nginx -d immohai.ohaisoft.com -d docs.immohai.ohaisoft.com

Certbot hat das Zertifikat erfolgreich erstellt und automatisch in die Nginx-Konfiguration eingebunden.

Aktive HTTPS-URLs:

https://immohai.ohaisoft.com
https://docs.immohai.ohaisoft.com

Wichtig:

Private Keys, Zertifikatsdateien und andere sensible Daten dürfen niemals in Git gespeichert werden.

HTTPS-Prüfung

HTTPS wurde geprüft mit:

curl -I https://immohai.ohaisoft.com
curl -I https://docs.immohai.ohaisoft.com

Ergebnis:

HTTP/1.1 200 OK

Damit sind App und Dokumentation über HTTPS erreichbar.


HTTP-Weiterleitung auf HTTPS

HTTP sollte auf HTTPS weiterleiten.

Prüfung:

curl -I http://immohai.ohaisoft.com
curl -I http://docs.immohai.ohaisoft.com

Erwartung:

301 Moved Permanently

oder eine andere permanente Weiterleitung auf HTTPS.


Automatische Zertifikatserneuerung

Die automatische Zertifikatserneuerung wurde getestet mit:

sudo certbot renew --dry-run

Ergebnis:

Congratulations, all simulated renewals succeeded

Damit ist die automatische Erneuerung funktionsfähig.


Aktueller Deployment-Status

Bereich Status
Domain gekauft erledigt
DNS eingerichtet erledigt
DNS mit nslookup geprüft erledigt
Docker-Ports lokal gebunden erledigt
Nginx Reverse Proxy eingerichtet erledigt
Port-80-Konflikt gelöst erledigt
Firewall geprüft erledigt
HTTP getestet erledigt
HTTPS eingerichtet erledigt
Certbot Renewal getestet erledigt
Dokumentation online erledigt

Aktuelle Prüfkommandos

Diese Kommandos können zur schnellen Prüfung des Deployments verwendet werden:

cd /home/fober/projects/immohai

docker ps --format "table {{.Names}}\t{{.Ports}}"

sudo nginx -t
sudo systemctl status nginx

curl -I https://immohai.ohaisoft.com
curl -I https://docs.immohai.ohaisoft.com

sudo certbot renew --dry-run

Abgrenzung zum Developer Playbook

Diese Immohai-Projektdokumentation beschreibt konkret:

  • welche Domain Immohai verwendet
  • welche DNS-Records gesetzt sind
  • welche Subdomains aktiv sind
  • welche lokalen Ports verwendet werden
  • welche Nginx-Weiterleitungen eingerichtet sind
  • ob HTTPS eingerichtet und getestet wurde

Die allgemeine wiederverwendbare Anleitung liegt vorerst hier:

playbook-staging/deployment/01-domain-dns-reverse-proxy.md

Später wird sie in das eigenständige Developer-Playbook-Repository übertragen.


Geplante Zielstruktur

Die aktuelle Projektstruktur lautet noch:

/home/fober/projects/immohai

Die spätere Zielstruktur lautet:

/home/fober/workspace/
├── developer-playbook/
└── apps/
    └── Immohai/

Die Migration erfolgt später, sobald das eigenständige Developer-Playbook-Repository erstellt wurde.


Checkliste Immohai

Domain und DNS

  • [x] Domain gekauft: ohaisoft.com
  • [x] A-Record für @ gesetzt
  • [x] A-Record für www gesetzt
  • [x] A-Record für playbook gesetzt
  • [x] A-Record für immohai gesetzt
  • [x] A-Record für docs.immohai gesetzt
  • [x] DNS mit nslookup geprüft

Docker

  • [x] Immohai App auf lokalen Port 127.0.0.1:8200 umgestellt
  • [x] Immohai Doku auf lokalen Port 127.0.0.1:8201 umgestellt
  • [x] Docker Compose mit docker compose config geprüft
  • [x] Container neu gestartet
  • [x] Lokaler Zugriff per curl geprüft

Nginx

  • [x] Nginx installiert
  • [x] Port-80-Konflikt mit altem Container atlas-web gelöst
  • [x] Nginx gestartet
  • [x] Reverse Proxy für immohai.ohaisoft.com eingerichtet
  • [x] Reverse Proxy für docs.immohai.ohaisoft.com eingerichtet
  • [x] Nginx-Konfiguration geprüft
  • [x] HTTP-Zugriff erfolgreich getestet

HTTPS

  • [x] Certbot installiert
  • [x] HTTPS für immohai.ohaisoft.com eingerichtet
  • [x] HTTPS für docs.immohai.ohaisoft.com eingerichtet
  • [x] Automatische Zertifikatserneuerung getestet

Developer Playbook

  • [ ] Repository developer-playbook erstellt
  • [ ] Container für Developer Playbook eingerichtet
  • [ ] Reverse Proxy für playbook.ohaisoft.com eingerichtet
  • [ ] HTTPS für playbook.ohaisoft.com eingerichtet