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: ports:
- 80:80 - 80:80
volumes: 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 RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d COPY nginx.conf /etc/nginx/conf.d
ENV PORT = 8080 ENV PORT = 80
EXPOSE 8080 EXPOSE 80
CMD ["nginx", "-g", "daemon off;"] CMD ["nginx", "-g", "daemon off;"]

View File

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