Archived
1
0

🏗️」 wip: Added prodution option for CD

This commit is contained in:
2025-02-07 14:48:34 +01:00
parent 13586ceb1a
commit 0aef0328c1
3 changed files with 36 additions and 12 deletions

View File

@ -1,9 +1,22 @@
#!/bin/sh
if [ ! -f ${NGINX_SSL_KEY_FILE} ]; then
echo "Generating certs"
mkdir -p /etc/nginx/ssl
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ${NGINX_SSL_KEY_FILE} -out ${NGINX_SSL_CERT_FILE} -subj "/C=FR/ST=IDF/L=Angouleme/O=42/OU=42/CN=adjoly.42.fr/UID=adjoly"
else
printf "Key already exist not recreating\n"
if [ ! -v ${PRODUCTION} ]; then
if [ ! -f ${NGINX_SSL_KEY_FILE} ]; then
echo "Generating certs"
mkdir -p /etc/nginx/ssl
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ${NGINX_SSL_KEY_FILE} -out ${NGINX_SSL_CERT_FILE} -subj "/C=FR/ST=IDF/L=Angouleme/O=42/OU=42/CN=adjoly.42.fr/UID=adjoly"
else
printf "Key already exist not recreating\n"
fi
else
printf "Entering production mode for nginx"
INPUT_FILE="/etc/nginx/http.d/www.conf"
OUTPUT_FILE="/etc/nginx/http.d/www.conf"
sed -E '
s/listen\s+443 ssl;/listen 80;/;
s/server_name.*/&\n\tlisten 80;/;
/ssl_certificate/d;
/ssl_certificate_key/d;
/ssl_protocols/d;
/ssl_session_timeout/d;
' "$INPUT_FILE" > "$OUTPUT_FILE"
fi

View File

@ -1,7 +1,7 @@
server {
listen 443 ssl;
server_name adjoly.42.fr www.adjoly.42.fr;
server_name $NGINX_EXPOSED_HOSTS;
root /var/www/html;
index index.php;