Skip to content

Commit

Permalink
secfit
Browse files Browse the repository at this point in the history
  • Loading branch information
mauritzs committed Mar 4, 2025
1 parent 95148a6 commit 1919ddc
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 11 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/deploy_test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Deploy to TDT4242 server development

on:
push:
branches:
- main
workflow_dispatch:
inputs:
config:
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/update_primary_nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ http {
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}
}
35 changes: 35 additions & 0 deletions nginx_secfit.conf
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit 1919ddc

Please sign in to comment.