add the API to the NGINX server

This commit is contained in:
Andreas Zweili 2020-11-28 01:22:25 +01:00
parent dba05101dd
commit 21a116fbea
3 changed files with 32 additions and 19 deletions

View File

@ -30,4 +30,4 @@ services:
ports:
- 80:80
volumes:
- ./static:/home/app/web/static
- ./static:/home/app/backend/static

View File

@ -16,6 +16,6 @@ COPY --from=build-stage . /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d
ENV PORT = 8080
EXPOSE 8080
ENV PORT = 80
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

View File

@ -1,17 +1,30 @@
server {
listen 8080;
location / {
root /usr/share/nginx/html/app;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
upstream network_inventory {
server backend:8000;
}
server {
listen 80;
location /api/ {
proxy_pass http://network_inventory;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
location /static/ {
alias /home/app/backend/static/;
}
location / {
root /usr/share/nginx/html/app/dist;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}