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] 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