Last active
February 12, 2019 21:13
-
-
Save namnv609/a255f5c69018e7d15421f749a4abd5d4 to your computer and use it in GitHub Desktop.
ActionCable WebSocket with Apache2 proxy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80 *:443> | |
# Domain | |
ServerName servername.domain | |
SSLEngine On | |
SSLProxyEngine On | |
# Path to SSL CRT file | |
SSLCertificateFile /etc/apache2/ssl/apache.crt | |
# Path to SSL KEY file | |
SSLCertificateKeyFile /etc/apache2/ssl/apache.key | |
ProxyRequests Off | |
ProxyPreserveHost On | |
<Location /> | |
ProxyPass http://0.0.0.0:3000/ | |
ProxyPassReverse http://0.0.0.0:3000/ | |
</Location> | |
<Location /cable> | |
ProxyPass ws://0.0.0.0:3000/cable | |
ProxyPassReverse ws://0.0.0.0:3000/cale | |
</Location> | |
</VirtualHost> |
@ForeverYoung This code solved for me.
<VirtualHost *:80 *:443>
ServerName api.mysite.com.br
ServerAlias app.mysite.com.br
DocumentRoot "/webapp/mysite/public"
#SSLEngine On
#SSLProxyEngine On
ProxyRequests Off
ProxyPreserveHost on
<Location />
ProxyPass http://0.0.0.0:3000/
ProxyPassReverse http://0.0.0.0:3000/
</Location>
# ----------------------------------------
# difference
# host.com.br instead of 0.0.0.0:3000
<Location /cable>
ProxyPass ws://mysite.com.br:3000/cable
ProxyPassReverse ws://mysite.com.br:3000/cable
</Location>
# ----------------------------------------
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Directory "/webapp/mysite/public">
Options FollowSymlinks Multiviews
AllowOverride All
Allow from all
Require all granted
RailsEnv production
</Directory>
#SSLCertificateFile /etc/letsencrypt/live/mysite.com.br/fullchain.pem
#SSLCertificateKeyFile /etc/letsencrypt/live/mysite.com.br/privkey.pem
#Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Doesn't work for me (((
I've got
"WebSocket connection to 'wss://site.domain/cable' failed: Connection closed before receiving a handshake response"
Can you help me? I've already broken my mind with it ((
I'm stuck (((((((