-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathproxy-domain-add.sh
executable file
·42 lines (30 loc) · 1.14 KB
/
proxy-domain-add.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
#!/usr/bin/env bash
echo "Insert your domain address..."
read domain
echo "Insert proxy pass address..."
read proxy_pass_address
echo "Insert your SSL keys file name (collected from certbot)..."
read ssl_key_name
echo "Select a configuration..."
configurations=( proxy-with-www proxy-without-www )
select config in "${configurations[@]}"; do
echo "You have chosen $config"
break
done
echo "Creating nginx virtual host file..."
sudo cp ${PWD}/nginx/${config}.conf /etc/nginx/sites-available/${domain}.conf
sudo sed -i "s%domain%${domain}%g" /etc/nginx/sites-available/${domain}.conf
echo "Domain name set..."
sudo sed -i "s%proxy_pass_address%${proxy_pass_address}%g" /etc/nginx/sites-available/${domain}.conf
echo "Proxy pass address set..."
sudo sed -i "s%ssl_key_name%${ssl_key_name}%g" /etc/nginx/sites-available/${domain}.conf
echo "SSL set..."
if [[ ! -e /etc/nginx/sites-enabled/${domain}.conf ]]
then
sudo ln -s /etc/nginx/sites-available/${domain}.conf /etc/nginx/sites-enabled/${domain}.conf
echo "Symbolic link created..."
fi
echo "Checking configuration..."
sudo nginx -t
echo "Restarting nginx server..."
sudo service nginx restart