diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..afdd7a7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,24 @@ +version: "2" + +services: + frontend: + image: nginx:stable + volumes: + - ./nginx:/etc/nginx/conf.d/ + - ./build:/www + links: + - backend + ports: + - "80:80" + - "443:443" + + backend: + image: villasweb-backend + links: + - database + + database: + image: mongo:latest + volumes: + - /opt/database:/data/db + diff --git a/nginx/villas.conf b/nginx/villas.conf new file mode 100644 index 0000000..f3417de --- /dev/null +++ b/nginx/villas.conf @@ -0,0 +1,32 @@ +server { + listen 80 default_server; + server_name VILLASweb; + + # backend location + location /api/ { + proxy_redirect off; + proxy_set_header Host $http_host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + # rewrite url to exclude /api on context broker side + rewrite ^/api/?(.*) /api/v1/$1 break; + + proxy_pass http://backend:4000/; + } + + # frontend location + location / { + root /www; + } + + # error pages + error_page 404 /404.html; + location = /404.html { + root /usr/share/nginx/html; + } + + error_page 500 502 503 504 50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +}