Update apache-config-example.conf to improve static file handling and reverse proxy configuration. Disable DirectoryIndex to prevent serving index.html directly, and ensure all requests are routed to Node.js. Add comments for clarity on configuration rules.

This commit is contained in:
Torsten Schulz (local)
2025-12-05 08:57:11 +01:00
parent 99097cf213
commit c9b38f9825

View File

@@ -8,15 +8,21 @@
SSLCertificateFile /etc/letsencrypt/live/www.ypchat.net/fullchain.pem SSLCertificateFile /etc/letsencrypt/live/www.ypchat.net/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.ypchat.net/privkey.pem SSLCertificateKeyFile /etc/letsencrypt/live/www.ypchat.net/privkey.pem
# DocumentRoot (optional, falls statische Dateien direkt serviert werden sollen) # DocumentRoot (nur für statische Dateien wie ads.txt)
DocumentRoot /opt/ypchat/docroot DocumentRoot /opt/ypchat/docroot
# WICHTIG: Deaktiviere DirectoryIndex, damit Apache keine index.html direkt serviert
# Alle Anfragen sollen an Node.js weitergeleitet werden
DirectoryIndex disabled
<Directory /opt/ypchat/docroot> <Directory /opt/ypchat/docroot>
AllowOverride None AllowOverride None
Require all granted Require all granted
# Verhindere, dass Apache index.html automatisch serviert
Options -Indexes
</Directory> </Directory>
# Spezielle Regel für /ads.txt # Spezielle Regel für /ads.txt (muss VOR ProxyPass stehen!)
Alias /ads.txt /opt/ypchat/docroot/ads.txt Alias /ads.txt /opt/ypchat/docroot/ads.txt
<Location /ads.txt> <Location /ads.txt>
Require all granted Require all granted
@@ -34,6 +40,7 @@
RewriteRule ^/?(.*) "ws://localhost:4000/$1" [P,L] RewriteRule ^/?(.*) "ws://localhost:4000/$1" [P,L]
# Reverse Proxy zu Node.js # Reverse Proxy zu Node.js
# WICHTIG: ProxyPass muss ALLE Routen abfangen, auch /
ProxyPreserveHost On ProxyPreserveHost On
ProxyPass /ads.txt ! ProxyPass /ads.txt !
ProxyPass / http://localhost:4000/ ProxyPass / http://localhost:4000/