-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathproxy-setup.sh
executable file
·193 lines (159 loc) · 5.3 KB
/
proxy-setup.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/bin/bash
clear
echo -e "\e[1;31m
___ ____ _ _ ____ _ _ _ ____ ___ ____ _ _ ____ ____
/ |___ | | [__ | |\ | [__ | |__| | | |___ |__/
/__ |___ |__| ___] | | \| ___] | | | |___ |___ |___ | \
\e[0m"
echo " "
echo -e "\e[1;33mSelect an option to install & configure: \e[0m"
echo "1. Nginx Proxy Manager"
echo "2. Caddy"
echo "3. Caddy (Docker-Compose)"
echo "4. Exit"
echo " "
read -p "Enter your selection: " chooseproxy
case $chooseproxy in
1)
# Create NPM directory & docker-compose file
mkdir -p /home/$USER/auto-authelia/nginx-proxy-manager
touch /home/$USER/auto-authelia/nginx-proxy-manager/docker-compose.yml
# Appending docker-compose code into the file
echo "version: '3'
services:
app:
image: 'jc21/nginx-proxy-manager:latest'
restart: unless-stopped
ports:
- '80:80'
- '81:81'
- '443:443'
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt" >> /home/$USER/auto-authelia/nginx-proxy-manager/docker-compose.yml
echo " "
echo " "
echo -e "\e[1;33mMake sure you port forward ports 80 and 443 from your router to the device hosting Nginx Proxy Manager\e[0m"
echo " "
echo " "
# Start NPM [Y/N]
read -p "Would you like to start Nginx Proxy Manager via docker-compose? [Y/N] " npmstart
if [ "$npmstart" = y ]; then
echo " "
echo -e "\e[1;33mStarting Nginx Proxy Manager. When launched it will be found at http://YOURIP:81\e[0m"
echo " "
echo " "
cd /home/$USER/auto-authelia/nginx-proxy-manager
docker-compose up -d
echo " "
echo -e "\e[1:32mDone.\e[0m"
elif [ "$npmstart" = n ]; then
echo " "
echo -e "\e[1;31mNot starting Nginx Proxy Manager.\e[0m"
echo " "
else
echo -e "\e[1;31mInvalid command. Not starting Nginx Proxy Manager by default\e[0m."
fi
;;
2)
#Caddy install
echo " "
echo " "
echo -e "\e[1;33mInstalling Caddy. Please wait...\e[0m"
echo " "
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy
echo " "
echo -e "\e[1;32mDone.\e[0m"
echo " "
echo " "
echo -e "\e[1;33mCreating Caddyfile for Caddy...\e[0m"
echo " "
echo " "
touch /home/$USER/auto-authelia/Caddyfile
read -p "Enter the auth root domain [EX: auth.example.com] (SAME AS AUTHELIA SETUP ROOT DOMAIN): " rootauthdomain
echo "$rootauthdomain {
reverse_proxy localhost:9091
}
service.example.com {
forward_auth localhost:9091 {
uri /api/verify?rd=https://$rootauthdomain/
copy_headers Remote-User Remote-Groups Remote-Name Remote-Email
}
reverse_proxy localhost:SERVICEPORTHERE {
}
}" >> /home/$USER/auto-authelia/Caddyfile
echo " "
echo -e "\e[1;32mDone.\e[0m"
echo " "
echo -e "\e[1;33mYou will need to edit the Caddyfile for your services. There is a service.example.com there to provide a example.\e[0m"
echo -e "\e[1;33mVisit the auto-authelia github page for more instructions.\e[0m"
;;
3)
echo " "
echo " "
echo -e "\e[1;33mInstalling Caddy. Please wait...\e[0m"
echo " "
touch /home/$USER/auto-authelia/Caddyfile
mkdir /home/$USER/auto-authelia/caddy
touch /home/$USER/auto-authelia/caddy/docker-compose.yml
echo 'version: "3.7"
services:
caddy:
image: caddy:latest
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "443:443/udp"
volumes:
- /home/$USER/auto-authelia/Caddyfile:/etc/caddy/Caddyfile
- $PWD/site:/srv
- caddy_data:/data
- caddy_config:/config
volumes:
caddy_data:
external: true
caddy_config:' >> /home/$USER/auto-authelia/caddy/docker-compose.yml
read -p "Enter the auth root domain [EX: auth.example.com] (SAME AS AUTHELIA SETUP ROOT DOMAIN): " rootauthdomain
echo "$rootauthdomain {
reverse_proxy localhost:9091
}
service.example.com {
forward_auth localhost:9091 {
uri /api/verify?rd=https://$rootauthdomain/
copy_headers Remote-User Remote-Groups Remote-Name Remote-Email
}
reverse_proxy localhost:SERVICEPORTHERE {
}
}" >> /home/$USER/auto-authelia/Caddyfile
echo " "
echo " "
echo -e "\e[1;33mStart Caddy?\e[0m"
read -p "Answer: " cadstart
if [ "$cadstart" = y ]; then
cd /home/$USER/auto-authelia/caddy
docker-compose up -d
elif [ "$cadstart" = n ]; then
echo -e "\e[1;33mSkipping...\e[0m"
else
echo -e "\e[1;33mSkipping.\e[0m"
fi
echo " "
echo -e "\e[1;32mDone.\e[0m"
echo " "
echo -e "\e[1;33mYou will need to edit the Caddyfile for your services. There is a service.example.com there to provide a example.\e[0m"
echo -e "\e[1;33mVisit the auto-authelia github page for more instructions.\e[0m"
;;
4)
echo " "
echo -e "\e[1;31mExiting...\e[0m"
exit 0
;;
5)
echo -e "\e[1;31mInvalid choice. Please select a valid option.\e[0m"
;;
esac