From bb4d61435b1c6bb23a4f1ea613dffb1e5115b950 Mon Sep 17 00:00:00 2001 From: Arth <65160206@go.buu.ac.th> Date: Fri, 28 Mar 2025 02:48:49 +0700 Subject: [PATCH] nginx refresh page not 404 --- Dockerfile | 3 +++ default.conf | 11 +++++++++++ nginx.conf | 19 +++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 default.conf create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile index 211bed4..b96babd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,9 @@ RUN npm run build # 👉 Production stage FROM nginx:stable-alpine +COPY default.conf /etc/nginx/conf.d/default.conf +# ❗ถ้าอยากใช้ custom nginx.conf (optional) +# COPY nginx.conf /etc/nginx/nginx.conf # คัดลอกไฟล์ที่ build แล้ว ไปยัง nginx COPY --from=builder /app/dist /usr/share/nginx/html diff --git a/default.conf b/default.conf new file mode 100644 index 0000000..d1da56e --- /dev/null +++ b/default.conf @@ -0,0 +1,11 @@ +server { + listen 80; + server_name localhost; + + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri $uri/ /index.html; + } +} \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..9b2a58f --- /dev/null +++ b/nginx.conf @@ -0,0 +1,19 @@ +user nginx; +worker_processes auto; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + sendfile on; + keepalive_timeout 65; + + include /etc/nginx/conf.d/*.conf; # 🔥 load default.conf จาก conf.d +} \ No newline at end of file -- GitLab