Merge branch '8784-dir-listings'
[arvados.git] / doc / install / install-keepproxy.html.textile.liquid
1 ---
2 layout: default
3 navsection: installguide
4 title: Install Keepproxy server
5 ...
6 {% comment %}
7 Copyright (C) The Arvados Authors. All rights reserved.
8
9 SPDX-License-Identifier: CC-BY-SA-3.0
10 {% endcomment %}
11
12 The Keepproxy server is a gateway into your Keep storage. Unlike the Keepstore servers, which are only accessible on the local LAN, Keepproxy is suitable for clients located elsewhere on the internet. Specifically, in contrast to Keepstore:
13 * A client writing through Keepproxy generates less network traffic: the client sends a single copy of a data block, and Keepproxy sends copies to the appropriate Keepstore servers.
14 * A client can write through Keepproxy without precomputing content hashes. Notably, the browser-based upload feature in Workbench requires Keepproxy.
15 * Keepproxy checks API token validity before processing requests. (Clients that can connect directly to Keepstore can use it as scratch space even without a valid API token.)
16
17 By convention, we use the following hostname for the Keepproxy server:
18
19 <div class="offset1">
20 table(table table-bordered table-condensed).
21 |_Hostname_|
22 |keep.@uuid_prefix@.your.domain|
23 </div>
24
25 This hostname should resolve from anywhere on the internet.
26
27 h2. Install Keepproxy
28
29 On Debian-based systems:
30
31 <notextile>
32 <pre><code>~$ <span class="userinput">sudo apt-get install keepproxy</span>
33 </code></pre>
34 </notextile>
35
36 On Red Hat-based systems:
37
38 <notextile>
39 <pre><code>~$ <span class="userinput">sudo yum install keepproxy</span>
40 </code></pre>
41 </notextile>
42
43 Verify that Keepproxy is functional:
44
45 <notextile>
46 <pre><code>~$ <span class="userinput">keepproxy -h</span>
47 ...
48 Usage: keepproxy [-config path/to/keepproxy.yml]
49 ...
50 </code></pre>
51 </notextile>
52
53 h3. Create an API token for the Keepproxy server
54
55 {% assign railscmd = "bundle exec ./script/get_anonymous_user_token.rb --get" %}
56 {% assign railsout = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" %}
57 The Keepproxy server needs a token to talk to the API server.  On the <strong>API server</strong>, use the following command to create the token.  {% include 'install_rails_command' %}
58
59 h3. Set up the Keepproxy service
60
61 Install runit to supervise the keepproxy daemon.  {% include 'install_runit' %}
62
63 The run script for the keepproxy service should set the environment variables @ARVADOS_API_TOKEN@ (with the token you just generated), @ARVADOS_API_HOST@, and, if needed, @ARVADOS_API_HOST_INSECURE@.  The core keepproxy command to run is:
64
65 <notextile>
66 <pre><code>ARVADOS_API_TOKEN=<span class="userinput">{{railsout}}</span> ARVADOS_API_HOST=<span class="userinput">uuid_prefix.your.domain</span> exec keepproxy
67 </code></pre>
68 </notextile>
69
70 h3. Set up a reverse proxy with SSL support
71
72 Because the Keepproxy is intended for access from anywhere on the internet, it is recommended to use SSL for transport encryption.
73
74 This is best achieved by putting a reverse proxy with SSL support in front of Keepproxy. Keepproxy itself runs on port 25107 by default; your reverse proxy can run on port 443 and pass requests to Keepproxy on port 25107.
75
76 <notextile><pre>
77 upstream keepproxy {
78   server                127.0.0.1:<span class="userinput">25107</span>;
79 }
80
81 server {
82   listen                <span class="userinput">[your public IP address]</span>:443 ssl;
83   server_name           keep.<span class="userinput">uuid_prefix</span>.your.domain;
84
85   proxy_connect_timeout 90s;
86   proxy_read_timeout    300s;
87   proxy_set_header      X-Real-IP $remote_addr;
88
89   ssl                   on;
90   ssl_certificate       /etc/nginx/keep.<span class="userinput">uuid_prefix</span>.your.domain-ssl.crt;
91   ssl_certificate_key   /etc/nginx/keep.<span class="userinput">uuid_prefix</span>.your.domain-ssl.key;
92
93   # Clients need to be able to upload blocks of data up to 64MiB in size.
94   client_max_body_size  64m;
95
96   location / {
97     proxy_pass          http://keepproxy;
98   }
99 }
100 </pre></notextile>
101
102 Note: if the Web uploader is failing to upload data and there are no logs from keepproxy, be sure to check the nginx proxy logs.  In addition to "GET" and "PUT", The nginx proxy must pass "OPTIONS" requests to keepproxy, which should respond with appropriate Cross-origin resource sharing headers.  If the CORS headers are not present, brower security policy will cause the upload request to silently fail.  The CORS headers are generated by keepproxy and should not be set in nginx.
103
104 h3. Tell the API server about the Keepproxy server
105
106 The API server needs to be informed about the presence of your Keepproxy server. Please execute the following commands on your <strong>shell server</strong>.
107
108 <notextile>
109 <pre><code>~$ <span class="userinput">uuid_prefix=`arv --format=uuid user current | cut -d- -f1`</span>
110 ~$ <span class="userinput">echo "Site prefix is '$uuid_prefix'"</span>
111 ~$ <span class="userinput">read -rd $'\000' keepservice &lt;&lt;EOF; arv keep_service create --keep-service "$keepservice"</span>
112 <span class="userinput">{
113  "service_host":"<strong>keep.$uuid_prefix.your.domain</strong>",
114  "service_port":443,
115  "service_ssl_flag":true,
116  "service_type":"proxy"
117 }
118 EOF</span>
119 </code></pre></notextile>