From bdb50f38e51e0c588582c3927c3376a084f03dc8 Mon Sep 17 00:00:00 2001 From: Arthur Schwaiger Date: Thu, 3 Dec 2020 17:42:16 +0100 Subject: [PATCH] feat: add support for routes in URL (custom nginx config) --- Dockerfile | 5 +++-- nginx.conf | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile index 113f55ac..ad5ef8d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,7 @@ COPY . /app RUN yarn build FROM nginx:alpine -COPY --from=ui-builder /app/dist /usr/share/nginx/html +COPY --from=ui-builder /app/dist /etc/nginx/html +COPY --from=ui-builder /app/nginx.conf /etc/nginx/nginx.conf EXPOSE 80 -CMD ["nginx", "-g", "daemon off;"] +CMD ["nginx"] diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 00000000..22052c92 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,47 @@ +# run nginx in foreground +daemon off; + +#user nobody; +worker_processes 1; + +#error_log logs/error.log; +error_log stderr notice; +#error_log logs/error.log info; + +#pid logs/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + access_log /dev/stdout; + + sendfile on; + + keepalive_timeout 65; + + gzip on; + + server { + listen 80; + server_name localhost; + + location / { + root html; + index index.html index.htm; + # redirect 404 to index + try_files $uri /index.html; + } + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + } +}