-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
proxyicann
executable file
·50 lines (41 loc) · 884 Bytes
/
proxyicann
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
#!/bin/bash
domain=$1
url=$2
# Check if args passed
if [ -z "$1" ]
then
# Ask for domain name
echo "Domain name:"
read domain
fi
if [ -z "$2" ]
then
# Ask for domain name
echo "URL:"
read url
fi
# Install nginx
sudo apt update
sudo apt-get install nginx certbot python3-certbot-nginx -y
# Setup NGINX config
printf "server {
listen 80;
listen [::]:80;
server_name $domain;
proxy_ssl_server_name on;
location / {
proxy_set_header X-Real-IP \$remote_addr;
proxy_pass $url;
}
}" > /etc/nginx/sites-available/$domain
sudo ln -s /etc/nginx/sites-available/$domain /etc/nginx/sites-enabled/$domain
# LetsEncrypt SSL Certificate
sudo certbot --nginx -d $domain
# Add cert renewal to cron
crontab -l > cron
printf "0 12 * * * /usr/bin/certbot renew --quiet
" > cron
crontab cron
rm cron
# Restart to apply config file
sudo systemctl restart nginx