From 3ba5cc711ff930aea67f76c9ac25df12b249bc94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Mon, 3 Mar 2025 16:33:33 +0100 Subject: [PATCH 01/31] Initial commit --- .env | 2 +- .github/workflows/deploy_test.yml | 9 +++++---- .gitignore | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.env b/.env index bf8f669..c525288 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ -GROUP_ID=00 +GROUP_ID=05 DOMAIN=localhost URL_PREFIX=http:// PORT_PREFIX=2 diff --git a/.github/workflows/deploy_test.yml b/.github/workflows/deploy_test.yml index a14f485..ea79766 100644 --- a/.github/workflows/deploy_test.yml +++ b/.github/workflows/deploy_test.yml @@ -19,10 +19,11 @@ jobs: env: REPO_NAME: ${{ github.event.repository.name }} COMPOSE_FILE: ${{ github.event.inputs.config }} - + steps: - name: Checkout repository uses: actions/checkout@v3 + - name: Dotenv Action uses: falti/dotenv-action@v1.1.4 with: @@ -35,9 +36,9 @@ jobs: docker compose version cd $GITHUB_WORKSPACE docker compose -f $COMPOSE_FILE --verbose config && printf "OK\n" || exit 1 - - - name: Build and run docker image + + - name: Build and run docker image run: docker compose -f $COMPOSE_FILE up --force-recreate --build -d - + - name: Verify that gateway is available run: docker ps diff --git a/.gitignore b/.gitignore index 57dd5eb..60627fd 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ backend/secfit/.vscode/ backend/secfit/*/migrations/__pycache__/ backend/secfit/*/__pycache__/ backend/secfit/db.sqlite3 +.env From f7df476771c2876b2fa9e8649a25d377f878a2ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Mon, 3 Mar 2025 16:44:38 +0100 Subject: [PATCH 02/31] Second commit --- .github/workflows/update_primary_nginx.yml | 29 +++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index 9733e17..91bc87d 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -1,12 +1,15 @@ -name: UNFINISHED - setup nginx from the configuration file +name: Deploy nginx configuration to TDT4242 server on: + push: + branches: + - main workflow_dispatch: jobs: - deploy: + deploy-nginx: runs-on: self-hosted - + steps: - name: Checkout repository uses: actions/checkout@v3 @@ -16,16 +19,14 @@ jobs: export-variables: true keys-case: bypass - - name: Check environment variables - run: env - - #Doesn't work properly, envsubst replaces all instances of $variable and ${variable}, but we want to keep e.g., $host as nginx variables - #- name: Create temporary nginx config file - # run: envsubst < ./nginx_template.txt > temp_default.conf - # Maybe look at https://www.baeldung.com/linux/envsubst-command to get an idea - - - name: Copy temporary file to correct place - run: cp temp_default.conf /etc/nginx/conf.d/default.conf + - name: Deploy nginx configuration file + run: | + sudo cp ./nginx/nginx.conf /etc/nginx/conf.d/default.conf + sudo systemctl reload nginx - name: Show nginx file - run: cat /etc/nginx/conf.d/default.conf + run: | + cat /etc/nginx/conf.d/default.conf + sudo nginx -t + sudo systemctl status nginx + echo "Nginx is running correctly" From d3940fcf3b90e031ecbf134c2ac05008bfa5b881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Mon, 3 Mar 2025 17:12:08 +0100 Subject: [PATCH 03/31] Third commit --- .github/workflows/update_primary_nginx.yml | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index 91bc87d..3a2f957 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -13,20 +13,29 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 - - name: Dotenv Action + + # Setting up env variables + - name: Env variables uses: falti/dotenv-action@v1.1.4 with: export-variables: true keys-case: bypass + # Copying nginx configuration file to the server - name: Deploy nginx configuration file run: | - sudo cp ./nginx/nginx.conf /etc/nginx/conf.d/default.conf + sudo cp ./nginx.conf /etc/nginx/conf.d/nginx.conf + + # Restarting nginx service + - name: Restart nginx service + run: | sudo systemctl reload nginx - - name: Show nginx file + # Test the nginx configuration + - name: Test nginx configuration + run: | + sudo nginx -t + + - name: Show deployed configuration run: | - cat /etc/nginx/conf.d/default.conf - sudo nginx -t - sudo systemctl status nginx - echo "Nginx is running correctly" + cat /etc/nginx/conf.d/nginx.conf From 2f6c728f7d8c4840fa488be82ba12b968c7f1bb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Mon, 3 Mar 2025 17:13:44 +0100 Subject: [PATCH 04/31] Corr: corrected file path --- .github/workflows/update_primary_nginx.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index 3a2f957..8f88b91 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -24,7 +24,7 @@ jobs: # Copying nginx configuration file to the server - name: Deploy nginx configuration file run: | - sudo cp ./nginx.conf /etc/nginx/conf.d/nginx.conf + sudo cp ./nginx/nginx.conf /etc/nginx/conf.d/nginx.conf # Restarting nginx service - name: Restart nginx service From 6d10649834646315a1ce906a9e6c80f9940f9bd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Mon, 3 Mar 2025 17:43:08 +0100 Subject: [PATCH 05/31] Attempted fix --- .github/workflows/update_primary_nginx.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index 8f88b91..532846d 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -21,21 +21,24 @@ jobs: export-variables: true keys-case: bypass + # Test the nginx configuration + - name: Test nginx configuration + run: | + sudo nginx -t + # Copying nginx configuration file to the server - name: Deploy nginx configuration file run: | - sudo cp ./nginx/nginx.conf /etc/nginx/conf.d/nginx.conf + sudo cp ./nginx/nginx.conf /etc/nginx/nginx.conf # Main config + sudo cp ./nginx/nginx.conf /etc/nginx/conf.d/nginx.conf # Server block (if needed) + sudo chown root:root /etc/nginx/nginx.conf + sudo chmod 644 /etc/nginx/nginx.conf # Restarting nginx service - name: Restart nginx service run: | sudo systemctl reload nginx - # Test the nginx configuration - - name: Test nginx configuration - run: | - sudo nginx -t - - name: Show deployed configuration run: | cat /etc/nginx/conf.d/nginx.conf From cec44a770012a1d6b4e047d242ea0298f8c8dddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Mon, 3 Mar 2025 18:17:20 +0100 Subject: [PATCH 06/31] Attempted fix again --- .github/workflows/update_primary_nginx.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index 532846d..352a5ae 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -22,7 +22,7 @@ jobs: keys-case: bypass # Test the nginx configuration - - name: Test nginx configuration + - name: Test nginx configuration file run: | sudo nginx -t From ae7ad5dd9852625840090975965c36e3226e4c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Mon, 3 Mar 2025 18:37:21 +0100 Subject: [PATCH 07/31] Fix: comon please --- .github/workflows/update_primary_nginx.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index 352a5ae..520a617 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -29,10 +29,7 @@ jobs: # Copying nginx configuration file to the server - name: Deploy nginx configuration file run: | - sudo cp ./nginx/nginx.conf /etc/nginx/nginx.conf # Main config - sudo cp ./nginx/nginx.conf /etc/nginx/conf.d/nginx.conf # Server block (if needed) - sudo chown root:root /etc/nginx/nginx.conf - sudo chmod 644 /etc/nginx/nginx.conf + sudo cp ./nginx.conf /etc/nginx/conf.d/nginx.conf # Restarting nginx service - name: Restart nginx service From 95148a6fc7005d4c05d48e3905c26b734decb071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Mon, 3 Mar 2025 18:53:11 +0100 Subject: [PATCH 08/31] Try fix again --- .github/workflows/deploy_test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/deploy_test.yml b/.github/workflows/deploy_test.yml index ea79766..92f116e 100644 --- a/.github/workflows/deploy_test.yml +++ b/.github/workflows/deploy_test.yml @@ -1,6 +1,9 @@ name: Deploy to TDT4242 server development on: + push: + branches: + - main workflow_dispatch: inputs: config: From 1919ddc2666dd09509c6423dec76a2716cfb4102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Tue, 4 Mar 2025 09:32:23 +0100 Subject: [PATCH 09/31] secfit --- .github/workflows/deploy_test.yml | 3 -- .github/workflows/update_primary_nginx.yml | 16 +++++----- nginx/nginx.conf | 2 +- nginx_secfit.conf | 35 ++++++++++++++++++++++ 4 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 nginx_secfit.conf diff --git a/.github/workflows/deploy_test.yml b/.github/workflows/deploy_test.yml index 92f116e..ea79766 100644 --- a/.github/workflows/deploy_test.yml +++ b/.github/workflows/deploy_test.yml @@ -1,9 +1,6 @@ name: Deploy to TDT4242 server development on: - push: - branches: - - main workflow_dispatch: inputs: config: diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index 520a617..1a1ec52 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -14,12 +14,14 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - # Setting up env variables - - name: Env variables - uses: falti/dotenv-action@v1.1.4 - with: - export-variables: true - keys-case: bypass + - name: Load environment variables + run: | + export $(grep -v '^#' .env | xargs) + printenv | grep PORT_PREFIX # Debugging step to see if they are loaded + + - name: Replace environment variables in Nginx config + run: | + envsubst < nginx.conf.template > nginx.conf # Test the nginx configuration - name: Test nginx configuration file @@ -29,7 +31,7 @@ jobs: # Copying nginx configuration file to the server - name: Deploy nginx configuration file run: | - sudo cp ./nginx.conf /etc/nginx/conf.d/nginx.conf + sudo cp ./nginx_secfit.conf /etc/nginx/conf.d/nginx.conf # Restarting nginx service - name: Restart nginx service diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 6cf6f69..131034d 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -46,4 +46,4 @@ http { proxy_set_header X-Forwarded-Proto $scheme; } } -} +} \ No newline at end of file diff --git a/nginx_secfit.conf b/nginx_secfit.conf new file mode 100644 index 0000000..5047f73 --- /dev/null +++ b/nginx_secfit.conf @@ -0,0 +1,35 @@ +# Production server configuration +server { + listen 80; + + location / { + proxy_pass http://0.0.0.0:8080/; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +} + +# Development server configuration +server { + listen 8081; + + location / { + proxy_pass http://0.0.0.0:8081/; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +} + +# Staging server configuration +server { + listen 8082; + + location / { + proxy_pass http://0.0.0.0:8082/; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +} \ No newline at end of file From ec07072fffd79baa4abbd0dee0b900772d8b9d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Tue, 4 Mar 2025 09:47:30 +0100 Subject: [PATCH 10/31] New workflow --- .github/workflows/deploy_dev.yml | 45 ++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/deploy_dev.yml diff --git a/.github/workflows/deploy_dev.yml b/.github/workflows/deploy_dev.yml new file mode 100644 index 0000000..e83cacb --- /dev/null +++ b/.github/workflows/deploy_dev.yml @@ -0,0 +1,45 @@ +name: Deploy to development + +on: + push: + branches: + - main + +jobs: + deploy-dev: + runs-on: self-hosted # Ensure you're using your self-hosted runner + + steps: + - name: Checkout repository + uses: actions/checkout@v3 # Checkout the latest code + + # Optionally, set environment variables (if needed) + - name: Set up environment variables + uses: falti/dotenv-action@v1.1.4 + with: + export-variables: true + keys-case: bypass + + - name: Check environment variables + run: env + + # Stop and remove existing Docker containers + - name: Stop and remove existing containers + run: | + sudo docker compose down || true + + # Pull the latest Docker images (if using remote images) + - name: Pull latest Docker images + run: sudo docker compose pull || true + + # Build Docker images if there are any changes + - name: Build Docker images + run: sudo docker compose build --no-cache + + # Start Docker containers (detached mode) + - name: Start Docker containers + run: sudo docker compose up -d + + # Verify that the containers are running + - name: Verify running Docker containers + run: sudo docker ps -a From 453109ff0bf735b14b7da402c01c9111bc87d5b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Tue, 4 Mar 2025 09:57:25 +0100 Subject: [PATCH 11/31] Fix --- .github/workflows/update_primary_nginx.yml | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index 1a1ec52..ca82e10 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -14,29 +14,29 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Load environment variables - run: | - export $(grep -v '^#' .env | xargs) - printenv | grep PORT_PREFIX # Debugging step to see if they are loaded + - name: Set up environment variables + uses: falti/dotenv-action@v1.1.4 + with: + export-variables: true + keys-case: bypass + + - name: Check environment variables + run: env - - name: Replace environment variables in Nginx config + # Copying nginx configuration file to the server + - name: Deploy nginx configuration file run: | - envsubst < nginx.conf.template > nginx.conf + sudo cp ./nginx_secfit.conf /etc/nginx/conf.d/nginx.conf # Test the nginx configuration - name: Test nginx configuration file run: | sudo nginx -t - # Copying nginx configuration file to the server - - name: Deploy nginx configuration file - run: | - sudo cp ./nginx_secfit.conf /etc/nginx/conf.d/nginx.conf - # Restarting nginx service - name: Restart nginx service run: | - sudo systemctl reload nginx + sudo systemctl restart nginx - name: Show deployed configuration run: | From 6ebc84b99eb3413d42691ecd036f59fa1683296c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Tue, 4 Mar 2025 10:06:57 +0100 Subject: [PATCH 12/31] Attempt again fix --- nginx_secfit.conf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nginx_secfit.conf b/nginx_secfit.conf index 5047f73..04b2ae4 100644 --- a/nginx_secfit.conf +++ b/nginx_secfit.conf @@ -3,7 +3,7 @@ server { listen 80; location / { - proxy_pass http://0.0.0.0:8080/; + proxy_pass http://0.0.0.0:${PROD_PORT_PREFIX}${GATEWAY_POSTFIX}/; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -12,10 +12,10 @@ server { # Development server configuration server { - listen 8081; + listen ${DEV_PORT_PREFIX}7; location / { - proxy_pass http://0.0.0.0:8081/; + proxy_pass http://0.0.0.0:${DEV_PORT_PREFIX}${GATEWAY_POSTFIX}/; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -24,10 +24,10 @@ server { # Staging server configuration server { - listen 8082; + listen ${STAG_PORT_PREFIX}${GATEWAY_POSTFIX}7; location / { - proxy_pass http://0.0.0.0:8082/; + proxy_pass http://0.0.0.0:${STAG_PORT_PREFIX}${GATEWAY_POSTFIX}/; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; From decc1d27475dcf2d87df93fe31066dff52dd5243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Tue, 4 Mar 2025 10:57:53 +0100 Subject: [PATCH 13/31] Fix .env --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 60627fd..48059d3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,4 @@ backend/secfit/.vscode/ backend/secfit/*/migrations/__pycache__/ backend/secfit/*/__pycache__/ -backend/secfit/db.sqlite3 -.env +backend/secfit/db.sqlite3 \ No newline at end of file From c3b3187303398a2afc2e902a1f123ec6e7ac88cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Tue, 4 Mar 2025 11:04:00 +0100 Subject: [PATCH 14/31] Fix --- .github/workflows/update_primary_nginx.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index ca82e10..62e510d 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -20,8 +20,9 @@ jobs: export-variables: true keys-case: bypass - - name: Check environment variables - run: env + - name: Replace environment variables in Nginx config + run: | + envsubst < nginx.conf.template > nginx.conf # Copying nginx configuration file to the server - name: Deploy nginx configuration file From 89d29f0b5dcbff1dc55beccb0320c08ed69aa27e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Tue, 4 Mar 2025 11:09:46 +0100 Subject: [PATCH 15/31] Fix --- .github/workflows/update_primary_nginx.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index 62e510d..3836d92 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -20,10 +20,6 @@ jobs: export-variables: true keys-case: bypass - - name: Replace environment variables in Nginx config - run: | - envsubst < nginx.conf.template > nginx.conf - # Copying nginx configuration file to the server - name: Deploy nginx configuration file run: | From edf100b403ed09144f2bab22d6eb05b781fd0110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Tue, 4 Mar 2025 11:18:45 +0100 Subject: [PATCH 16/31] Try again please --- .github/workflows/update_primary_nginx.yml | 29 ++++++++++++++-------- nginx_template.txt | 2 +- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index 3836d92..7906f2f 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -14,22 +14,31 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Set up environment variables - uses: falti/dotenv-action@v1.1.4 - with: - export-variables: true - keys-case: bypass - - # Copying nginx configuration file to the server - - name: Deploy nginx configuration file + - name: Export environment variables run: | - sudo cp ./nginx_secfit.conf /etc/nginx/conf.d/nginx.conf + export URL_PREFIX=http:// + export PORT_PREFIX=2 + export DEV_POSTFIX=1 + export STAG_POSTFIX=2 + export PROD_POSTFIX=3 + export DEV_PORT_PREFIX=${PORT_PREFIX}${GROUP_ID}${DEV_POSTFIX} + export STAG_PORT_PREFIX=${PORT_PREFIX}${GROUP_ID}${STAG_POSTFIX} + export PROD_PORT_PREFIX=${PORT_PREFIX}${GROUP_ID}${PROD_POSTFIX} + + - name: Replace environment variables in Nginx config + run: | + envsubst < nginx_template > nginx.conf - # Test the nginx configuration + # Test the nginx configuration - name: Test nginx configuration file run: | sudo nginx -t + # Copying nginx configuration file to the server + - name: Deploy nginx configuration file + run: | + sudo cp ./nginx_secfit.conf /etc/nginx/conf.d/nginx.conf + # Restarting nginx service - name: Restart nginx service run: | diff --git a/nginx_template.txt b/nginx_template.txt index 6ff2deb..26926ed 100644 --- a/nginx_template.txt +++ b/nginx_template.txt @@ -12,7 +12,7 @@ server { server { listen ${DEV_PORT_PREFIX}7; location / { - proxy_pass http://0.0.0.0:${DEV_PORT_PREFIX}${GATEWAY_POSTFIX}/; + proxy_pass http://0.0.0.0:${envDEV_PORT_PREFIX}${GATEWAY_POSTFIX}/; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; From ecb30adb02a4c681c20a21aa848b0f3b9a50f0be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Tue, 4 Mar 2025 11:22:27 +0100 Subject: [PATCH 17/31] Please --- .github/workflows/update_primary_nginx.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index 7906f2f..8a11737 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -27,7 +27,7 @@ jobs: - name: Replace environment variables in Nginx config run: | - envsubst < nginx_template > nginx.conf + envsubst < ./nginx_template.txt > ./nginx_secfit.conf # Test the nginx configuration - name: Test nginx configuration file From c875001c96a32696f760d97f32565312f6bcdca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Hardersen=20Skog=C3=B8y?= Date: Tue, 4 Mar 2025 11:29:00 +0100 Subject: [PATCH 18/31] Fix from server --- nginx_secfit.conf | 50 +++++++++++++++++++++------------------------- nginx_template.txt | 2 +- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/nginx_secfit.conf b/nginx_secfit.conf index 04b2ae4..f4c9a36 100644 --- a/nginx_secfit.conf +++ b/nginx_secfit.conf @@ -1,35 +1,31 @@ -# Production server configuration server { - listen 80; + listen 80; - location / { - proxy_pass http://0.0.0.0:${PROD_PORT_PREFIX}${GATEWAY_POSTFIX}/; - proxy_set_header Host $http_host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } + location / { + proxy_pass http://0.0.0.0:23/; + proxy_set_header Host ; + proxy_set_header X-Real-IP ; + proxy_set_header X-Forwarded-For ; + } } -# Development server configuration server { - listen ${DEV_PORT_PREFIX}7; - - location / { - proxy_pass http://0.0.0.0:${DEV_PORT_PREFIX}${GATEWAY_POSTFIX}/; - proxy_set_header Host $http_host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } + listen 217; + location / { + proxy_pass http://0.0.0.0:/; + proxy_set_header Host ; + proxy_set_header X-Real-IP ; + proxy_set_header X-Forwarded-For ; + } } -# Staging server configuration -server { - listen ${STAG_PORT_PREFIX}${GATEWAY_POSTFIX}7; - location / { - proxy_pass http://0.0.0.0:${STAG_PORT_PREFIX}${GATEWAY_POSTFIX}/; - proxy_set_header Host $http_host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } -} \ No newline at end of file +server { + listen 227; + location / { + proxy_pass http://0.0.0.0:22/; + proxy_set_header Host ; + proxy_set_header X-Real-IP ; + proxy_set_header X-Forwarded-For ; + } +} diff --git a/nginx_template.txt b/nginx_template.txt index 26926ed..6ff2deb 100644 --- a/nginx_template.txt +++ b/nginx_template.txt @@ -12,7 +12,7 @@ server { server { listen ${DEV_PORT_PREFIX}7; location / { - proxy_pass http://0.0.0.0:${envDEV_PORT_PREFIX}${GATEWAY_POSTFIX}/; + proxy_pass http://0.0.0.0:${DEV_PORT_PREFIX}${GATEWAY_POSTFIX}/; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; From 74f00bba0fb8bc746d7ca03fd45de4e3dc0d2d18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Hardersen=20Skog=C3=B8y?= Date: Tue, 4 Mar 2025 11:57:40 +0100 Subject: [PATCH 19/31] Fix again --- nginx.conf | 31 ++++++++++++++++++++++++ nginx/nginx.conf | 62 +++++++++++++++++------------------------------- 2 files changed, 53 insertions(+), 40 deletions(-) create mode 100644 nginx.conf diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..158a736 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,31 @@ +server { + listen 80; + + location / { + proxy_pass http://0.0.0.0:23/; + proxy_set_header Host ; + proxy_set_header X-Real-IP ; + proxy_set_header X-Forwarded-For ; + } +} + +server { + listen 217; + location / { + proxy_pass http://0.0.0.0:21/; + proxy_set_header Host ; + proxy_set_header X-Real-IP ; + proxy_set_header X-Forwarded-For ; + } +} + + +server { + listen 227; + location / { + proxy_pass http://0.0.0.0:22/; + proxy_set_header Host ; + proxy_set_header X-Real-IP ; + proxy_set_header X-Forwarded-For ; + } +} diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 131034d..f4c9a36 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -1,49 +1,31 @@ -user nginx; -worker_processes 1; -error_log /var/log/nginx/error.log warn; -pid /var/run/nginx.pid; - - -events { - worker_connections 1024; -} - -http { - server { +server { listen 80; - # Route to frontend location / { - proxy_pass http://frontend:3000; - proxy_set_header Host $http_host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; + proxy_pass http://0.0.0.0:23/; + proxy_set_header Host ; + proxy_set_header X-Real-IP ; + proxy_set_header X-Forwarded-For ; } +} - # Route to backend - location /api/ { - proxy_pass http://backend:8000; - proxy_set_header Host $http_host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; +server { + listen 217; + location / { + proxy_pass http://0.0.0.0:/; + proxy_set_header Host ; + proxy_set_header X-Real-IP ; + proxy_set_header X-Forwarded-For ; } +} - location /admin/ { - proxy_pass http://backend:8000; - proxy_set_header Host $http_host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - } - location /static/admin/ { - proxy_pass http://backend:8000; - proxy_set_header Host $http_host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; +server { + listen 227; + location / { + proxy_pass http://0.0.0.0:22/; + proxy_set_header Host ; + proxy_set_header X-Real-IP ; + proxy_set_header X-Forwarded-For ; } - } -} \ No newline at end of file +} From 7261bfb28b200700216eca5b41636d0dd3e2c9f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Tue, 4 Mar 2025 12:01:30 +0100 Subject: [PATCH 20/31] Fix --- .github/workflows/update_primary_nginx.yml | 15 ++------------- nginx_template.txt | 2 +- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index 8a11737..8d46840 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -14,20 +14,9 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Export environment variables - run: | - export URL_PREFIX=http:// - export PORT_PREFIX=2 - export DEV_POSTFIX=1 - export STAG_POSTFIX=2 - export PROD_POSTFIX=3 - export DEV_PORT_PREFIX=${PORT_PREFIX}${GROUP_ID}${DEV_POSTFIX} - export STAG_PORT_PREFIX=${PORT_PREFIX}${GROUP_ID}${STAG_POSTFIX} - export PROD_PORT_PREFIX=${PORT_PREFIX}${GROUP_ID}${PROD_POSTFIX} - - name: Replace environment variables in Nginx config run: | - envsubst < ./nginx_template.txt > ./nginx_secfit.conf + envsubst '${DEV_PORT_PREFIX} ${PROD_PORT_PREFIX} ${STAG_PORT_PREFIX} ${GATEWAY_POSTFIX}' < nginx_secfit.conf > nginx/nginx.conf # Test the nginx configuration - name: Test nginx configuration file @@ -37,7 +26,7 @@ jobs: # Copying nginx configuration file to the server - name: Deploy nginx configuration file run: | - sudo cp ./nginx_secfit.conf /etc/nginx/conf.d/nginx.conf + sudo cp ./nginx/nginx.conf /etc/nginx/conf.d/nginx.conf # Restarting nginx service - name: Restart nginx service diff --git a/nginx_template.txt b/nginx_template.txt index 26926ed..6ff2deb 100644 --- a/nginx_template.txt +++ b/nginx_template.txt @@ -12,7 +12,7 @@ server { server { listen ${DEV_PORT_PREFIX}7; location / { - proxy_pass http://0.0.0.0:${envDEV_PORT_PREFIX}${GATEWAY_POSTFIX}/; + proxy_pass http://0.0.0.0:${DEV_PORT_PREFIX}${GATEWAY_POSTFIX}/; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; From a9c690f45fe1aa28c44e8e4866579070b3da17e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Tue, 4 Mar 2025 12:05:01 +0100 Subject: [PATCH 21/31] fix error --- nginx_secfit.conf | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/nginx_secfit.conf b/nginx_secfit.conf index f4c9a36..6ff2deb 100644 --- a/nginx_secfit.conf +++ b/nginx_secfit.conf @@ -2,30 +2,30 @@ server { listen 80; location / { - proxy_pass http://0.0.0.0:23/; - proxy_set_header Host ; - proxy_set_header X-Real-IP ; - proxy_set_header X-Forwarded-For ; + proxy_pass http://0.0.0.0:${PROD_PORT_PREFIX}${GATEWAY_POSTFIX}/; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } server { - listen 217; + listen ${DEV_PORT_PREFIX}7; location / { - proxy_pass http://0.0.0.0:/; - proxy_set_header Host ; - proxy_set_header X-Real-IP ; - proxy_set_header X-Forwarded-For ; + proxy_pass http://0.0.0.0:${DEV_PORT_PREFIX}${GATEWAY_POSTFIX}/; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } server { - listen 227; + listen ${STAG_PORT_PREFIX}7; location / { - proxy_pass http://0.0.0.0:22/; - proxy_set_header Host ; - proxy_set_header X-Real-IP ; - proxy_set_header X-Forwarded-For ; + proxy_pass http://0.0.0.0:${STAG_PORT_PREFIX}${GATEWAY_POSTFIX}/; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } From 8ed15dbb43172ad77804649d34f4a6f6a92f6e2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Tue, 4 Mar 2025 12:12:42 +0100 Subject: [PATCH 22/31] Corr --- .github/workflows/update_primary_nginx.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index 8d46840..daeaa91 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -26,7 +26,7 @@ jobs: # Copying nginx configuration file to the server - name: Deploy nginx configuration file run: | - sudo cp ./nginx/nginx.conf /etc/nginx/conf.d/nginx.conf + sudo cp nginx/nginx.conf /etc/nginx/conf.d/nginx.conf # Restarting nginx service - name: Restart nginx service From 1d5a2b50803599ab7d9f42ea1b228407a878d084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Tue, 4 Mar 2025 12:29:02 +0100 Subject: [PATCH 23/31] Changes again to config --- .github/workflows/update_primary_nginx.yml | 16 +----- nginx/nginx.conf | 62 ++++++++++++++-------- 2 files changed, 42 insertions(+), 36 deletions(-) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index daeaa91..3f91bed 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -16,23 +16,11 @@ jobs: - name: Replace environment variables in Nginx config run: | - envsubst '${DEV_PORT_PREFIX} ${PROD_PORT_PREFIX} ${STAG_PORT_PREFIX} ${GATEWAY_POSTFIX}' < nginx_secfit.conf > nginx/nginx.conf - - # Test the nginx configuration - - name: Test nginx configuration file - run: | + envsubst '${DEV_PORT_PREFIX} ${PROD_PORT_PREFIX} ${STAG_PORT_PREFIX} ${GATEWAY_POSTFIX}' < nginx_template.txt > nginx_secfit.conf + sudo mv nginx_secfit.conf /etc/nginx/conf.d/nginx.conf sudo nginx -t - # Copying nginx configuration file to the server - - name: Deploy nginx configuration file - run: | - sudo cp nginx/nginx.conf /etc/nginx/conf.d/nginx.conf - # Restarting nginx service - name: Restart nginx service run: | sudo systemctl restart nginx - - - name: Show deployed configuration - run: | - cat /etc/nginx/conf.d/nginx.conf diff --git a/nginx/nginx.conf b/nginx/nginx.conf index f4c9a36..131034d 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -1,31 +1,49 @@ -server { +user nginx; +worker_processes 1; +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + +http { + server { listen 80; + # Route to frontend location / { - proxy_pass http://0.0.0.0:23/; - proxy_set_header Host ; - proxy_set_header X-Real-IP ; - proxy_set_header X-Forwarded-For ; + proxy_pass http://frontend:3000; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; } -} -server { - listen 217; - location / { - proxy_pass http://0.0.0.0:/; - proxy_set_header Host ; - proxy_set_header X-Real-IP ; - proxy_set_header X-Forwarded-For ; + # Route to backend + location /api/ { + proxy_pass http://backend:8000; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; } -} + location /admin/ { + proxy_pass http://backend:8000; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } -server { - listen 227; - location / { - proxy_pass http://0.0.0.0:22/; - proxy_set_header Host ; - proxy_set_header X-Real-IP ; - proxy_set_header X-Forwarded-For ; + location /static/admin/ { + proxy_pass http://backend:8000; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; } -} + } +} \ No newline at end of file From 57c9957c3ea3a59c1e0c533fe4a95a449ed36230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Tue, 4 Mar 2025 12:30:29 +0100 Subject: [PATCH 24/31] Feat: workflow cp not mv --- .github/workflows/update_primary_nginx.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index 3f91bed..f65aa68 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -17,7 +17,7 @@ jobs: - name: Replace environment variables in Nginx config run: | envsubst '${DEV_PORT_PREFIX} ${PROD_PORT_PREFIX} ${STAG_PORT_PREFIX} ${GATEWAY_POSTFIX}' < nginx_template.txt > nginx_secfit.conf - sudo mv nginx_secfit.conf /etc/nginx/conf.d/nginx.conf + sudo cp nginx_secfit.conf /etc/nginx/conf.d/nginx.conf sudo nginx -t # Restarting nginx service From a04d11931751a0d0defd7bb58636f7bbca82296d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Tue, 4 Mar 2025 12:34:34 +0100 Subject: [PATCH 25/31] Fix: added env variables --- .github/workflows/update_primary_nginx.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index f65aa68..8c18b29 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -14,6 +14,17 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 + - name: export environment variables + run: | + export PORT_PREFIX=2 + export DEV_POSTFIX=1 + export STAG_POSTFIX=2 + export PROD_POSTFIX=3 + export DEV_PORT_PREFIX=${PORT_PREFIX}${GROUP_ID}${DEV_POSTFIX} + export STAG_PORT_PREFIX=${PORT_PREFIX}${GROUP_ID}${STAG_POSTFIX} + export PROD_PORT_PREFIX=${PORT_PREFIX}${GROUP_ID}${PROD_POSTFIX} + export GATEWAY_POSTFIX=6 + - name: Replace environment variables in Nginx config run: | envsubst '${DEV_PORT_PREFIX} ${PROD_PORT_PREFIX} ${STAG_PORT_PREFIX} ${GATEWAY_POSTFIX}' < nginx_template.txt > nginx_secfit.conf From 2c6e154e75e20e8a9b2c719d4cd6cef95e933e99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Tue, 4 Mar 2025 12:37:51 +0100 Subject: [PATCH 26/31] Attempt again --- .github/workflows/update_primary_nginx.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index 8c18b29..f9caae7 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -28,7 +28,13 @@ jobs: - name: Replace environment variables in Nginx config run: | envsubst '${DEV_PORT_PREFIX} ${PROD_PORT_PREFIX} ${STAG_PORT_PREFIX} ${GATEWAY_POSTFIX}' < nginx_template.txt > nginx_secfit.conf + + - name: Copy variables to conf file + run: | sudo cp nginx_secfit.conf /etc/nginx/conf.d/nginx.conf + + - name: Test setup + run: | sudo nginx -t # Restarting nginx service From bf5f571fdf1bd903ea1a7ccdc3d0f4863db88d06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Tue, 4 Mar 2025 12:41:16 +0100 Subject: [PATCH 27/31] Added gruop ID --- .github/workflows/update_primary_nginx.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index f9caae7..1ea6e9b 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -16,6 +16,7 @@ jobs: - name: export environment variables run: | + export GROUP_ID=05 export PORT_PREFIX=2 export DEV_POSTFIX=1 export STAG_POSTFIX=2 From f9dce7dddcc34ebc8b5f5b670584b7d3e95b2d93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Tue, 4 Mar 2025 12:46:11 +0100 Subject: [PATCH 28/31] Add again --- .github/workflows/update_primary_nginx.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index 1ea6e9b..77a92ff 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -26,6 +26,13 @@ jobs: export PROD_PORT_PREFIX=${PORT_PREFIX}${GROUP_ID}${PROD_POSTFIX} export GATEWAY_POSTFIX=6 + - name: Debug Environment Variables + run: | + echo "DEV_PORT_PREFIX=${DEV_PORT_PREFIX}" + echo "STAG_PORT_PREFIX=${STAG_PORT_PREFIX}" + echo "PROD_PORT_PREFIX=${PROD_PORT_PREFIX}" + echo "GATEWAY_POSTFIX=${GATEWAY_POSTFIX}" + - name: Replace environment variables in Nginx config run: | envsubst '${DEV_PORT_PREFIX} ${PROD_PORT_PREFIX} ${STAG_PORT_PREFIX} ${GATEWAY_POSTFIX}' < nginx_template.txt > nginx_secfit.conf From d244fe2700190ee15d5a436c37803df978c455d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauritz=20Skog=C3=B8y?= Date: Tue, 4 Mar 2025 12:52:51 +0100 Subject: [PATCH 29/31] Fix attempt again --- .github/workflows/update_primary_nginx.yml | 33 +++++++++++----------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index 77a92ff..a3477d9 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -14,24 +14,23 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: export environment variables + - name: Export environment variables run: | - export GROUP_ID=05 - export PORT_PREFIX=2 - export DEV_POSTFIX=1 - export STAG_POSTFIX=2 - export PROD_POSTFIX=3 - export DEV_PORT_PREFIX=${PORT_PREFIX}${GROUP_ID}${DEV_POSTFIX} - export STAG_PORT_PREFIX=${PORT_PREFIX}${GROUP_ID}${STAG_POSTFIX} - export PROD_PORT_PREFIX=${PORT_PREFIX}${GROUP_ID}${PROD_POSTFIX} - export GATEWAY_POSTFIX=6 - - - name: Debug Environment Variables - run: | - echo "DEV_PORT_PREFIX=${DEV_PORT_PREFIX}" - echo "STAG_PORT_PREFIX=${STAG_PORT_PREFIX}" - echo "PROD_PORT_PREFIX=${PROD_PORT_PREFIX}" - echo "GATEWAY_POSTFIX=${GATEWAY_POSTFIX}" + export GROUP_ID="05" + export PORT_PREFIX="2" + export DEV_POSTFIX="1" + export STAG_POSTFIX="2" + export PROD_POSTFIX="3" + export GATEWAY_POSTFIX="6" + + export DEV_PORT_PREFIX="${PORT_PREFIX}${GROUP_ID}${DEV_POSTFIX}" + export STAG_PORT_PREFIX="${PORT_PREFIX}${GROUP_ID}${STAG_POSTFIX}" + export PROD_PORT_PREFIX="${PORT_PREFIX}${GROUP_ID}${PROD_POSTFIX}" + + echo "DEV_PORT_PREFIX=$DEV_PORT_PREFIX" >> $GITHUB_ENV + echo "STAG_PORT_PREFIX=$STAG_PORT_PREFIX" >> $GITHUB_ENV + echo "PROD_PORT_PREFIX=$PROD_PORT_PREFIX" >> $GITHUB_ENV + echo "GATEWAY_POSTFIX=$GATEWAY_POSTFIX" >> $GITHUB_ENV - name: Replace environment variables in Nginx config run: | From 26644da8819445529c20d177ca4a1f1fdf2c6722 Mon Sep 17 00:00:00 2001 From: Jolan Date: Tue, 4 Mar 2025 15:22:41 +0100 Subject: [PATCH 30/31] fix: changed file name and last cmd nginx config to match exercises requirements --- .github/workflows/update_primary_nginx.yml | 4 ++-- nginx_secfit.conf => nginx_securefit.conf | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename nginx_secfit.conf => nginx_securefit.conf (100%) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index a3477d9..6758242 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -38,7 +38,7 @@ jobs: - name: Copy variables to conf file run: | - sudo cp nginx_secfit.conf /etc/nginx/conf.d/nginx.conf + sudo cp ./nginx_securefit.conf /etc/nginx/conf.d/nginx.conf - name: Test setup run: | @@ -47,4 +47,4 @@ jobs: # Restarting nginx service - name: Restart nginx service run: | - sudo systemctl restart nginx + sudo systemctl reload nginx diff --git a/nginx_secfit.conf b/nginx_securefit.conf similarity index 100% rename from nginx_secfit.conf rename to nginx_securefit.conf From de49f3e1f230c45461650ab2bea99600201df541 Mon Sep 17 00:00:00 2001 From: Jolan Date: Tue, 4 Mar 2025 15:25:15 +0100 Subject: [PATCH 31/31] fix --- .github/workflows/update_primary_nginx.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_primary_nginx.yml b/.github/workflows/update_primary_nginx.yml index 6758242..55b9ede 100644 --- a/.github/workflows/update_primary_nginx.yml +++ b/.github/workflows/update_primary_nginx.yml @@ -34,7 +34,7 @@ jobs: - name: Replace environment variables in Nginx config run: | - envsubst '${DEV_PORT_PREFIX} ${PROD_PORT_PREFIX} ${STAG_PORT_PREFIX} ${GATEWAY_POSTFIX}' < nginx_template.txt > nginx_secfit.conf + envsubst '${DEV_PORT_PREFIX} ${PROD_PORT_PREFIX} ${STAG_PORT_PREFIX} ${GATEWAY_POSTFIX}' < nginx_template.txt > ./nginx_securefit.conf - name: Copy variables to conf file run: |