Proxying right in FE config

Change-Id: I745f756f583a874284478cf07e3d9b3f99fe9dcf
diff --git a/Dockerfile b/Dockerfile
index c09541a..3fef3f0 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -16,18 +16,28 @@
 RUN ./install_node.sh
 RUN apt-get install -y nodejs
 
-# Add the app
-COPY ${CODE_SOURCE} ${CODE_DEST}
+# Add the app deps
+COPY ${CODE_SOURCE}/package.json ${CODE_DEST}/package.json
+COPY ${CODE_SOURCE}/typings.json ${CODE_DEST}/typings.json
 
 # Install Deps
 WORKDIR ${CODE_DEST}
-RUN npm install 
+RUN npm install
 RUN npm run typings
 
-# Override nginx configutaion
+# Create folder for logs
 RUN mkdir -p /var/log/nginx/log
-RUN mv ${CODE_SOURCE}/nginx.conf /etc/nginx/conf.d/default.conf
 
 # Build the app
 EXPOSE 4000
-RUN npm run build
\ No newline at end of file
+COPY ${CODE_SOURCE}/conf ${CODE_DEST}/conf
+COPY ${CODE_SOURCE}/gulp_tasks ${CODE_DEST}/gulp_tasks
+COPY ${CODE_SOURCE}/src ${CODE_DEST}/src
+COPY ${CODE_SOURCE}/gulpfile.js ${CODE_DEST}/gulpfile.js
+COPY ${CODE_SOURCE}/tsconfig.json ${CODE_DEST}/tsconfig.json
+COPY ${CODE_SOURCE}/tslint.json ${CODE_DEST}/tslint.json
+RUN npm run build
+
+# Override nginx configutaion
+COPY ${CODE_SOURCE}/nginx.conf ${CODE_DEST}/nginx.conf
+RUN mv ${CODE_SOURCE}/nginx.conf /etc/nginx/conf.d/default.conf
diff --git a/conf/app/app.config.production.ts b/conf/app/app.config.production.ts
index b1a1b7d..63c19f3 100644
--- a/conf/app/app.config.production.ts
+++ b/conf/app/app.config.production.ts
@@ -1,5 +1,5 @@
 import {IAppConfig} from './interfaces';
 export const AppConfig: IAppConfig = {
     apiEndpoint: '/spa/api',
-    websocketClient: '/spa'
+    websocketClient: '/'
 };
diff --git a/conf/webpack-dist.conf.js b/conf/webpack-dist.conf.js
index 9e0f3c9..a59ff69 100644
--- a/conf/webpack-dist.conf.js
+++ b/conf/webpack-dist.conf.js
@@ -56,7 +56,11 @@
       mangle: false // NOTE mangling was breaking the build
     }),
     new ExtractTextPlugin('index-[contenthash].css'),
-    new webpack.optimize.CommonsChunkPlugin({name: 'vendor'})
+    new webpack.optimize.CommonsChunkPlugin({name: 'vendor'}),
+    new webpack.ProvidePlugin({
+      $: "jquery",
+      jQuery: "jquery"
+    })
   ],
   postcss: () => [autoprefixer],
   output: {
diff --git a/nginx.conf b/nginx.conf
index 6150ae8..1e5b404 100644
--- a/nginx.conf
+++ b/nginx.conf
@@ -4,26 +4,31 @@
 
     #charset koi8-r;
     access_log  /var/log/nginx/log/xos-spa-gui.access.log  main;
-    error_log  /var/log/nginx/log/xos-spa-gui.error.log  warn;
+    error_log  /var/log/nginx/log/xos-spa-gui.error.log  debug;
 
     location / {
-        root   /var/www/dist;
-        index  index.html index.htm;
+       root   /var/www/dist;
+       index  index.html index.htm;
     }
 
     # Redirect for FE config
-    location /spa {
-        root   /var/www/dist;
-        index  index.html index.htm;
+
+    location /spa/ {
+        rewrite ^/spa/(.*)$ /$1;
     }
 
-    location /spa/api {
+    location /api {
         resolver 127.0.0.1 valid=30s;
-        proxy_pass http://xos-rest-gw:3000;
+        proxy_pass      http://xos-rest-gw:3000;
+        # proxy_redirect  http://xos-rest-gw:3000/spa /;
     }
 
-    location /spa/socket.io {
+    location /socket.io {
         resolver 127.0.0.1 valid=30s;
-        proxy_pass http://xos-rest-gw:3000;
+        proxy_pass      http://xos-rest-gw:3000;
+        # proxy_redirect  http://xos-rest-gw:3000/spa /;
+        proxy_http_version 1.1;
+        proxy_set_header Upgrade $http_upgrade;
+        proxy_set_header Connection "upgrade";
     }
 }
\ No newline at end of file