2960: Merge branch 'main' into 2960-keepstore-streaming
[arvados.git] / doc / install / install-keepproxy.html.textile.liquid
index e800bf45a5d3491d9be18b49eac65eff0c415ce1..20021bd42e539985054f134f6f24f8513069b935 100644 (file)
@@ -3,98 +3,122 @@ layout: default
 navsection: installguide
 title: Install Keepproxy server
 ...
+{% comment %}
+Copyright (C) The Arvados Authors. All rights reserved.
 
-The Keepproxy server is a gateway into your Keep storage. Unlike the Keepstore servers, which are only accessible on the local LAN, Keepproxy is designed to provide secure access into Keep from anywhere on the internet.
+SPDX-License-Identifier: CC-BY-SA-3.0
+{% endcomment %}
 
-By convention, we use the following hostname for the Keepproxy:
+# "Introduction":#introduction
+# "Update config.yml":#update-config
+# "Update nginx configuration":#update-nginx
+# "Install keepproxy package":#install-packages
+# "Start the service":#start-service
+# "Restart the API server and controller":#restart-api
+# "Confirm working installation":#confirm-working
+
+h2(#introduction). Introduction
+
+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:
+* A client writing through Keepproxy sends a single copy of a data block, and Keepproxy distributes copies to the appropriate Keepstore servers.
+* A client can write through Keepproxy without precomputing content hashes.
+* 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.)
+
+By convention, we use the following hostname for the Keepproxy server:
 
 <div class="offset1">
 table(table table-bordered table-condensed).
-|_Hostname_|
-|keep.@uuid_prefix@.your.domain|
+|_. Hostname|
+|@keep.ClusterID.example.com@|
 </div>
 
 This hostname should resolve from anywhere on the internet.
 
-h2. Install Keepproxy
+h2(#update-config). Update config.yml
 
-On Debian-based systems:
+Edit the cluster config at @config.yml@ and set @Services.Keepproxy.ExternalURL@ and @Services.Keepproxy.InternalURLs@.
 
 <notextile>
-<pre><code>~$ <span class="userinput">sudo apt-get install keepproxy</span>
-</code></pre>
+<pre><code>    Services:
+      Keepproxy:
+        ExternalURL: <span class="userinput">https://keep.ClusterID.example.com</span>
+        InternalURLs:
+          <span class="userinput">"http://localhost:25107": {}</span>
+</span></code></pre>
 </notextile>
 
-On Red Hat-based systems:
+h2(#update-nginx). Update Nginx configuration
 
-<notextile>
-<pre><code>~$ <span class="userinput">sudo yum install keepproxy</span>
-</code></pre>
-</notextile>
+Put a reverse proxy with SSL support in front of Keepproxy. Keepproxy itself runs on the port 25107 (or whatever is specified in @Services.Keepproxy.InternalURL@) while the reverse proxy runs on port 443 and forwards requests to Keepproxy.
 
-Verify that Keepproxy is functional:
+Use a text editor to create a new file @/etc/nginx/conf.d/keepproxy.conf@ with the following configuration. Options that need attention are marked in <span class="userinput">red</span>.
 
-<notextile>
-<pre><code>~$ <span class="userinput">keepproxy -h</span>
-Usage of default:
-  -default-replicas=2: Default number of replicas to write if not specified by the client.
-  -listen=":25107": Interface on which to listen for requests, in the format ipaddr:port. e.g. -listen=10.0.1.24:8000. Use -listen=:port to listen on all network interfaces.
-  -no-get=false: If set, disable GET operations
-  -no-put=false: If set, disable PUT operations
-  -pid="": Path to write pid file
-</code></pre>
-</notextile>
+<notextile><pre><code>upstream keepproxy {
+  server                127.0.0.1:<span class="userinput">25107</span>;
+}
 
-It's recommended to run Keepproxy under "runit":http://smarden.org/runit/ or something similar.
+server {
+  listen                  443 ssl;
+  server_name             <span class="userinput">keep.ClusterID.example.com</span>;
 
-h3. Create an API token for the Keepproxy server
+  proxy_connect_timeout   90s;
+  proxy_read_timeout      300s;
+  proxy_set_header        X-Real-IP $remote_addr;
+  proxy_http_version      1.1;
+  proxy_request_buffering off;
+  proxy_max_temp_file_size 0;
 
-The Keepproxy server needs a token to talk to the API server.
+  ssl_certificate     <span class="userinput">/YOUR/PATH/TO/cert.pem</span>;
+  ssl_certificate_key <span class="userinput">/YOUR/PATH/TO/cert.key</span>;
 
-On the <strong>API server</strong>, use the following command to create the token:
+  # Clients need to be able to upload blocks of data up to 64MiB in size.
+  client_max_body_size    64m;
 
-<notextile>
-<pre><code>~/arvados/services/api/script$ <span class="userinput">RAILS_ENV=production ./get_anonymous_user_token.rb</span>
-hoShoomoo2bai3Ju1xahg6aeng1siquuaZ1yae2gi2Uhaeng2r
+  location / {
+    proxy_pass            http://keepproxy;
+  }
+}
 </code></pre></notextile>
 
-The value for the @api_token@ field should be added to Keepproxy's environment as ARVADOS_API_TOKEN. Make sure to also set ARVADOS_API_HOST to @uuid_prefix@.your.domain.
+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.
 
-h3. Set up a reverse proxy with SSL support
+{% assign arvados_component = 'keepproxy' %}
 
-Because the Keepproxy is intended for access from anywhere on the internet, it is recommended to use SSL for transport encryption.
+{% include 'install_packages' %}
 
-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.
+{% include 'start_service' %}
 
-If possible, the proxy should be configured to add CORS headers to its own error responses -- otherwise in-browser applications can't report proxy errors. For example, in nginx >= 1.7.5:
+{% include 'restart_api' %}
 
-<notextile><pre>
-server {
-  server_name keep.example.com
-  ...
-  add_header 'Access-Control-Allow-Methods' 'GET, HEAD, POST, PUT, OPTIONS' always
-  add_header 'Access-Control-Allow-Origin' '*' always
-  add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Length, Content-Type, X-Keep-Desired-Replicas' always
-  add_header 'Access-Control-Max-Age' '86486400' always
-}
-</pre></notextile>
+h2(#confirm-working). Confirm working installation
+
+We recommend using the "Cluster diagnostics tool.":diagnostics.html  Because Keepproxy is specifically a gateway used by outside clients, for this test you should run the diagnostics from a client machine outside the Arvados private network, and provide the @-external-client@ parameter.
+
+Here are some other checks you can perform manually.
+
+Log into a host that is on a network external to your private Arvados network.  The host should be able to contact your keepproxy server (eg @keep.ClusterID.example.com@), but not your keepstore servers (eg keep[0-9].ClusterID.example.com).
+
+@ARVADOS_API_HOST@ and @ARVADOS_API_TOKEN@ must be set in the environment.
+
+@ARVADOS_API_HOST@ should be the hostname of the API server.
 
-*Warning:* Make sure you don't inadvertently add CORS headers for services _other than keepproxy_ while you're doing this.
+@ARVADOS_API_TOKEN@ should be the system root token.
 
-h3. Tell the API server about the Keepproxy server
+Install the "Command line SDK":{{site.baseurl}}/sdk/cli/install.html
 
-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>.
+Check that the keepproxy server is in the @keep_service@ "accessible" list:
 
 <notextile>
-<pre><code>~$ <span class="userinput">prefix=`arv --format=uuid user current | cut -d- -f1`</span>
-~$ <span class="userinput">echo "Site prefix is '$prefix'"</span>
-~$ <span class="userinput">read -rd $'\000' keepservice &lt;&lt;EOF; arv keep_service create --keep-service "$keepservice"</span>
-<span class="userinput">{
- "service_host":"keep.$prefix.your.domain",
- "service_port":443,
- "service_ssl_flag":true,
- "service_type":"proxy"
-}
-EOF</span>
-</code></pre></notextile>
+<pre><code>
+$ <span class="userinput">arv keep_service accessible</span>
+[...]
+</code></pre>
+</notextile>
+
+If keepstore does not show up in the "accessible" list, and you are accessing it from within the private network, check that you have "properly configured the @geo@ block for the API server":install-api-server.html#update-nginx .
+
+Install the "Python SDK":{{site.baseurl}}/sdk/python/sdk-python.html
+
+You should now be able to use @arv-put@ to upload collections and @arv-get@ to fetch collections.  Be sure to execute this from _outside_ the cluster's private network.
 
+{% include 'arv_put_example' %}