-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-socket-conf.sh
executable file
·58 lines (50 loc) · 1.21 KB
/
create-socket-conf.sh
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/bash
if [[ $# -eq 0 ]] ; then
echo 'Need website name'
exit 0
fi
if [[ $# -eq 1 ]] ; then
echo 'Need website directory'
exit 0
fi
filename="./$1"
sitename=$1
doublesitename=$1
dotcount="$(awk -F'.' '{print NF-1}' <<< $1)"
if [[ $dotcount -eq 1 ]] ; then
doublesitename="$sitename www.$sitename"
fi
cat > /etc/nginx/sites-available/$filename <<- EOM
server {
listen 80;
listen [::]:80;
server_name $doublesitename;
return 301 https://\$server_name\$request_uri;
client_max_body_size 50M;
}
server {
client_max_body_size 50M;
location / {
proxy_set_header Host \$host;
proxy_set_header REMOTE_ADDR \$remote_addr;
proxy_set_header X_FORWARDED_FOR \$remote_addr;
proxy_pass http://unix:/tmp/$sitename.socket;
}
location /static {
alias $2/$sitename/static/;
}
location /uploads {
alias $2/$sitename/uploads/;
}
location /.well-known {
alias /var/www/html/.well-known;
allow all;
}
server_name $doublesitename;
listen 443 ssl http2;
listen [::]:443 ssl http2;
include snippets/ssl-$sitename.conf;
include snippets/ssl-params.conf;
add_header X-Frame-Options DENY;
}
EOM