This commit adds a ProxyTimeout setting for WebSocket connections in the Apache configuration, enhancing the server's ability to manage long-lived connections. Additionally, the socket service documentation is updated to clarify compatibility with both Apache and Nginx as reverse proxies. These changes improve the handling of real-time communication in the application.
66 lines
2.1 KiB
Plaintext
66 lines
2.1 KiB
Plaintext
# Apache-Konfiguration für tt-tagebuch.de mit WebSocket-Support
|
|
#
|
|
# WICHTIG: Folgende Module müssen aktiviert sein:
|
|
# sudo a2enmod proxy
|
|
# sudo a2enmod proxy_http
|
|
# sudo a2enmod proxy_wstunnel
|
|
# sudo a2enmod rewrite
|
|
# sudo a2enmod headers
|
|
# sudo systemctl restart apache2
|
|
|
|
<VirtualHost *:443>
|
|
ServerName tt-tagebuch.de
|
|
ServerAlias www.tt-tagebuch.de
|
|
|
|
DocumentRoot /var/www/tt-tagebuch.de
|
|
|
|
<Directory /var/www/tt-tagebuch.de>
|
|
Options Indexes FollowSymLinks
|
|
AllowOverride All
|
|
Require all granted
|
|
</Directory>
|
|
|
|
ErrorLog ${APACHE_LOG_DIR}/tt-tagebuch.de_error.log
|
|
CustomLog ${APACHE_LOG_DIR}/tt-tagebuch.de_access.log combined
|
|
|
|
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
|
|
|
|
ProxyRequests Off
|
|
|
|
# WebSocket-Proxy für Socket.IO
|
|
# WICHTIG: Diese LocationMatch muss VOR den anderen ProxyPass-Direktiven stehen
|
|
<LocationMatch "^/socket\.io/">
|
|
# WebSocket-Upgrade erkennen und weiterleiten
|
|
RewriteEngine on
|
|
RewriteCond %{HTTP:Upgrade} websocket [NC]
|
|
RewriteCond %{HTTP:Connection} upgrade [NC]
|
|
RewriteRule ^/?(.*) "ws://localhost:3050/$1" [P,L]
|
|
|
|
# Fallback für HTTP (Polling) - muss nach dem RewriteRule stehen
|
|
ProxyPass http://localhost:3050/socket.io/
|
|
ProxyPassReverse http://localhost:3050/socket.io/
|
|
|
|
# Headers für WebSocket
|
|
ProxyPreserveHost On
|
|
ProxyAddHeaders On
|
|
RequestHeader set X-Forwarded-Proto "https"
|
|
RequestHeader set X-Real-IP %{REMOTE_ADDR}s
|
|
RequestHeader set X-Forwarded-For %{REMOTE_ADDR}s
|
|
|
|
# Timeouts für WebSocket-Verbindungen
|
|
ProxyTimeout 3600
|
|
</LocationMatch>
|
|
|
|
# API-Routen
|
|
ProxyPass /api http://localhost:3050/api
|
|
ProxyPassReverse /api http://localhost:3050/api
|
|
|
|
# Alle anderen Anfragen an den Backend-Server (für Frontend)
|
|
ProxyPass / http://localhost:3050/
|
|
ProxyPassReverse / http://localhost:3050/
|
|
</VirtualHost>
|
|
|