From 87d54109ee248b03e8153cc945534570b6ea4b1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Haugen?= Date: Wed, 2 Apr 2025 17:16:00 +0200 Subject: [PATCH] Add nginx deployment workflow and configuration --- .github/workflows/nginx-deploy.yml | 27 +++++++++++++++++++++++++++ nginx_securefit.conf | 14 ++++++++++---- 2 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/nginx-deploy.yml diff --git a/.github/workflows/nginx-deploy.yml b/.github/workflows/nginx-deploy.yml new file mode 100644 index 0000000..7f8feef --- /dev/null +++ b/.github/workflows/nginx-deploy.yml @@ -0,0 +1,27 @@ +name: Deploy Nginx Configuration + +on: + push: + branches: + - main + paths: + - 'nginx_securefit.conf' + - '.github/workflows/nginx-deploy.yml' + +jobs: + deploy-nginx: + runs-on: self-hosted + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Deploy nginx configuration + run: | + sudo cp -v ./nginx_securefit.conf /etc/nginx/conf.d/nginx_securefit.conf + sudo nginx -t + sudo systemctl reload nginx + + - name: Verify nginx configuration + run: | + curl -I http://localhost + sudo systemctl status nginx \ No newline at end of file diff --git a/nginx_securefit.conf b/nginx_securefit.conf index 39db971..e13f6ab 100644 --- a/nginx_securefit.conf +++ b/nginx_securefit.conf @@ -1,10 +1,16 @@ server { - listen 80 default_server; - server_name localhost; + listen 80; + server_name tdt4242-26.idi.ntnu.no; location / { - return 200 "Nginx configuration deployed successfully!"; - add_header Content-Type text/plain; + root /var/www/html; + index index.html; + try_files $uri $uri/ =404; } + + # Add some basic security headers + add_header X-Frame-Options "SAMEORIGIN"; + add_header X-XSS-Protection "1; mode=block"; + add_header X-Content-Type-Options "nosniff"; }