1
1
# AWS Specify Asset Server Setup
2
2
3
3
## EC2 Non-Dockerized Build
4
- ```bash
5
- #!/bin/bash
6
-
7
- sudo apt update;
8
- sudo apt upgrade -y;
9
- sudo apt-get -y install --no-install-recommends \
10
- python3-venv \
11
- python3.8 \
12
- python3.8-dev \
13
- python3-pip \
14
- imagemagick \
15
- ghostscript \
16
- git \
17
- nginx \
18
- certbot \
19
- authbind \
20
- s3fs \
21
- awscli;
22
-
23
- # python 3.6
24
- #sudo apt update
25
- #sudo apt install build-essential checkinstall zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev;
26
- #wget https://www.python.org/ftp/python/3.6.15/Python-3.6.15.tgz;
27
- #tar -xf Python-3.6.15.tgz;
28
- #cd Python-3.6.15 && ./configure --enable-optimizations;
29
- #make -j$(nproc);
30
- #sudo make altinstall;
31
- #python3.6 --version;
32
-
33
- # python 3.6 install with apt
34
- sudo apt install software-properties-common;
35
- sudo add-apt-repository ppa:deadsnakes/ppa;
36
- sudo apt update;
37
- sudo apt install python3.6;
38
- sudo apt-get install python3.6-distutils;
39
-
40
- # install pip3.6
41
- #wget https://bootstrap.pypa.io/pip/3.6/get-pip.py;
42
- python3.6 -m venv --without-pip ve;
43
- source ve/bin/activate;
44
- wget https://bootstrap.pypa.io/get-pip.py;
45
- #wget https://bootstrap.pypa.io/pip/3.5/get-pip.py
46
- #deactivate;
47
-
48
- # activate python3.6 venv
49
- sudo apt install -y python3-virtualenv;
50
- python3.6 -m venv myenv;
51
- source myenv/bin/activate;
52
- pip install --no-cache-dir -r requirements.txt;
53
- #deactivate;
54
-
55
- # TLS dependencies
56
- sudo apt-get -y install --no-install-recommends \
57
- certbot \
58
- python3-certbot-nginx \
59
- software-properties-common;
60
-
61
- # Configure AWS
62
- aws configure set aws_access_key_id "ACCESS_KEY";
63
- aws configure set aws_secret_access_key "ACCESS_KEY_SECRET";
64
- aws configure set default.region us-east-1;
65
- aws configure set default.output json;
66
-
67
- # Import attachment files
68
- #mkdir attachments;
69
- #aws s3 cp s3://specify-cloud/assets-server/attachments/ ~/attachments --recursive;
70
4
71
- # S3 Mounting
72
- mkdir attachments;
73
- s3fs specify-cloud /assets-server/attachments/;
5
+ Make sure to set environment variables before running the bash script
74
6
75
- # Clone asset server repo
76
- git clone https://github.com/specify/web-asset-server.git;
77
- cd ~/web-asset-server;
78
- git checkout arm-build;
79
-
80
- # Build python web asset server
81
- python3.8 -m venv ve;
82
- sudo ve/bin/pip install --no-cache-dir -r requirements.txt
83
- #sudo pip install -r requirements.txt;
84
-
85
- # Port config
86
- # not needed when running with nginx
87
- #sudo apt-get install authbind;
88
- #touch 80;
89
- #chmod u+x 80;
90
- #sudo mv 80 /etc/authbind/byport;
91
-
92
- # Create SystemD service
93
- sudo cat > /etc/systemd/system/web-asset-server.service << EOF
94
- [Unit]
95
- Description=Specify Web Asset Server
96
- Wants=network.target
97
-
98
- [Service]
99
- User=ubuntu
100
- WorkingDirectory=/home/ubuntu/web-asset-server
101
- ExecStart=/home/ubuntu/web-asset-server/ve/bin/python /home/ubuntu/web-asset-server/server.py
102
- Restart=always
103
-
104
- [Install]
105
- WantedBy=multi-user.target
106
-
107
- EOF
108
-
109
- sudo systemctl daemon-reload;
110
- sudo systemctl enable web-asset-server.service;
111
- sudo systemctl start web-asset-server.service;
112
- sudo systemctl status web-asset-server.service;
113
-
114
- # nginx
115
- # sudo vim etc/nginx/sites-enabled/assets.conf
116
- sudo rm -f /etc/nginx/sites-enabled/default;
117
- sudo nginx -t;
118
- sudo /etc/init.d/nginx reload;
119
-
120
- # S3 Mounting
121
- mount -o discard,defaults,noatime /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01 /mnt/volume-nyc1-01
122
-
123
- # TODO: EFS Mounting
124
-
125
- # Certbot TLS config
126
- sudo mkdir /var/www/.well-known;
127
- sudo certbot --nginx -d assets-test.specifycloud.org -d assets-test.specifycloud.org;
128
- sudo ls -la /etc/letsencrypt/live/assets-test.specifycloud.org;
129
- #openssl dhparam -out /etc/nginx/dhparam.pem 4096;
130
- sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 4096; #2048 or 1024
131
- sudo openssl dhparam -dsaparam -out /etc/ssl/certs/dhparam.pem 1024;
132
- # add https server config to nginx assets.
133
-
134
- # Edit
7
+ ```command line
8
+ export DOMAIN_NAME <domain name>
9
+ export SUBDOMAIN_PREFIX <first section of subdomain>
135
10
```
136
11
12
+ [build_non_docker_asset_server.sh](../scripts/build_non_docker_asset_server.sh) to build the instance.
13
+
137
14
## Config files
15
+
16
+ Make sure to set environment variables
138
17
/etc/systemd/system/web-asset-server.service ->
139
18
```
140
19
[Unit]
@@ -185,7 +64,7 @@ ALLOW_STATIC_FILE_ACCESS = True
185
64
# These values are interpolated into the web_asset_store.xml resource
186
65
# so the client knows how to talk to the server.
187
66
#HOST = 'localhost'
188
- HOST = 'assets-test.specifycloud.org '
67
+ HOST = 'subdomain.domain.name '
189
68
PORT = 8080
190
69
#PORT = 80
191
70
@@ -228,7 +107,7 @@ CAN_THUMBNAIL = {'image/jpeg', 'image/gif', 'image/png', 'image/tiff', 'applicat
228
107
SERVER = 'wsgiref' # For testing. Requires no extra packages.
229
108
```
230
109
231
- /etc/nginx/sites-enabled/assets.conf from the aasets1.specifycloud.org - ->
110
+ /etc/nginx/sites-enabled/assets.conf from the subdomain.domain.name - ->
232
111
```
233
112
# Nginx configuration for supplying an HTTPS end point for the web
234
113
# asset server. The asset server is running on the same system
@@ -241,7 +120,7 @@ SERVER = 'wsgiref' # For testing. Requires no extra packages.
241
120
server {
242
121
# HTTP access is needed for Specify 6. It will not work with HTTPS.
243
122
listen 80 default_server;
244
- server_name assets1.specifycloud.org ;
123
+ server_name subdomain.domain.name ;
245
124
client_max_body_size 0;
246
125
247
126
# The LetsEncrypt certificate mechanism places a nonce
@@ -258,7 +137,7 @@ server {
258
137
# it defines point to this proxy.
259
138
location = /web_asset_store.xml {
260
139
proxy_pass http://localhost:8080/web_asset_store.xml;
261
- sub_filter 'http://assets1.specifycloud.org :8080' 'http://assets1.specifycloud.org ';
140
+ sub_filter 'http://subdomain.domain.name :8080' 'http://subdomain.domain.name ';
262
141
sub_filter_once off;
263
142
sub_filter_types text/xml;
264
143
}
@@ -273,11 +152,11 @@ server {
273
152
server {
274
153
# This stanza defines the HTTPS end point.
275
154
listen 443 ssl default_server;
276
- server_name assets1.specifycloud.org ;
155
+ server_name subdomain.domain.name ;
277
156
client_max_body_size 0;
278
157
279
- ssl_certificate /etc/letsencrypt/live/assets1.specifycloud.org /fullchain.pem;
280
- ssl_certificate_key /etc/letsencrypt/live/assets1.specifycloud.org /privkey.pem;
158
+ ssl_certificate /etc/letsencrypt/live/subdomain.domain.name /fullchain.pem;
159
+ ssl_certificate_key /etc/letsencrypt/live/subdomain.domain.name /privkey.pem;
281
160
282
161
# from https://cipherli.st/
283
162
# and https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
@@ -311,7 +190,7 @@ server {
311
190
# to use HTTPS in addition to changing the port.
312
191
location = /web_asset_store.xml {
313
192
proxy_pass http://localhost:8080/web_asset_store.xml;
314
- sub_filter 'http://assets1.specifycloud.org :8080' 'https://assets1.specifycloud.org ';
193
+ sub_filter 'http://subdomain.domain.name :8080' 'https://subdomain.domain.name ';
315
194
sub_filter_once off;
316
195
sub_filter_types text/xml;
317
196
}
@@ -323,15 +202,15 @@ server {
323
202
}
324
203
```
325
204
326
- /etc/letsencrypt/renewal/assets1.specifycloud.org .conf ->
205
+ /etc/letsencrypt/renewal/subdomain.domain.name .conf ->
327
206
```
328
207
# renew_before_expiry = 30 days
329
- cert = /etc/letsencrypt/live/assets1.specifycloud.org /cert.pem
330
- privkey = /etc/letsencrypt/live/assets1.specifycloud.org /privkey.pem
331
- chain = /etc/letsencrypt/live/assets1.specifycloud.org /chain.pem
332
- fullchain = /etc/letsencrypt/live/assets1.specifycloud.org /fullchain.pem
208
+ cert = /etc/letsencrypt/live/subdomain.domain.name /cert.pem
209
+ privkey = /etc/letsencrypt/live/subdomain.domain.name /privkey.pem
210
+ chain = /etc/letsencrypt/live/subdomain.domain.name /chain.pem
211
+ fullchain = /etc/letsencrypt/live/subdomain.domain.name /fullchain.pem
333
212
version = 1.9.0
334
- archive_dir = /etc/letsencrypt/archive/assets1.specifycloud.org
213
+ archive_dir = /etc/letsencrypt/archive/subdomain.domain.name
335
214
336
215
# Options and defaults used in the renewal process
337
216
[renewalparams]
@@ -340,18 +219,13 @@ account = a563615cc912ed3d7a3edfede09d6760
340
219
post_hook = systemctl reload nginx
341
220
server = https://acme-v02.api.letsencrypt.org/directory
342
221
[[webroot_map]]
343
- assets1.specifycloud.org = /var/www
222
+ subdomain.domain.name = /var/www
344
223
```
345
224
346
- /etc/ssl/certs/dhparam.pem from assets1.specofycloud.org ->
225
+ /etc/ssl/certs/dhparam.pem from subdomain.domain.name ->
347
226
```
348
227
-----BEGIN DH PARAMETERS-----
349
- MIIBCAKCAQEAlcFKsIuFylwX47jxqbNT0wSVD6ifznsMcti8f7T+zaQQNr84IYIM
350
- pNTT9E6SrVkkJg2u1nGScNqj5lArXvrda6zL66T8WmkFFrGfNW7RYCQ3vpg6BpGs
351
- dJ3+HtWYDNoMbeCrDyMz1DDfX/3OWblTTZRbjpvn/tEgTAn3DexP/QkE9E2c1AUX
352
- Mf/07vWpZ7giemaNgaME3fHDKyReNhTpfg1eDKypUUhEmr+PJmWQ9LQBc12LyXOP
353
- DaFwAJUrqwEqrQP5fEQdOMdh522RwuD2/fPeXTukQHI8gUuMjk652aeLOcn1Ufhy
354
- /KbbV6TJi7wS5F3HVaNXGOLMsHq+CywOCwIBAg==
228
+ ...
355
229
-----END DH PARAMETERS-----
356
230
```
357
231
0 commit comments