summaryrefslogtreecommitdiff
path: root/public/fs/etc/nginx/vhosts.d/nginx-primary-zone-cfg.sh
blob: 4942233af990a03214f88799eef674a87e6699ae (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
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh

set -eu

IFS=','

sitezone="$1"; shift;
cfg_script="$0"
cfg_srcdir=$(cd -- "${cfg_script%/*}/" ; pwd -P)

# header
cat << _EOF
server {
    listen                [::]:80;
    server_name           ${sitezone};
    return                301 https://\$server_name\$request_uri;
}

server {
    listen                [::]:443;
    server_name           ${sitezone};

_EOF

# indexed locations
for sitedir in $@; do

cat << _EOF
    location /${sitedir} {
        root              /srv/www/htdocs/\$host;
        autoindex         on;
        ssi               on;
    }

_EOF

done

# root directory
cat << _EOF
    location / {
        root              /srv/www/htdocs/\$host;
        index             index.xhtml index.html index.htm;
        ssi               on;
        ssi_types         application/xhtml+xml;
    }

_EOF

# ssl and footer
cat << _EOF
    ssl_certificate           /srv/webroot/${sitezone}/ssl/fullchain.pem;
    ssl_certificate_key       /srv/webroot/${sitezone}/ssl/privkey.pem;
    ssl_trusted_certificate   /srv/webroot/${sitezone}/ssl/chain.pem;

    include conf.d/ssl_params;
}
_EOF