Refactor yourpart-https.conf for enhanced WebSocket and API request handling
- Updated www redirect to exclude API and WebSocket paths for improved functionality. - Organized WebSocket and API proxy settings within Location blocks for better clarity and maintainability. - Consolidated WebSocket upgrade rules for Socket.io and daemon connections, ensuring consistent handling.
This commit is contained in:
@@ -24,34 +24,43 @@
|
|||||||
RequestHeader set X-Forwarded-Proto "https"
|
RequestHeader set X-Forwarded-Proto "https"
|
||||||
AllowEncodedSlashes NoDecode
|
AllowEncodedSlashes NoDecode
|
||||||
|
|
||||||
# www Redirect (muss zuerst kommen, aber nicht für WebSocket-Pfade)
|
# www Redirect (muss zuerst kommen, aber nicht für Proxy-Pfade)
|
||||||
RewriteEngine on
|
RewriteEngine on
|
||||||
RewriteCond %{SERVER_NAME} =your-part.de
|
RewriteCond %{SERVER_NAME} =your-part.de
|
||||||
RewriteCond %{REQUEST_URI} !^/socket\.io/
|
RewriteCond %{REQUEST_URI} !^/(api|socket\.io|ws)/
|
||||||
RewriteCond %{REQUEST_URI} !^/ws/
|
|
||||||
RewriteRule ^ https://www.%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
|
RewriteRule ^ https://www.%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
|
||||||
|
|
||||||
# API-Requests an Backend weiterleiten
|
# API-Requests an Backend weiterleiten (Location-Block hat höhere Priorität)
|
||||||
ProxyPass "/api/" "http://localhost:2020/api/"
|
<Location "/api/">
|
||||||
ProxyPassReverse "/api/" "http://localhost:2020/api/"
|
ProxyPass "http://localhost:2020/api/"
|
||||||
|
ProxyPassReverse "http://localhost:2020/api/"
|
||||||
|
</Location>
|
||||||
|
|
||||||
# Socket.io: WebSocket-Upgrade (muss VOR ProxyPass stehen!)
|
# Socket.io: WebSocket und HTTP mit Location-Block
|
||||||
RewriteCond %{HTTP:Upgrade} websocket [NC]
|
<LocationMatch "^/socket.io/">
|
||||||
RewriteCond %{HTTP:Connection} upgrade [NC]
|
# WebSocket-Upgrade
|
||||||
RewriteRule ^/socket.io/(.*)$ "ws://localhost:2020/socket.io/$1" [P,L]
|
RewriteEngine on
|
||||||
|
RewriteCond %{HTTP:Upgrade} websocket [NC]
|
||||||
|
RewriteCond %{HTTP:Connection} upgrade [NC]
|
||||||
|
RewriteRule .* "ws://localhost:2020%{REQUEST_URI}" [P,L]
|
||||||
|
|
||||||
|
# HTTP-Fallback für Polling
|
||||||
|
ProxyPass "http://localhost:2020/socket.io/"
|
||||||
|
ProxyPassReverse "http://localhost:2020/socket.io/"
|
||||||
|
</LocationMatch>
|
||||||
|
|
||||||
# Socket.io: HTTP-Fallback für Polling
|
# Daemon: WebSocket mit Location-Block
|
||||||
ProxyPass "/socket.io/" "http://localhost:2020/socket.io/"
|
<LocationMatch "^/ws/">
|
||||||
ProxyPassReverse "/socket.io/" "http://localhost:2020/socket.io/"
|
# WebSocket-Upgrade
|
||||||
|
RewriteEngine on
|
||||||
# Daemon: WebSocket-Upgrade (muss VOR ProxyPass stehen!)
|
RewriteCond %{HTTP:Upgrade} websocket [NC]
|
||||||
RewriteCond %{HTTP:Upgrade} websocket [NC]
|
RewriteCond %{HTTP:Connection} upgrade [NC]
|
||||||
RewriteCond %{HTTP:Connection} upgrade [NC]
|
RewriteRule .* "ws://localhost:4551%{REQUEST_URI}" [P,L]
|
||||||
RewriteRule ^/ws/(.*)$ "ws://localhost:4551/$1" [P,L]
|
|
||||||
|
# HTTP-Fallback
|
||||||
# Daemon: HTTP-Fallback (sollte eigentlich nicht benötigt werden)
|
ProxyPass "http://localhost:4551/"
|
||||||
ProxyPass "/ws/" "http://localhost:4551/"
|
ProxyPassReverse "http://localhost:4551/"
|
||||||
ProxyPassReverse "/ws/" "http://localhost:4551/"
|
</LocationMatch>
|
||||||
|
|
||||||
ErrorLog /var/log/apache2/yourpart.error.log
|
ErrorLog /var/log/apache2/yourpart.error.log
|
||||||
CustomLog /var/log/apache2/yourpart.access.log combined
|
CustomLog /var/log/apache2/yourpart.access.log combined
|
||||||
|
|||||||
Reference in New Issue
Block a user