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