Installation/Camo: Difference between revisions

From diaspora* project wiki
(camos default port is 8081)
(JD is funny sometimes.)
Line 84: Line 84:
{{#tag:syntaxhighlight|
{{#tag:syntaxhighlight|
"application/octet-stream",
"application/octet-stream",
"binary/octet-stream"
"binary/octet-stream",
""
|lang=javascript}}
|lang=javascript}}



Revision as of 21:06, 1 December 2014

WarningWarning:Camo integration for diaspora* is not yet in a released version. This documentation is a work in progress so it is ready when the Camo integration is released.
Request targets, without Camo
Request targets, with Camo

About Camo and why there is support for it in diaspora*

Camo is a small Node.js application to proxy insecure assets. Its main reason is to service HTTP assets over an HTTPS channel to avoid mixed content warnings. Another usage is to reduce the amount of external assets to avoid browser connects to third party hosts. Camo will also add a whitelisting to the images MIME type to add some protection against attacks.

diaspora* supports content formatting using Markdown, which also enables users to embed images from third parties. While this is great for creating larger posts with inline images, it is a huge privacy and security problem since most of the images will get hosted by third parties, forcing the users browser to connect to those servers, thus exposing their identities to others.

Since disabling markdown embeds is not a nice solution, we implemented a special mechanism to rewrite markdown image URLs to get proxied through Camo. In addition, it is also possible to proxy remote profile pictures and remote post photos to create an environment almost entirely without external resources.

Why your pod should enable Camo

  • Depending on your configuration, embedded images and/or remote pods content will get proxied through your server, so your user's browsers do not need to connect to external servers. This will increase the users privacy.
  • Your pods frontend will get a little bit of extra protection due to the MIME type whitelist.

Why your pod should not enable Camo

  • Camo will create a huge amount of traffic depending on your settings since it will proxy all the remote images.
  • You will have to maintain a dedicated node.js application, the Camo application is neither shipped nor started with diaspora*.
  • Bugs may occur and images with wrong/missing MIME types will not get served.

Adding Camo to your pod

Setting up Camo

First, you have to set up Node.js on your server. Detailed instructions are available on the Node.js website. Then get a copy of camo's source code and install its dependencies

git clone https://github.com/atmos/camo.git
cd camo
npm install
rake bundle

You are now able to start camo using

coffee server.coffee

You should add a service file to your system to ensure the service is up all the time. Please check https://github.com/atmos/camo#configuration for available and required configurations and generate a shared key for the HMAC generation.

Setting up the reverse proxy

A reverse proxy should be used to connect your Camo instance to the world. By using the server running diaspora*, it is possible to run Camo inside a virtual subdirectory so you do not need a dedicated subdomain. That is handy if you do not own a wildcard certificate.

Here is an example config for nginx, but you should be able to create a version for Apache very easily:

upstream camo {
    server 127.0.0.1:8081;
}

# inside your diaspora* config
location /camo/ {
    proxy_redirect off;
    proxy_pass http://camo/;
    break;
}

Setting up diaspora*

You have to enable and configure the Camo integration in your diaspora.yml, example configuration values and explanations are available inside diaspora.yml.example. Please ensure you considered the amount of users and traffic before enabling proxy modes. Here is a short summary:

  • proxy_markdown_images will enable proxying for all images embedded via markdown. This is recommended, but pay attention if you have a large number of users since it might cause some traffic.
  • proxy_opengraph_thumbnails will proxy thumbnails of OpenGraph embeds. You can turn this on since there are not much OpenGraph embeds right now.
  • proxy_remote_pod_images will proxy all remote images including profile pictures and photos inside posts. Enabling this will create a very private environment, but proxing all those images will create a huge amount of traffic.

Recommended Camo settings

Tests have shown disabling a strict SSL certificate check is a good idea to avoid problems with images from hosts with self-signed certificates (or CACert certificates, if CACert is not in your systems bundle). Also increasing the max file size to 10MiB is recommended due to the large size of some GIFs - and diaspora* loves GIFs. To apply those suggestions, set the following environment variables when starting Camo:

NODE_TLS_REJECT_UNAUTHORIZED=0
CAMO_LENGTH_LIMIT=10485760

To avoid problems with images hosted on Amazon S3 or CloudFlares CDN, it's recommended to add two MIME types to the whitelist in Camos mime-types.json. Just append these to the list:

"application/octet-stream",
"binary/octet-stream",
""

Reporting issues

Please report bugs the usual way and we will decide if it is an implementation bug or something caused by Camo and/or the remote host.