Преглед изворни кода

cable.conf aggiornato (mod_rewrite per proxy)

torn пре 7 година
родитељ
комит
58fb910dc4
1 измењених фајлова са 39 додато и 5 уклоњено
  1. 39 5
      cable.conf

+ 39 - 5
cable.conf

@@ -18,13 +18,29 @@
 	#SSLCertificateChainFile /home/cable/certificati/whisper.crt
 
 	# Per proxare websocket (ws://) serve questa roba:
-	#
 	# https://httpd.apache.org/docs/2.4/mod/mod_proxy_wstunnel.html
+	#
+	# Con ProxyPass non sono riuscito a fare il proxy http+websocket.
+	# Ho provato con solo "ProxyPass ws://127.0.0.1:4242/" e anche
+	# mettendo un ProxyPass per http:// e uno per ws://, non va.
+	# Alla fine ho trovato la soluzione usando mod_rewrite leggendo
+	# di gente che ha avuto lo stesso problema (con altri software):
+	#
+	# https://stackoverflow.com/questions/27526281/websockets-and-apache-proxy-how-to-configure-mod-proxy-wstunnel
+	#
+	# Forse non ottimale, ma comunque in produzione lo farei con nginx...
 
-	ProxyVia On
-	ProxyPreserveHost On
-	ProxyPass / ws://127.0.0.1:4242/
-	ProxyPassReverse / ws://127.0.0.1:4242/
+	RewriteEngine On
+	RewriteCond %{HTTP:Upgrade} =websocket [NC]
+	RewriteRule /(.*)           ws://127.0.0.1:4242/$1 [P,L]
+	RewriteCond %{HTTP:Upgrade} !=websocket [NC]
+	RewriteRule /(.*)           http://127.0.0.1:4242/$1 [P,L]
+
+	ProxyPassReverse / http://127.0.0.1:4242/
+
+	CustomLog "/var/log/httpd/cable.access.log" combined
+	ErrorLog "/var/log/httpd/cable.error.log"
+	LogLevel warn
 </VirtualHost>
 
 
@@ -113,3 +129,21 @@
 	</Files>
 </VirtualHost>
 
+
+### Minio
+
+<VirtualHost *:443>
+	ServerName s3.cable.im
+	SSLEngine On
+
+	SSLCertificateFile /etc/letsencrypt/live/s3.cable.im/cert.pem
+	SSLCertificateKeyFile /etc/letsencrypt/live/s3.cable.im/privkey.pem
+	Include /etc/letsencrypt/options-ssl-apache.conf
+	SSLCertificateChainFile /etc/letsencrypt/live/s3.cable.im/chain.pem
+
+	ProxyVia On
+	ProxyPreserveHost On
+	ProxyPass / http://127.0.0.1:9000/
+	ProxyPassReverse / http://127.0.0.1:9000/
+</VirtualHost>
+