From 8f4523cd263d173cc70ccea1a7858b66eaa87cfe Mon Sep 17 00:00:00 2001
From: Sascha Schulz <sschulz@dh-software.de>
Date: Di, 18 Mär 2025 12:00:56 +0100
Subject: [PATCH] Merge branch 'draft'

---
 index.html |   99 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 96 insertions(+), 3 deletions(-)

diff --git a/index.html b/index.html
index 96a514b..9152e52 100644
--- a/index.html
+++ b/index.html
@@ -4817,6 +4817,9 @@
 								
 								# Aktivierte vhosts, Symlinks auf obige verfügbare
 								/etc/apache2/sites-enabled/*.conf
+								
+								# Standard HTML Pfad bei Apache
+								/var/www/html
 							</code>
 						</pre>
 					</section>
@@ -4828,11 +4831,11 @@
 								
 								# 000-default.conf als Vorlage nutzen
 								# vm-ubuntu-server durch eigenen Host ersetzen
-								sudo cp 000-default.conf www.vm-ubuntu-server
+								sudo cp 000-default.conf www.vm-ubuntu-server.conf
 								
 								# 'ServerName' einkommentieren und mit eigenem Host anpassen
 								# Weitere Optionen je nach Fall anpassen, z.B. 'DocumentRoot'
-								sudo vim www.vm-ubuntu-server
+								sudo vim www.vm-ubuntu-server.conf
 								
 								# vhost / Site aktivieren
 								sudo a2ensite www.vm-ubuntu-server.conf
@@ -4864,7 +4867,7 @@
 						<pre>
 							<code class="bash" data-trim data-line-numbers>
 								# scp [Quelle] [Ziel], z.B.
-								scp index.html user@domain:~/html
+								scp index.html user@domain:~/
 							</code>
 						</pre>
 					</section>
@@ -4872,6 +4875,96 @@
 						<h3>Aufgabe</h3>
 						<p>Richte die Sub-Domain <code>www.vm-ubuntu-server</code> ein und liefere unter dieser Adresse eine beliebige HTML-Seite aus. Dies kann eine minimale selbstgeschriebene oder eine beliebige komplexere aus den vergangenen Veranstaltungen sein, z.B. aus den CSS-Themen (jedoch keine NodeJS-Projekte).</p>
 					</section>
+					<section>
+						<h3>NodeJS und PM2 einrichten</h3>
+					</section>
+					<section>
+						<p>Installation mittels fnm (<code>fast node manager</code>)</p>
+						<pre>
+							<code class="bash" data-trim data-line-numbers>
+								# Abhängigkeit 'unzip' installieren
+								sudo apt install unzip
+								
+								# https://github.com/Schniz/fnm
+								curl -fsSL https://fnm.vercel.app/install | bash
+								
+								# Anschließend die .bashrc neuladen
+								. ~/.bashrc
+								
+								# Aktuelle NodeJS LTS installieren
+								fnm install --lts
+								
+								# Test
+								node -v
+							</code>
+						</pre>
+					</section>
+					<section>
+						<pre>
+							<code class="bash" data-trim data-line-numbers>
+								# PM2
+								npm install -g pm2
+							</code>
+						</pre>
+					</section>
+					<section>
+						<h3>Aufgabe</h3>
+						<p>Richte auf dem Server ein kleines NodeJS-Projekt ein, welches eine beliebige Website zur Verfügung stellt (selber implementieren oder ein bestehendes kopieren). Kopiere das Projekt mit den bekannten Befehlen auf den Server an einen beliebigen Ort. Teste anschließend die Lauffähigkeit im Browser per IP und Port der Anwendung.</p>
+					</section>
+					<section>
+						<h3>Einrichten eines Reverse-Proxy</h3>
+					</section>
+					<section>
+						<img data-src="/assets/images/proxy-types.svg">
+					</section>
+					<section>
+						<p>Aktivieren des benötigten Moduls</p>
+						<pre>
+							<code class="bash" data-trim data-line-numbers>
+								# Apache 2 enable module
+								sudo a2enmod proxy
+							</code>
+						</pre>
+						<p>Neue Direktiven</p>
+						<ul>
+							<li>ProxyPass</li>
+							<li>ProxyPassReverse</li>
+							<li>ProxyRequests</li>
+						</ul>
+					</section>
+					<section>
+						<p>Notwendige Anpassungen am vhost</p>
+						<pre>
+							<code class="bash" data-trim data-line-numbers>
+								# DocumentRoot entfernen / auskommentieren
+								#DocumentRoot /var/www/html
+								
+								# Aus Sicherheitsgründen Forward Proxy deaktivieren
+								ProxyRequests Off
+								
+								# ProxyPass [Quelle] [Ziel] (auf Port achten) => Weiterleitung
+								ProxyPass / http://127.0.0.1:9000
+								
+								# ProxyPassReverse [Quelle] [Ziel] (auf Port achten) => URL-Rewrite bei Redirects
+								ProxyPassReverse / http://127.0.0.1:9000
+							</code>
+						</pre>
+						<p>Apache neu starten, um die Änderungen am vhost zu übernehmen</p>
+						<pre>
+							<code class="bash" data-trim data-line-numbers>
+								sudo systemctl reload apache2
+							</code>
+						</pre>
+					</section>
+					<section>
+						<p>In das Verzeichnis der NodeJS-Anwendung wechseln und per PM2 starten</p>
+						<pre>
+							<code class="bash" data-trim data-line-numbers>
+								pm2 start --name my-super-app index.js
+							</code>
+						</pre>
+						<p>Anschließend sollte die NodeJS-Anwendung unter der bereits bekannten Domain erreichbar sein.</p>
+					</section>
 				</section>
 			</div>
 		</div>

--
Gitblit v1.9.3