# Funktionelles Hosting

{% hint style="info" %}
Verantwortlicher: Robert L.
{% endhint %}

Diese Seite soll ein wenig technischen Hintergrund geben, wie wir ein funktionelles Hosting erreicht haben. Für das Hosten der BaSyx-UI haben wir uns für eine VM auf Microsofts Cloud-Anbieter [Azure](https://azure.microsoft.com/en-us) entschieden, da dieser ein Kontingent von 100$ für Studenten bereitstellt.&#x20;

## Erste Versuche und Tests

### Azure VM Setup

1. **Erstellen der VM**: Ich habe mich bei meinem Azure-Konto angemeldet und eine neue virtuelle Maschine erstellt. Dabei habe ich mich für eine Ubuntu und erstmal 1gb RAM entschieden,.

### DNS-Konfiguration mit Cloudflare

1. Ich habe mich bei Cloudflare angemeldet und meine Domain hinzugefügt.
2. Dort wurde dann ein `A` Eintrag mit der öffentlichen IPv4 meiner VM erstellt.
3. Die Ports `443` und `80` wurden in der Azure WebUI geöffnet. Diese müssen offen sein, damit Caddy ein SSL Zertifikat bei *Let's Encrypt* erfolgreich anfordern kann.

### TLS-Zertifikate mit Caddy

1. Ich habe mich in meine VM eingeloggt und Caddy installiert. Dazu bin ich den Anweisungen auf [dieser Seite gefolgt.](https://caddyserver.com/docs/install#debian-ubuntu-raspbian)
2. Caddyfile schreiben:

{% code lineNumbers="true" %}

```json
basichs.goofyboxd.space {
	reverse_proxy localhost:3000
	log {
		output file /var/log/caddy/access.log
	}
	tls <meine-email@example.com>
}
```

{% endcode %}

* Der lokale Dienst (die BaSyx WebUI) läuft auf Port 3000
* Caddy dient als [Reverse Proxy](https://en.wikipedia.org/wiki/Reverse_proxy) und stellt mir ein SSL Zertifikat für HTTPS zur Verfügung
* Caddy liefert den content auf Port 443 (HTTPS)
* In Azure muss Port 443 offen sein, nicht Port 3000

{% hint style="info" %}
Durch die Kombination aus Azure, Cloudflare und Caddy habe ich eine stabile Base mit der ich Seiten mit HTTPS-Unterstützung hosten kann.&#x20;
{% endhint %}

### Probleme

* Erste Tests zeigten, dass 1gb an RAM absolut nicht ausreichend sind. Sobald die Website [basichs.goofyboxd.space](https://basichs.goofyboxd.space) in einem Webbrowser aufgerufen wurde, ist die Azure VM gecrashed.
* In der Azure WebUI habe ich den RAM + die CPU geupgradet, jedoch sind die monatlichen Kosten nun etwa **35$**
  * Das hat zur Folge, dass der Server nun die meinste Zeit offline ist, um Kosten zu sparen


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://basyx-security-plugin.gitbook.io/basyx-security/technisches/funktionelles-hosting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
