blob: 0c51900dd58ce4239d263ebdf4a9379ac2b84958 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#!/bin/sh -ex
# A ship template script
die() { [ "$1" ] && echo "$0: $*" >&2; exit 1; }
[ "$1" ] || die 'host argument missing'
[ -f /etc/alpine-release ] || die 'not on alpinelinux system'
[ "$USER" = root ] || exec doas "$0" "$@"
: Step 1: install dependencies
apk add nginx
: Step 2: Configure
mkdir -p "/var/www/$1/html"
cat <<- EOF > "/var/www/$1/html/index.html"
<!DOCTYPE html>
<html lang="en">
<head>
<title>Server block</title>
</head>
<body>
<h1>Success! The Nginx server block is running!</h1>
</body>
</html>
EOF
chown -R nginx: "/var/www/$1"
cat <<- EOF > "/etc/nginx/http.d/$1.conf"
server {
listen 80;
listen [::]:80;
server_name $1;
root /var/www/$1/html;
access_log /var/log/nginx/$1.access.log;
error_log /var/log/nginx/$1.error.log;
}
EOF
: Step 3: Enable and start
service nginx restart
: Step 4: Test
netstat -tulpn | grep :80
|