Skip to content
This repository has been archived by the owner on Aug 22, 2022. It is now read-only.

How to enable ws proxying on apache #209

Merged
merged 1 commit into from
Nov 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/documents/en/host/troubleshooting.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,31 @@ Once this is done, you'll need to login. The `login` link is in the bottom right

Once logged in, use the `View` dropdown menu, and select `User -> all`. You should see one line, which you can delete.
When you refresh your Cozy page, it should ask you to register.

## Websockets do not work in Apache

If you are using Apache and meet some errors in your browser console like the one below, you might want to enable the websocket proxying.

> WebSocket connection to 'wss://domain/public/files/socket.io/?EIO=3&transport=websocket&sid=DGvqewDGc_GvZX-3AAAB' failed: Error during WebSocket handshake: Unexpected response code: 400

First,enable the *proxy_wstunnel* and *mod_rewrite* modules:

```bash
sudo a2enmod proxy_wstunnel
sudo a2enmod mod_rewrite
```

Then edit your apache configuration file (`/etc/apache2/sites-available/cozy.conf` on the default Debian installation for example) to insert the following lines:

```apache-config
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/.*socket\.io [NC]
RewriteCond %{THE_REQUEST} websocket [NC]
RewriteRule /(.*) ws://127.0.0.1:9104/$1 [P,L]
```

Finally, reload apache, and that's it!

```bash
sudo service apache2 reload
```
28 changes: 28 additions & 0 deletions src/documents/fr/host/trouble-shootings.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,31 @@ Une fois fait, vous devez vous connecter. Le lien de connexion est tout en bas

Une fois connecté, utilisez le menu déroulant `View` et choisissez `User -> all`. Vous devriez voir une ligne, que vous pouvez supprimer.
En rafraîchissant la page de votre Cozy, celui-ci devrait vous proposer de vous enregistrer.

## Les websockets ne fonctionnent pas avec Apache

Si vous utilisez Apache et rencontrez des erreurs dans la console de votre navigateur comme celle ci-dessous, suivez la procédure suivante.

> WebSocket connection to 'wss://domain/public/files/socket.io/?EIO=3&transport=websocket&sid=DGvqewDGc_GvZX-3AAAB' failed: Error during WebSocket handshake: Unexpected response code: 400

D'abord, activez les modules *proxy_wstunnel* et *mod_rewrite* :

```bash
sudo a2enmod proxy_wstunnel
sudo a2enmod mod_rewrite
```

Éditez ensuite votre fichier de configuration apache (`/etc/apache2/sites-available/cozy.conf` par défaut pour l'installation Debian par exemple) et insérez les lignes suivantes :

```apache-config
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/.*socket\.io [NC]
RewriteCond %{THE_REQUEST} websocket [NC]
RewriteRule /(.*) ws://127.0.0.1:9104/$1 [P,L]
```

Enfin, relancez apache et c'est tout !

```bash
sudo service apache2 reload
```