Created
August 21, 2019 19:29
-
-
Save skorotkiewicz/28ce7d2422508fa38d843d64342050d6 to your computer and use it in GitHub Desktop.
Socket.io via Apache Reverse Proxy
This file contains 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> | |
ServerName example.com | |
ServerAlias example.com www.example.com | |
ServerAdmin admin@example.com | |
RewriteEngine on | |
ReWriteCond %{SERVER_PORT} !^443$ | |
RewriteRule ^/(.*) https://example.com/$1 [NC,R,L] | |
</VirtualHost> | |
<VirtualHost *:443> | |
ServerName example.com | |
ServerAlias example.com www.example.com | |
ServerAdmin admin@example.com | |
RewriteEngine On | |
RewriteCond %{REQUEST_URI} ^/socket.io [NC] | |
RewriteCond %{QUERY_STRING} transport=websocket [NC] | |
RewriteRule /(.*) ws://127.0.0.1:3020/$1 [P,L] | |
ProxyPass /socket.io http://127.0.0.1:3020/socket.io | |
ProxyPassReverse /socket.io http://127.0.0.1:3020/socket.io | |
<Location /> | |
ProxyPass http://127.0.0.1:3000/ | |
ProxyPassReverse http://127.0.0.1:3000/ | |
</Location> | |
SSLEngine on | |
SSLCertificateFile /etc/letsencrypt/example.com/cert.pem | |
SSLCertificateKeyFile /etc/letsencrypt/example.com/privkey.pem | |
SSLCertificateChainFile /etc/letsencrypt/example.com/fullchain.pem | |
ErrorLog /var/log/apache2/error.log | |
CustomLog /var/log/apache2/access.log combined | |
</VirtualHost> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment