Update Apache configuration example to clarify structure and enhance redirect handling

This commit revises the apache.conf.example file to provide clearer documentation on the configuration structure, emphasizing the separation of HTTP and HTTPS settings. It adds detailed comments regarding the use of separate configuration files for HTTP and HTTPS, and enhances the redirect rules for both www and non-www domains, ensuring proper traffic management and SEO practices.
This commit is contained in:
Torsten Schulz (local)
2025-11-16 12:14:17 +01:00
parent 5b04ed7904
commit 945fd85e39
4 changed files with 183 additions and 4 deletions

View File

@@ -1,5 +1,16 @@
# Apache-Konfiguration für tt-tagebuch.de mit WebSocket-Support
# Apache-Konfiguration für tt-tagebuch.de
#
# HINWEIS: Diese Datei ist eine kombinierte Referenz.
# Für die tatsächliche Konfiguration werden zwei separate Dateien verwendet:
#
# 1. apache-http.conf.example -> /etc/apache2/sites-available/tt-tagebuch.de.conf
# (HTTP, Port 80 - Weiterleitung zu HTTPS)
#
# 2. apache-https.conf.example -> /etc/apache2/sites-available/tt-tagebuch.de-le-ssl.conf
# (HTTPS, Port 443 - Hauptkonfiguration)
#
# Oder verwende das Update-Skript: ./update-apache-config.sh
#
# WICHTIG: Folgende Module müssen aktiviert sein:
# sudo a2enmod proxy
# sudo a2enmod proxy_http
@@ -8,27 +19,42 @@
# sudo a2enmod headers
# sudo systemctl restart apache2
# 301-Weiterleitung von www auf non-www (HTTP)
# ============================================
# HTTP (Port 80) - Weiterleitung zu HTTPS
# ============================================
# HTTP: www.tt-tagebuch.de -> HTTPS: tt-tagebuch.de
<VirtualHost *:80>
ServerName www.tt-tagebuch.de
Redirect permanent / https://tt-tagebuch.de/
</VirtualHost>
# HTTP: tt-tagebuch.de -> HTTPS: tt-tagebuch.de
<VirtualHost *:80>
ServerName tt-tagebuch.de
Redirect permanent / https://tt-tagebuch.de/
</VirtualHost>
# 301-Weiterleitung von www auf non-www (HTTPS)
# ============================================
# HTTPS (Port 443) - Weiterleitung www -> non-www
# ============================================
# HTTPS: www.tt-tagebuch.de -> HTTPS: tt-tagebuch.de (301-Weiterleitung)
<VirtualHost *:443>
ServerName www.tt-tagebuch.de
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/tt-tagebuch.de/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/tt-tagebuch.de/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
Redirect permanent / https://tt-tagebuch.de/
</VirtualHost>
# ============================================
# HTTPS (Port 443) - Hauptkonfiguration (non-www)
# ============================================
<VirtualHost *:443>
ServerName tt-tagebuch.de
@@ -61,4 +87,3 @@
ProxyPass / http://localhost:3050/
ProxyPassReverse / http://localhost:3050/
</VirtualHost>