cable.conf aggiornato (mod_rewrite per proxy)

This commit is contained in:
torn 2017-01-30 18:46:04 +01:00
parent 96d51cff08
commit 58fb910dc4

View file

@ -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>