Merge branch 'master' into 14715-keepprox-config
[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. Update the cluster config
54
55 Edit the cluster config at @/etc/arvados/config.yml@ and set @Services.Keepproxy.ExternalURL@ and @Services.Keepproxy.InternalURLs@.  Replace @zzzzz@ with your cluster id.
56
57 <notextile>
58 <pre><code>Clusters:
59   zzzzz:
60     Services:
61       <span class="userinput">Keepproxy:
62         ExternalURL: https://keep.uuid_prefix.your.domain
63         InternalURLs:
64           "http://localhost:25107": {}
65 </span></code></pre>
66 </notextile>
67
68 h3. Set up the Keepproxy service
69
70 Install runit to supervise the keepproxy daemon.  {% include 'install_runit' %}
71
72 The keepproxy command to run is:
73
74 <notextile>
75 <pre><code>~$ <span class="userinput">exec keepproxy
76 </code></pre>
77 </notextile>
78
79 h3. Set up a reverse proxy with SSL support
80
81 Because the Keepproxy is intended for access from anywhere on the internet, it is recommended to use SSL for transport encryption.
82
83 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.
84
85 <notextile><pre>
86 upstream keepproxy {
87   server                127.0.0.1:<span class="userinput">25107</span>;
88 }
89
90 server {
91   listen                  <span class="userinput">[your public IP address]</span>:443 ssl;
92   server_name             keep.<span class="userinput">uuid_prefix</span>.your.domain;
93
94   proxy_connect_timeout   90s;
95   proxy_read_timeout      300s;
96   proxy_set_header        X-Real-IP $remote_addr;
97   proxy_http_version      1.1;
98   proxy_request_buffering off;
99
100   ssl                     on;
101   ssl_certificate         /etc/nginx/keep.<span class="userinput">uuid_prefix</span>.your.domain-ssl.crt;
102   ssl_certificate_key     /etc/nginx/keep.<span class="userinput">uuid_prefix</span>.your.domain-ssl.key;
103
104   # Clients need to be able to upload blocks of data up to 64MiB in size.
105   client_max_body_size    64m;
106
107   location / {
108     proxy_pass            http://keepproxy;
109   }
110 }
111 </pre></notextile>
112
113 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.
114
115 h3. Tell the API server about the Keepproxy server
116
117 The API server needs to be informed about the presence of your Keepproxy server.
118
119 First, if you don't already have an admin token, create a superuser token.
120
121 {% include 'create_superuser_token' %}
122
123 Configure your environment to run @arv@ using the output of create_superuser_token.rb:
124
125 <pre>
126 export ARVADOS_API_HOST=zzzzz.example.com
127 export ARVADOS_API_TOKEN=zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
128 </pre>
129
130 <notextile>
131 <pre><code>~$ <span class="userinput">uuid_prefix=`arv --format=uuid user current | cut -d- -f1`</span>
132 ~$ <span class="userinput">echo "Site prefix is '$uuid_prefix'"</span>
133 ~$ <span class="userinput">read -rd $'\000' keepservice &lt;&lt;EOF; arv keep_service create --keep-service "$keepservice"</span>
134 <span class="userinput">{
135  "service_host":"<strong>keep.$uuid_prefix.your.domain</strong>",
136  "service_port":443,
137  "service_ssl_flag":true,
138  "service_type":"proxy"
139 }
140 EOF</span>
141 </code></pre></notextile>
142
143 h3. Testing keepproxy
144
145 Log into a host that is on an external network from your private Arvados network.  The host should be able to contact your keepproxy server (eg keep.$uuid_prefix.arvadosapi.com), but not your keepstore servers (eg keep[0-9].$uuid_prefix.arvadosapi.com).
146
147 Install the "Python SDK":{{site.baseurl}}/sdk/python/sdk-python.html
148
149 @ARVADOS_API_HOST@ and @ARVADOS_API_TOKEN@ must be set in the environment.
150
151 You should now be able to use @arv-put@ to upload collections and @arv-get@ to fetch collections, for an example see "Testing keep.":install-keepstore.html#testing on the keepstore install page.