15572: Documentation WIP
[arvados.git] / doc / install / install-keep-web.html.textile.liquid
1 ---
2 layout: default
3 navsection: installguide
4 title: Install Keep-web 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 # "Introduction":#introduction
13 # "Configure DNS":#introduction
14 # "Update config.yml":#update-config
15 # "Update nginx configuration":#update-nginx
16 # "Install keep-web package":#install-packages
17 # "Start the service":#start-service
18 # "Restart the API server and controller":#restart-api
19 # "Confirm working installation":#confirm-working
20
21 h2(#introduction). Introduction
22
23 The Keep-web server provides read/write HTTP (WebDAV) access to files stored in Keep. It serves public data to unauthenticated clients, and serves private data to clients that supply Arvados API tokens. It can be installed anywhere with access to Keep services, typically behind a web proxy that provides TLS support. See the "godoc page":http://godoc.org/github.com/curoverse/arvados/services/keep-web for more detail.
24
25 By convention, we use the following hostnames for the Keep-web service:
26
27 <notextile>
28 <pre><code>download.<span class="userinput">uuid_prefix</span>.your.domain
29 collections.<span class="userinput">uuid_prefix</span>.your.domain
30 *.collections.<span class="userinput">uuid_prefix</span>.your.domain
31 </code></pre>
32 </notextile>
33
34 The above hostnames should resolve from anywhere on the internet.
35
36 h2(#dns). Configure DNS
37
38 It is important to properly configure the download service to migitate cross-site-scripting (XSS) attacks.  A HTML page can be stored in collection.  If an attacker causes a victim to visit that page through Workbench, it will be rendered by the browser.  If all collections are served at the same domain, the browser will consider collections as coming from the same origin and having access to the same browsing data, enabling malicious Javascript on that page to access Arvados on behalf of the victim.
39
40 Browser security is based on domain names.  We  having separate domains for each collection
41
42
43
44         # Serve preview links using uuid or pdh in subdomain
45         # (requires wildcard DNS and TLS certificate)
46         #   https://*.collections.ClusterID.example.com
47         #
48         # Serve preview links using uuid or pdh in main domain
49         # (requires wildcard DNS and TLS certificate)
50         #   https://*--collections.ClusterID.example.com
51
52
53 limiting preview to circumstances where the collection is not accessed with the user's regular full-access token.
54
55         # Serve preview links by setting uuid or pdh in the path.
56         # This configuration only allows previews of public data or
57         # collection-sharing links, because these use the anonymous
58         # user token or the token is already embedded in the URL.
59         # Other data must be handled as downloads via WebDAVDownload:
60         #   https://collections.ClusterID.example.com
61
62 The configuration option @Services.WebDAV.ExternalURL@ is the base URL for Workbench inline preview.  If blank, use WebDAVDownload instead, and disable inline preview.  If both are empty, downloading collections from workbench will be impossible.
63
64
65
66
67         # Base URL for download links. If blank, serve links to WebDAV
68         # with disposition=attachment query param.  Unlike preview links,
69         # browsers do not render attachments, so there is no risk of XSS.
70         #
71         # If WebDAVDownload is blank, and WebDAV uses a
72         # single-origin form, then Workbench will show an error page
73         #
74         # Serve download links by setting uuid or pdh in the path:
75         #   https://download.ClusterID.example.com
76
77
78 Configure your DNS servers so the following names resolve to your keep-web server's public IP address.
79 * @download.ClusterID.example.com@
80 * @collections.ClusterID.example.com@
81 * @*--collections.ClusterID.example.com@, if you have a wildcard TLS certificate valid for @*.ClusterID.example.com@ and your DNS server allows this without interfering with other DNS names.
82 * @*.collections.ClusterID.example.com@, if you have a wildcard TLS certificate valid for these names.
83
84 If neither of the above wildcard options is feasible, you have two choices:
85 # Serve web content at @collections.ClusterID.example.com@, but only for unauthenticated requests (public data and collection sharing links). Authenticated requests will always result in file downloads, using the @download@ name. For example, the Workbench "preview" button and the "view entire log file" link will invoke file downloads instead of displaying content in the browser window.
86 # In the special case where you know you are immune to XSS exploits, you can enable the "trust all content" mode in Keep-web and Workbench (setting @Collections.TrustAllContent: true@ on the config file). With this enabled, inline web content can be served from a single @collections@ host name; no wildcard DNS or certificate is needed. Do not do this without understanding the security implications described in the "Keep-web documentation":http://godoc.org/github.com/curoverse/arvados/services/keep-web.
87
88 h2(#update-config). Update config.yml
89
90 {% assign railscmd = "bundle exec ./script/get_anonymous_user_token.rb --get" %}
91 {% assign railsout = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" %}
92 If you intend to use Keep-web to serve public data to anonymous clients, configure it with an anonymous token. Use the following command on the <strong>API server</strong> to create an anonymous user token. {% include 'install_rails_command' %}
93
94 Update @Services.WebDAV@ and @Services.WebDAVDownload@ in config.yml:
95
96 <notextile>
97 <pre><code>    Services:
98       WebDAV:
99         InternalURLs:
100           <span class="userinput">"http://collections.<span class="userinput">ClusterID</span>.example.com:9002/": {}</span>
101         ExternalURL: "https://collections.<span class="userinput">ClusterID</span>.example.com"
102       WebDAVDownload:
103         InternalURLs:
104           <span class="userinput">"http://download.<span class="userinput">ClusterID</span>.example.com:9002/": {}</span>
105         ExternalURL: "https://download.<span class="userinput">ClusterID</span>.example.com"
106     Users:
107       AnonymousUserToken: "{{railsout}}"
108     Collections:
109       TrustAllContent: false
110 </code></pre>
111 </notextile>
112
113 Set @Users.AnonymousUserToken: ""@ (empty string) or leave it out if you do not want to serve public data.
114
115 Workbench has features like "download file from collection" and "show image" which work better if the content is served by Keep-web rather than Workbench itself. We recommend using the two different hostnames ("download" and "collections" above) for file downloads and inline content respectively.
116
117 Additionally, one of the following entries on your cluster configuration file (depending on your DNS setup) tells Workbench which URL will be used to serve user content that can be displayed in the browser, like image previews and static HTML pages.
118
119 <notextile>
120 <pre><code>Clusters:
121   <span class="userinput">uuid_prefix</span>:
122     Services:
123       WebDAV:
124         ExternalURL: "https://*--collections.<span class="userinput">uuid_prefix</span>.example.com"
125         ExternalURL: "https://*.collections.<span class="userinput">uuid_prefix</span>.example.com"
126         ExternalURL: "https://collections.<span class="userinput">uuid_prefix</span>.example.com"
127 </code></pre>
128 </notextile>
129
130 h3. Update nginx configuration
131
132 The Keep-web service will be accessible from anywhere on the internet, so we recommend using TLS for transport encryption.
133
134 This is best achieved by putting a reverse proxy with TLS support in front of Keep-web, running on port 443 and passing requests to Keep-web on port 9002 (or whatever port you chose in your run script).
135
136 Note: A wildcard TLS certificate is required in order to support a full-featured secure Keep-web service. Without it, Keep-web can offer file downloads for all Keep data; however, in order to avoid cross-site scripting vulnerabilities, Keep-web refuses to serve private data as web content except when it is accessed using a "secret link" share. With a wildcard TLS certificate and DNS configured appropriately, all data can be served as web content.
137
138 Use a text editor to create a new file @/etc/nginx/conf.d/keep-web.conf@ with the following configuration. Options that need attention are marked with “TODO”.
139
140 <notextile><pre>
141 upstream keep-web {
142   server                127.0.0.1:<span class="userinput">9002</span>;
143 }
144
145 server {
146   listen                <span class="userinput">[TODO: your public IP address]</span>:443 ssl;
147   server_name           download.<span class="userinput">ClusterID</span>.example.com
148                         collections.<span class="userinput">ClusterID</span>.example.com
149                         *.collections.<span class="userinput">ClusterID</span>.example.com
150                         ~.*--collections.<span class="userinput">ClusterID</span>.example.com;
151
152   proxy_connect_timeout 90s;
153   proxy_read_timeout    300s;
154
155   ssl                   on;
156   ssl_certificate       <span class="userinput"/>YOUR/PATH/TO/cert.pem</span>;
157   ssl_certificate_key   <span class="userinput"/>YOUR/PATH/TO/cert.key</span>;
158
159   location / {
160     proxy_pass          http://keep-web;
161     proxy_set_header    Host            $host;
162     proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
163
164     client_max_body_size    0;
165     proxy_http_version      1.1;
166     proxy_request_buffering off;
167   }
168 }
169 </pre></notextile>
170
171 {% include 'notebox_begin' %}
172 If you restrict access to your Arvados services based on network topology -- for example, your proxy server is not reachable from the public internet -- additional proxy configuration might be needed to thwart cross-site scripting attacks that would circumvent your restrictions. Read the "'Intranet mode' section of the Keep-web documentation":https://godoc.org/github.com/curoverse/arvados/services/keep-web#hdr-Intranet_mode now.
173 {% include 'notebox_end' %}
174
175 h2. Install Keep-web package
176
177 Typically Keep-web runs on the same host as Keepproxy.
178
179 h3. Centos 7
180
181 <notextile>
182 <pre><code># <span class="userinput">yum install keepproxy</span>
183 </code></pre>
184 </notextile>
185
186 h3. Debian and Ubuntu
187
188 <notextile>
189 <pre><code># <span class="userinput">apt-get install keepproxy</span>
190 </code></pre>
191 </notextile>
192
193 h2(#start-service). Start the service
194
195 If your system does not use systemd, skip this section and follow the "runit instructions":#runit instead.
196
197 If your system uses systemd, the keep-web service should already be set up. Start it and check its status:
198
199 <notextile>
200 <pre><code>~$ <span class="userinput">sudo systemctl restart keep-web</span>
201 ~$ <span class="userinput">sudo systemctl status keep-web</span>
202 &#x25cf; keep-web.service - Arvados Keep web gateway
203    Loaded: loaded (/lib/systemd/system/keep-web.service; enabled)
204    Active: active (running) since Sat 2019-08-10 10:33:21 UTC; 3 days ago
205      Docs: https://doc.arvados.org/
206  Main PID: 4242 (keep-web)
207    CGroup: /system.slice/keep-web.service
208            └─4242 /usr/bin/keep-web
209 [...]
210 </code></pre>
211 </notextile>