Skip to content

Instantly share code, notes, and snippets.

@kgust
Last active April 28, 2017 01:18
Show Gist options
  • Save kgust/a9dcf4317f1e5de32c2a47779ab22d56 to your computer and use it in GitHub Desktop.
Save kgust/a9dcf4317f1e5de32c2a47779ab22d56 to your computer and use it in GitHub Desktop.
Use Apache for both http and web service traffic

Of course you can do this.

Firstly you have to check your Apache version. You should have 2.4+ version. I will show you command for my server on Ubuntu 14.4.

Secondly, turn on necessary apache modules:

a2enmod proxy
a2enmod proxy_http
a2enmod proxy_wstunnel

Open conf of your domain, in my case that was a path to file:

/etc/apache2/sites-available/myDomain.pl.conf

Next, append this code

<VirtualHost>

.
.
.

RewriteEngine on

RewriteCond %{QUERY_STRING} transport=polling
RewriteRule /(.*)$ http://localhost:3001/$1 [P]

ProxyRequests off
ProxyPass /socket.io ws://localhost:3001/socket.io
ProxyPassReverse /socket.io ws://localhost:3001/socket.io

ProxyPass        /socket.io http://localhost:3001/socket.io
ProxyPassReverse /socket.io http://localhost:3001/socket.io
</VirtualHost>

Finally restart your apache

service apache2 restart
Have fun!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment