Blame public/fs/etc/nginx/vhosts.d/nginx-primary-subdomain-cfg.sh

root@culturestrings 281232
#!/bin/sh
root@culturestrings 281232
root@culturestrings 281232
set -eu
root@culturestrings 281232
root@culturestrings 281232
IFS=','
root@culturestrings 281232
root@culturestrings 94be22
sitesubd="$1"; shift;
root@culturestrings 281232
sitezone="${sitesubd#*.}"
root@culturestrings 281232
sitepref="${sitesubd%%.*}"
root@culturestrings 281232
root@culturestrings 281232
cfg_script="$0"
root@culturestrings 281232
cfg_srcdir=$(cd -- "${cfg_script%/*}/" ; pwd -P)
root@culturestrings 281232
root@culturestrings 281232
# header
root@culturestrings 281232
cat << _EOF
root@culturestrings 281232
server {
root@culturestrings 281232
    listen                [::]:80;
root@culturestrings 281232
    server_name           ${sitesubd};
root@culturestrings 281232
    return                301 https://\$server_name\$request_uri;
root@culturestrings 281232
}
root@culturestrings 281232
root@culturestrings 281232
server {
root@culturestrings 281232
    listen                [::]:443;
root@culturestrings 281232
    server_name           ${sitesubd};
root@culturestrings 281232
root@culturestrings 281232
_EOF
root@culturestrings 281232
root@culturestrings 281232
# indexed locations
root@culturestrings 94be22
for sitedir in $@; do
root@culturestrings 281232
root@culturestrings 281232
cat << _EOF
root@culturestrings 281232
    location /${sitedir} {
root@culturestrings 281232
        root              /srv/www/htdocs/\$host;
root@culturestrings 281232
        fancyindex        on;
root@culturestrings 281232
        ssi               on;
root@culturestrings 281232
    }
root@culturestrings 281232
root@culturestrings 281232
_EOF
root@culturestrings 281232
root@culturestrings 281232
done
root@culturestrings 281232
root@culturestrings 281232
# root directory
root@culturestrings 281232
cat << _EOF
root@culturestrings 281232
    location / {
root@culturestrings 281232
        root              /srv/www/htdocs/\$host;
root@culturestrings 281232
        index             index.html index.htm;
root@culturestrings 281232
        ssi               on;
root@culturestrings 281232
    }
root@culturestrings 281232
root@culturestrings 281232
_EOF
root@culturestrings 281232
root@culturestrings 281232
# ssl and footer
root@culturestrings 281232
cat << _EOF
root@culturestrings 281232
    ssl_certificate           /srv/webroot/${sitezone}/ssl/fullchain.pem;
root@culturestrings 281232
    ssl_certificate_key       /srv/webroot/${sitezone}/ssl/privkey.pem;
root@culturestrings 281232
    ssl_trusted_certificate   /srv/webroot/${sitezone}/ssl/chain.pem;
root@culturestrings 281232
root@culturestrings 281232
    include conf.d/ssl_params;
root@culturestrings 281232
}
root@culturestrings 281232
_EOF