From 2c4c955a7b0c2c1e9d2b19372b6f095ec8f89d5d Mon Sep 17 00:00:00 2001 From: Saurabh Shrihar Date: Mon, 14 Oct 2024 16:47:48 +0400 Subject: [PATCH] Deployment fix for invalid url to return 404 --- Dockerfile.review | 2 +- build_branches.py | 2 +- nginx.conf | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Dockerfile.review b/Dockerfile.review index 6743b610f..a7d6f1d35 100755 --- a/Dockerfile.review +++ b/Dockerfile.review @@ -5,4 +5,4 @@ COPY app /app WORKDIR /app EXPOSE 80 -CMD ["nginx", "-g", "daemon off;"] +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/build_branches.py b/build_branches.py index 4394bb47f..5cca1b446 100755 --- a/build_branches.py +++ b/build_branches.py @@ -160,7 +160,7 @@ def update_nginx_config(pr_numbers, parsed_env): for pr_number in pr_numbers: location_block = f"""location /{pr_number} {{ alias /app/{pr_number}; - try_files $uri $uri/ /index.html; + try_files $uri $uri/ =404; error_page 404 /404.html; }} """ diff --git a/nginx.conf b/nginx.conf index 97cba0b75..5e69e6676 100644 --- a/nginx.conf +++ b/nginx.conf @@ -15,10 +15,11 @@ http { listen 80; #REPLACE_APPS + location / { - alias /app/#environment/; + root /app/#environment; index index.html; - try_files $uri $uri/ /index.html; + try_files $uri $uri/ /404.html; error_page 404 /404.html; } }