Files
singlechat/apache-config-example.conf

69 lines
2.2 KiB
Plaintext

<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName ypchat.net
ServerAlias www.ypchat.net
# SSL-Konfiguration
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/www.ypchat.net/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.ypchat.net/privkey.pem
# DocumentRoot (nur für statische Dateien wie ads.txt)
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>
AllowOverride None
Require all granted
# Verhindere, dass Apache index.html automatisch serviert
Options -Indexes
</Directory>
# Spezielle Regel für /ads.txt (muss VOR ProxyPass stehen!)
Alias /ads.txt /opt/ypchat/docroot/ads.txt
<Location /ads.txt>
Require all granted
</Location>
# Rewrite-Engine für alle Rewrite-Regeln
RewriteEngine On
# Rewrite-Regeln für unerwünschte Query-Parameter
RewriteCond %{QUERY_STRING} ^(.*)&?wtd=UrId0B0tLmuMAK9H&?(.*)$ [NC]
RewriteRule ^ %{REQUEST_URI}?%1%2 [R=301,L]
# WebSocket-Support für Socket.IO (muss VOR normalem ProxyPass stehen!)
# Socket.IO verwendet /socket.io/ für Verbindungen
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/socket\.io/(.*) ws://localhost:4000/socket.io/$1 [P,L]
# Reverse Proxy zu Node.js
# WICHTIG: ProxyPass muss ALLE Routen abfangen, auch /
ProxyPreserveHost On
# ProxyPass für Socket.IO (auch für Polling)
ProxyPass /socket.io/ http://localhost:4000/socket.io/
ProxyPassReverse /socket.io/ http://localhost:4000/socket.io/
# Ausnahme für /ads.txt
ProxyPass /ads.txt !
# Alle anderen Anfragen an Node.js
ProxyPass / http://localhost:4000/
ProxyPassReverse / http://localhost:4000/
# Proxy-Einstellungen für WebSockets
ProxyRequests Off
ProxyTimeout 300
# Headers für HTTPS
RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Forwarded-Port "443"
</VirtualHost>
</IfModule>