Skip to content

Commit

Permalink
nginx config overwrite for react app index/refresh fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc23007 committed Nov 17, 2024
1 parent 1dad00a commit d2bb43f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ RUN npm run build

# Step 2: Serve the app using NGINX
FROM nginxinc/nginx-unprivileged:mainline
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
COPY --from=build /usr/src/app/dist /usr/share/nginx/html
EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]
27 changes: 27 additions & 0 deletions nginx/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
server {
listen 8080;
server_name localhost;

#access_log /var/log/nginx/host.access.log main;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

# react app specific
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.html break;
}
}
}

0 comments on commit d2bb43f

Please sign in to comment.