Bump loofah from 2.2.3 to 2.3.1 in /apps/workbench
[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 Usage of keepproxy:
48   -config file
49         Site configuration file (default may be overridden by setting an ARVADOS_CONFIG environment variable) (default "/etc/arvados/config.yml")
50   -dump-config
51         write current configuration to stdout and exit
52 [...]
53   -version
54         print version information and exit.
55 </code></pre>
56 </notextile>
57
58 h3. Update the cluster config
59
60 Edit the cluster config at @/etc/arvados/config.yml@ and set @Services.Keepproxy.ExternalURL@ and @Services.Keepproxy.InternalURLs@.  Replace @uuid_prefix@ with your cluster id.
61
62 <notextile>
63 <pre><code>Clusters:
64   <span class="userinput">uuid_prefix</span>:
65     Services:
66       Keepproxy:
67         ExternalURL: <span class="userinput">https://keep.uuid_prefix.your.domain</span>
68         InternalURLs:
69           <span class="userinput">"http://localhost:25107": {}</span>
70 </span></code></pre>
71 </notextile>
72
73 h3. Set up a reverse proxy with SSL support
74
75 Because the Keepproxy is intended for access from anywhere on the internet, it is recommended to use SSL for transport encryption.
76
77 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.
78
79 <notextile><pre>
80 upstream keepproxy {
81   server                127.0.0.1:<span class="userinput">25107</span>;
82 }
83
84 server {
85   listen                  <span class="userinput">[your public IP address]</span>:443 ssl;
86   server_name             keep.<span class="userinput">uuid_prefix</span>.your.domain;
87
88   proxy_connect_timeout   90s;
89   proxy_read_timeout      300s;
90   proxy_set_header        X-Real-IP $remote_addr;
91   proxy_http_version      1.1;
92   proxy_request_buffering off;
93
94   ssl                     on;
95   ssl_certificate         /etc/nginx/keep.<span class="userinput">uuid_prefix</span>.your.domain-ssl.crt;
96   ssl_certificate_key     /etc/nginx/keep.<span class="userinput">uuid_prefix</span>.your.domain-ssl.key;
97
98   # Clients need to be able to upload blocks of data up to 64MiB in size.
99   client_max_body_size    64m;
100
101   location / {
102     proxy_pass            http://keepproxy;
103   }
104 }
105 </pre></notextile>
106
107 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.
108
109 h3. Tell the API server about the Keepproxy server
110
111 The API server needs to be informed about the presence of your Keepproxy server.
112
113 First, if you don't already have an admin token, create a superuser token.
114
115 {% include 'create_superuser_token' %}
116
117 Configure your environment to run @arv@ using the output of create_superuser_token.rb:
118
119 <pre>
120 export ARVADOS_API_HOST=zzzzz.example.com
121 export ARVADOS_API_TOKEN=zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
122 </pre>
123
124 <notextile>
125 <pre><code>~$ <span class="userinput">uuid_prefix=`arv --format=uuid user current | cut -d- -f1`</span>
126 ~$ <span class="userinput">echo "Site prefix is '$uuid_prefix'"</span>
127 ~$ <span class="userinput">read -rd $'\000' keepservice &lt;&lt;EOF; arv keep_service create --keep-service "$keepservice"</span>
128 <span class="userinput">{
129  "service_host":"<strong>keep.$uuid_prefix.your.domain</strong>",
130  "service_port":443,
131  "service_ssl_flag":true,
132  "service_type":"proxy"
133 }
134 EOF</span>
135 </code></pre></notextile>
136
137 h2. Run Keepproxy
138
139 h3. Start the service (option 1: systemd)
140
141 If your system does not use systemd, skip this section and follow the "runit instructions":#runit instead.
142
143 If your system uses systemd, the keepproxy service should already be set up. Start it and check its status:
144
145 <notextile>
146 <pre><code>~$ <span class="userinput">sudo systemctl restart keepproxy</span>
147 ~$ <span class="userinput">sudo systemctl status keepproxy</span>
148 &#x25cf; keepproxy.service - Arvados Keep Proxy
149    Loaded: loaded (/lib/systemd/system/keepproxy.service; enabled)
150    Active: active (running) since Tue 2019-07-23 09:33:47 EDT; 3 weeks 1 days ago
151      Docs: https://doc.arvados.org/
152  Main PID: 1150 (Keepproxy)
153    CGroup: /system.slice/keepproxy.service
154            └─1150 /usr/bin/keepproxy
155 [...]
156 </code></pre>
157 </notextile>
158
159 h3(#runit). Start the service (option 2: runit)
160
161 Install runit to supervise the Keep-web daemon.  {% include 'install_runit' %}
162
163 h3. Testing keepproxy
164
165 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).
166
167 Install the "Python SDK":{{site.baseurl}}/sdk/python/sdk-python.html
168
169 @ARVADOS_API_HOST@ and @ARVADOS_API_TOKEN@ must be set in the environment.
170
171 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.