Skip to content

Commit

Permalink
Add secondary domain
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-vasconcelos committed Oct 2, 2024
1 parent c11a1bd commit aab160c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ services:
# # # # # # # # # # # # # # # # # # # # #

server:
image: ghcr.io/carrismetropolitana/navegante-proxy:production
image: ghcr.io/carrismetropolitana/navegante-proxy-server:production
deploy:
restart_policy:
condition: on-failure
Expand Down
17 changes: 9 additions & 8 deletions init-letsencrypt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
email="carrismetropolitana@gmail.com"
staging=0 # Set to 1 if you're testing your setup to avoid hitting request limits

api_domain=proxy.api.app.navegante.carrismetropolitana.pt # The primary domain
api_domain_1=proxy.api.app.navegante.carrismetropolitana.pt # The primary domain
api_domain_2=api.app.navegante.pt


# # #
Expand All @@ -22,9 +23,9 @@ curl -s https://raw.githubusercontent.com/certbot/certbot/master/certbot-nginx/c
curl -s https://raw.githubusercontent.com/certbot/certbot/master/certbot/certbot/ssl-dhparams.pem > "./letsencrypt/ssl-dhparams.pem"
echo

echo ">>> Creating dummy certificate for "$api_domain"..."
mkdir -p "./letsencrypt/live/$api_domain"
docker compose run --rm --entrypoint "openssl req -x509 -nodes -newkey rsa:4096 -days 1 -keyout '/etc/letsencrypt/live/$api_domain/privkey.pem' -out '/etc/letsencrypt/live/$api_domain/fullchain.pem' -subj '/CN=localhost'" certbot
echo ">>> Creating dummy certificate for "$api_domain_1"..."
mkdir -p "./letsencrypt/live/$api_domain_1"
docker compose run --rm --entrypoint "openssl req -x509 -nodes -newkey rsa:4096 -days 1 -keyout '/etc/letsencrypt/live/$api_domain_1/privkey.pem' -out '/etc/letsencrypt/live/$api_domain_1/fullchain.pem' -subj '/CN=localhost'" certbot
echo

echo ">>> Rebuilding nginx ..."
Expand All @@ -35,15 +36,15 @@ echo
# # #
# API

echo ">>> Preparing for "$api_domain"..."
echo ">>> Preparing for "$api_domain_1" and "$api_domain_2" ..."

echo ">>> Deleting dummy certificate..."
docker compose run --rm --entrypoint "rm -Rf /etc/letsencrypt/live/$api_domain && rm -Rf /etc/letsencrypt/archive/$api_domain && rm -Rf /etc/letsencrypt/renewal/$api_domain.conf" certbot
docker compose run --rm --entrypoint "rm -Rf /etc/letsencrypt/live/$api_domain_1 && rm -Rf /etc/letsencrypt/archive/$api_domain_1 && rm -Rf /etc/letsencrypt/renewal/$api_domain_1.conf" certbot
echo

echo ">>> Requesting Let's Encrypt certificate for "$api_domain"..."
echo ">>> Requesting Let's Encrypt certificate for "$api_domain_1"..."
if [ $staging != "0" ]; then staging_arg="--staging"; fi # Enable staging mode if needed
docker compose run --rm --entrypoint "certbot certonly --webroot -w /var/www/certbot $staging_arg -d $api_domain --email $email --rsa-key-size 4096 --agree-tos --noninteractive --verbose --force-renewal" certbot
docker compose run --rm --entrypoint "certbot certonly --webroot -w /var/www/certbot $staging_arg -d $api_domain_1 -d $api_domain_2 --email $email --rsa-key-size 4096 --agree-tos --noninteractive --verbose --force-renewal" certbot
echo


Expand Down
4 changes: 2 additions & 2 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ http {

listen 80;
listen [::]:80;
server_name proxy.api.app.navegante.carrismetropolitana.pt;
server_name proxy.api.app.navegante.carrismetropolitana.pt api.app.navegante.pt;
server_tokens off;

location /.well-known/acme-challenge/ {
Expand All @@ -132,7 +132,7 @@ http {

listen 443 ssl;
listen [::]:443 ssl;
server_name proxy.api.app.navegante.carrismetropolitana.pt;
server_name proxy.api.app.navegante.carrismetropolitana.pt api.app.navegante.pt;
server_tokens off;
http2 on;

Expand Down

0 comments on commit aab160c

Please sign in to comment.