Info:
This tutorial is specialized for people who want to run Camo themselves. E.g. when you need clustering or have several POP's. In case you just want to use camo I recommend you visiting the original post.
The following "variables" will be used:
<domain> -> your camo domain (e.g. https://camo.nodebb.org or camo.nodebb.org)
<your.crt> -> the path to your ssl certificate (e.g. /home/ssl/org.nodebb.crt)
<your.key> -> the path to your ssl private key (e.g. /home/ssl/org.nodebb.key). This key was generated by yourself when you created your certificate sign request / .csr
<port> -> your camo port, either from the standalone or integrated one.
<camo-key> -> a secret HMAC key. You could generate this using pwgen -sB 64
Configuring NGINX for proxying camo
Get a free SSL certificate from Let's Encrypt or StartCom, and add this new server block to your NGINX configuration:
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name <domain>;
access_log off;
error_log /dev/null;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_session_tickets off;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
ssl_ecdh_curve secp384r1;
ssl_buffer_size 1400;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_certificate <your.crt>;
ssl_certificate_key <your.key>;
charset utf-8;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_redirect off;
proxy_http_version 1.1;
proxy_pass http://localhost:<port>;
}
}
Make sure that:
- your ssl certificate is valid and includes your subdomain
camo.domain.tld
- you have at least 2 server blocks now in your NGINX configuration.
Then run service nginx configtest
to validate your new configuration. If it succeeds you can reload NGINX by using service nginx reload
. After this you can add camo.<domain.tld>
into the camo host field and reload NodeBB. Now continue with installing camo.
Installing camo
Camo is being configured by environment variables which is why I usually run it in docker, but here I'll provide details on how to install it directly like NodeBB. This is only useful if you want more fine grained control or clustering for sites with heavy load.
Clone camo from GitHub by executing:
git clone https://github.com/atmos/camo.git
You can then cd
into the camo
folder and start it using:
sudo PORT=<port> CAMO_KEY="<camo-key>" node server.js
Other variables you could add are:
CAMO_HEADER_VIA
: The string for Camo to include in the Via and User-Agent headers it sends in requests to origin servers. (default: Camo Asset Proxy <version>
)
CAMO_LENGTH_LIMIT
: The maximum Content-Length Camo will proxy. (default: 5242880
)
CAMO_LOGGING_ENABLED
: The logging level used for reporting debug or error information. Options are debug and disabled. (default: disabled
)
CAMO_MAX_REDIRECTS
: The maximum number of redirects Camo will follow while fetching an image. (default: 4
)
CAMO_SOCKET_TIMEOUT
: The maximum number of seconds Camo will wait before giving up on fetching an image. (default: 10
)
CAMO_TIMING_ALLOW_ORIGIN
: The string for Camo to include in the Timing-Allow-Origin header it sends in responses to clients. The header is omitted if this environment variable is not set. (default: not set
)
CAMO_HOSTNAME
: The Camo-Host header value that Camo will send. (default: unknown
)
CAMO_KEEP_ALIVE
: Whether or not to enable keep-alive session. (default: false
)
I would also recommend installing screen
and forever
, on Debian you would do this by executing:
apt-get install screen && npm i -g forever
and then starting your app with:
screen -S camo sudo PORT=<port> CAMO_KEY="<camo-key>" forever server.js
This runs camo in a screen you can exit by using CTRL+A+D
while still letting it run in the background and preserving any error logs. forever keeps care of restarting it in case it crashes. Test if your server.js
starts by manually using node
though before you use them both, otherwise you'll create a process crashing and restarting really fast.