Skip to content

Instantly share code, notes, and snippets.

@KyonLi
Created February 17, 2018 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KyonLi/529cf06e6c4a5cd622590ba0f5728ee2 to your computer and use it in GitHub Desktop.
Save KyonLi/529cf06e6c4a5cd622590ba0f5728ee2 to your computer and use it in GitHub Desktop.
Apache2 websocket proxy
<VirtualHost *:443>
ServerName mysite.com
ServerAlias www.mysite.com
SSLEngine on
SSLProxyEngine on
ProxyPreserveHost on
ProxyRequests Off
SSLCertificateFile /etc/apache2/ssl/mysite.com.crt
SSLCertificateKeyFile /etc/apache2/ssl/mysite.com.key
SSLCertificateChainFile /etc/apache2/ssl/ca.cer
DocumentRoot /var/www/errorPages
ErrorDocument 503 /503.html
ProxyPass /503.html !
ProxyPass / http://localhost:3999/
ProxyPassReverse / http://localhost:3999/
RewriteEngine on
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
RewriteRule .* ws://localhost:3999%{REQUEST_URI} [P]
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment