From 687c6a6d4e030b9666630c970e1e51c526308a07 Mon Sep 17 00:00:00 2001 From: Stefano Date: Wed, 14 May 2025 23:37:41 -0500 Subject: [PATCH] destroy stack before deploying new one. Created nginx configuration --- .gitea/workflows/aws_deploy_on_push.yml | 2 ++ infrastructure/userdata.sh | 24 +++++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/.gitea/workflows/aws_deploy_on_push.yml b/.gitea/workflows/aws_deploy_on_push.yml index 63ac96c..7f2fb90 100644 --- a/.gitea/workflows/aws_deploy_on_push.yml +++ b/.gitea/workflows/aws_deploy_on_push.yml @@ -32,6 +32,8 @@ jobs: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} aws-region: "us-east-2" + - name: Destroy existing stack + run: cdk destroy --app="python3 ${PWD}/app.py" --force - name: Deploy to AWS run: cdk deploy --app="python3 ${PWD}/app.py" --require-approval=never diff --git a/infrastructure/userdata.sh b/infrastructure/userdata.sh index cecf1fd..16d35e7 100644 --- a/infrastructure/userdata.sh +++ b/infrastructure/userdata.sh @@ -15,15 +15,21 @@ cd iptv-updater-aws pip3 install -r requirements.txt # Create nginx config -# echo 'server { -# listen 80; -# server_name $HOSTNAME; -# location / { -# proxy_pass http://127.0.0.1:8000; -# proxy_set_header Host $host; -# proxy_set_header X-Real-IP $remote_addr; -# } -# }' > /etc/nginx/conf.d/iptvUpdater.conf +echo 'server { + listen 80; + server_name $HOSTNAME; + location / { + proxy_pass http://127.0.0.1:8000; + proxy_set_header Host $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; + } +}' > /etc/nginx/conf.d/iptvUpdater.conf + +# Start nginx service +systemctl enable nginx +systemctl start nginx # Start IptvUpdater on port 8000 nohup uvicorn app.main:app --host 127.0.0.1 --port 8000 /dev/null & \ No newline at end of file