diff --git a/Dockerfile b/Dockerfile index 0e269b2..ae39bea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ RUN npm run build # Dockerfile untuk server Nuxt 3 FROM nginx:1.29-alpine -RUN rm -rf /usr/share/nginx/html/* && \ +RUN rm -rf /var/www/html/* && \ rm -f /etc/nginx/conf.d/default.conf # COPY nginx.conf /etc/nginx/conf.d/default.conf COPY nginx.conf /etc/nginx/conf.d/ @@ -23,6 +23,8 @@ COPY --from=builder /app/.output/public /var/www/html RUN chown -R nginx:nginx /var/www/html && \ chmod -R 755 /var/www/html +RUN ln -s /var/www/html /usr/share/nginx/html + EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] diff --git a/nginx.conf b/nginx.conf index 7b4381c..15034d7 100644 --- a/nginx.conf +++ b/nginx.conf @@ -2,19 +2,20 @@ server { listen 80; server_name localhost; - root /usr/share/nginx/html; + root /var/www/html; index index.html; location / { - try_files $uri $uri/ =404; + try_files $uri $uri/ /index.html; } - - location = / { - try_files /index.html =404; - } - - location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { - expires max; + + location /_nuxt/ { + expires 1y; add_header Cache-Control "public"; } + + location = /index.html { + expires -1; + add_header Cache-Control "no-store"; + } }