Configuring ngnix to proxy request toward the Node server
Change-Id: If9ae80afeef276886f87602d6d973bb30ac19dce
diff --git a/Dockerfile b/Dockerfile
index 72869a7..4b1df3d 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -6,7 +6,7 @@
# Set environment vars
ENV CODE_SOURCE .
ENV CODE_DEST /var/www
-ENV VHOST /usr/share/nginx/html
+ENV VHOST /var/www/dist
# Install nodeJs
RUN apt-get update
@@ -24,5 +24,5 @@
RUN npm install
RUN npm run build
-# Move the builded code to nginx vhost
-RUN mv ${CODE_DEST}/dist/* ${VHOST}
\ No newline at end of file
+# Override nginx configutaion
+RUN mv ${CODE_SOURCE}/nginx.conf /etc/nginx/conf.d/default.conf
\ No newline at end of file
diff --git a/conf/app/app.config.production.ts b/conf/app/app.config.production.ts
index 2357f77..361db95 100644
--- a/conf/app/app.config.production.ts
+++ b/conf/app/app.config.production.ts
@@ -6,6 +6,6 @@
}
export const AppConfig: IAppConfig = {
- apiEndpoint: 'http://xos-rest-gw:3000/api',
- websocketClient: 'http://xos-rest-gw:3000'
+ apiEndpoint: '/api',
+ websocketClient: ''
};
diff --git a/nginx.conf b/nginx.conf
new file mode 100644
index 0000000..659bb61
--- /dev/null
+++ b/nginx.conf
@@ -0,0 +1,20 @@
+server {
+ listen 80;
+ server_name localhost;
+
+ #charset koi8-r;
+ #access_log /var/log/nginx/log/host.access.log main;
+
+ location / {
+ root /var/www/dist;
+ index index.html index.htm;
+ }
+
+ location /api {
+ proxy_pass http://xos-rest-gw:3000;
+ }
+
+ location /socket.io {
+ proxy_pass http://xos-rest-gw:3000;
+ }
+}
\ No newline at end of file
diff --git a/src/app/core/nav/nav.ts b/src/app/core/nav/nav.ts
index d83f859..d978ef0 100644
--- a/src/app/core/nav/nav.ts
+++ b/src/app/core/nav/nav.ts
@@ -9,6 +9,10 @@
private $state: angular.ui.IStateService,
private navigationService: IXosNavigationService
) {
+ // NOTE we'll need to have:
+ // - Base routes (defined from configuration based on BRAND)
+ // - Autogenerated routes (nested somewhere)
+ // - Service Routes (dynamically added)
this.routes = this.navigationService.query();
}
diff --git a/src/index.ts b/src/index.ts
index bdb09ab..81a0d43 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -47,7 +47,7 @@
return;
}
return {
- label: `${f.name}`,
+ label: `${f.name}`, // TODO confert name to label
prop: f.name
};
})
@@ -77,7 +77,7 @@
_.forEach(models, (m: IModeldef) => {
const state: IXosState = {
parent: 'xos',
- url: `${m.name.toLowerCase()}s`,
+ url: `${m.name.toLowerCase()}s`, // TODO use https://github.com/blakeembrey/pluralize
component: 'xosCrud',
data: {
model: m.name,