Skip to content

Commit

Permalink
feat: add wildcard ssl certificates (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhijna-Raghavendra authored Jan 14, 2024
2 parents 6b7dac8 + 0ff1f62 commit 5254261
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/backend/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,4 @@ async function deleteMaps(ctx: Context) {
}

export { addMaps, checkUser, deleteMaps, getMaps };

16 changes: 16 additions & 0 deletions src/backend/utils/automate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@ if [ "$arg1" = "-u" ]; then
sudo echo " server {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
server_name $arg3;
location / {
return 307 $arg2;
}
charset utf-8;
client_max_body_size 20M;
ssl_certificate /etc/letsencrypt/live/df.mdgspace.org-0001/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/df.mdgspace.org-0001/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}" > /etc/nginx/sites-available/$arg3.conf;
sudo ln -s /etc/nginx/sites-available/$arg3.conf /etc/nginx/sites-enabled/$arg3.conf;
sudo systemctl reload nginx;
Expand All @@ -45,6 +53,8 @@ elif [ "$arg1" = "-p" ]; then
server {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
server_name $arg3;
location / {
proxy_pass http://localhost:$arg2;
Expand All @@ -54,6 +64,12 @@ elif [ "$arg1" = "-p" ]; then
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
charset utf-8;
client_max_body_size 20M;
ssl_certificate /etc/letsencrypt/live/df.mdgspace.org-0001/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/df.mdgspace.org-0001/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}" > /etc/nginx/sites-available/$arg3.conf;
ln -s /etc/nginx/sites-available/$arg3.conf /etc/nginx/sites-enabled/$arg3.conf;
sudo systemctl reload nginx;
Expand Down
10 changes: 9 additions & 1 deletion src/backend/utils/container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ name=$2-$suffix
env_content=$3
resource=$4
dockerfile=$5
exp_port=$6
exp_port=$6
echo $flag
echo $name
echo $resource
echo $dockerfile
echo $exp_port

available_ports=()

Expand All @@ -34,6 +39,7 @@ done
echo "Available ports: ${available_ports[56]}"
AVAILABLE=0
if [ $flag = "-g" ]; then
echo "hello"
git clone $resource $name
cd $name
touch .env
Expand Down Expand Up @@ -78,6 +84,7 @@ else
" > Dockerfile
sudo docker build -t $name .
sudo docker run -d -p ${available_ports[$AVAILABLE]}:80 $name
sudo rm Dockerfile
cd ..
rm -rf $name
sudo touch /etc/nginx/sites-available/$2.conf
Expand All @@ -101,3 +108,4 @@ else
fi



0 comments on commit 5254261

Please sign in to comment.