07e43a8d733fc5b4f38be7bb54f8f2f5258837a4
[arvados.git] / doc / install / install-keepproxy.html.textile.liquid
1 ---
2 layout: default
3 navsection: installguide
4 title: Install Keepproxy server
5 ...
6
7 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.
8
9 By convention, we use the following hostname for the Keepproxy:
10
11 <div class="offset1">
12 table(table table-bordered table-condensed).
13 |_Hostname_|
14 |keep.@uuid_prefix@.your.domain|
15 </div>
16
17 This hostname should resolve from anywhere on the internet.
18
19 h2. Install Keepproxy
20
21 On Debian-based systems:
22
23 <notextile>
24 <pre><code>~$ <span class="userinput">sudo apt-get install keepproxy</span>
25 </code></pre>
26 </notextile>
27
28 On Red Hat-based systems:
29
30 <notextile>
31 <pre><code>~$ <span class="userinput">sudo yum install keepproxy</span>
32 </code></pre>
33 </notextile>
34
35 Verify that Keepproxy is functional:
36
37 <notextile>
38 <pre><code>~$ <span class="userinput">keepproxy -h</span>
39 Usage of default:
40   -default-replicas=2: Default number of replicas to write if not specified by the client.
41   -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.
42   -no-get=false: If set, disable GET operations
43   -no-put=false: If set, disable PUT operations
44   -pid="": Path to write pid file
45 </code></pre>
46 </notextile>
47
48 h3. Create an API token for the Keepproxy server
49
50 The Keepproxy server needs a token to talk to the API server.
51
52 On the <strong>API server</strong>, use the following command to create the token:
53
54 <notextile>
55 <pre><code>~/arvados/services/api/script$ <span class="userinput">RAILS_ENV=production bundle exec ./get_anonymous_user_token.rb</span>
56 hoShoomoo2bai3Ju1xahg6aeng1siquuaZ1yae2gi2Uhaeng2r
57 </code></pre></notextile>
58
59 h3. Set up the Keepproxy service
60
61 We recommend you run Keepproxy under "runit":http://smarden.org/runit/ or a similar supervisor.  Make sure the launcher sets the envirnoment 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:
62
63 <notextile>
64 <pre><code>ARVADOS_API_TOKEN=<span class="userinput">[generated token]</span> ARVADOS_API_HOST=<span class="userinput">uuid_prefix.your.domain</span> exec keepproxy
65 </code></pre>
66 </notextile>
67
68 h3. Set up a reverse proxy with SSL support
69
70 Because the Keepproxy is intended for access from anywhere on the internet, it is recommended to use SSL for transport encryption.
71
72 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.
73
74 <notextile><pre>
75 upstream keepproxy {
76   server     127.0.0.1:25107  fail_timeout=10s;
77 }
78
79 server {
80   listen       <span class="userinput">[your public IP address]</span>:443 ssl;
81   server_name  <span class="userinput">keep.@uuid_prefix@.your.domain</span>
82
83   ssl on;
84   ssl_certificate           /etc/nginx/keep.example.com-ssl.crt;
85   ssl_certificate_key       /etc/nginx/keep.example.com-ssl.key;
86
87   # Clients need to be able to upload blocks of data up to 64MiB in size.
88   client_max_body_size 64m;
89
90   location / {
91     proxy_pass            http://keepproxy;
92     proxy_redirect        off;
93     proxy_connect_timeout 90;
94     proxy_read_timeout    300;
95
96     proxy_set_header      X-Forwarded-Proto https;
97     proxy_set_header      Host $http_host;
98     proxy_set_header      X-External-Client $external_client;
99     proxy_set_header      X-Real-IP $remote_addr;
100     proxy_set_header      X-Forwarded-For $proxy_add_x_forwarded_for;
101   }
102 }
103 </pre></notextile>
104
105 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.
106
107 h3. Tell the API server about the Keepproxy server
108
109 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>.
110
111 <notextile>
112 <pre><code>~$ <span class="userinput">prefix=`arv --format=uuid user current | cut -d- -f1`</span>
113 ~$ <span class="userinput">echo "Site prefix is '$prefix'"</span>
114 ~$ <span class="userinput">read -rd $'\000' keepservice &lt;&lt;EOF; arv keep_service create --keep-service "$keepservice"</span>
115 <span class="userinput">{
116  "service_host":"<strong>keep.$prefix.your.domain</strong>",
117  "service_port":443,
118  "service_ssl_flag":true,
119  "service_type":"proxy"
120 }
121 EOF</span>
122 </code></pre></notextile>