How to deploy a Feathersjs app at Infomaniak

Samuel Pouyt
1 min readFeb 6, 2018

--

Infomaniak use apache for its servers. When you want to deploy a nodejs app, the Apache server will need to be configured correctly in order allow access to your nodejs server. I have already written a small article that describes how to deploy a nodejs app on an Infomaniak Manage Server.

This time I would like to share my configuration — that can only be done via an .htaccess in order to let apps connect to your server via websocket.

This configuration is specific to the Feathersjs implementation of Socket.io. There is nothing special about it, but as far as I had to figure it out. I am sharing it:

RewriteEngine OnRewriteCond %{QUERY_STRING} transport=polling
RewriteRule ^(.*)$ http://localhost:3030/$1 [P]
RewriteCond %{REQUEST_URI} ^/socket.io
RewriteCond %{QUERY_STRING} transport=websocket
RewriteRule ^(.*)$ ws://localhost:3030/$1 [P]
RewriteRule ^(.*)$ http://localhost:3030/$1 [P]

Obviously the url rewriting needs to be turned on. The first condition checks for http requests that have the parameter transport set to polling this is the initial request to create a websocket connection, thus we want to match it first and proxy it as an http call to the nodejs server.

Next we check it the request is a socket connection. If it is the case we proxy it to the correct serveur location with the correct protocol (ws or wss ).

Finally we proxy all the other requests to the normal http endpoints.

Thus the server can work with websockets and with http. That is simple, but I hope it will save you some time.

--

--

Samuel Pouyt
Samuel Pouyt

Written by Samuel Pouyt

Tech Lead/Software engineer. I am currently working on Legal Technologies and Computational Law. I enjoy opera, philosophy nature and literature.

No responses yet