diff --git a/demo-docker/docker-compose.yaml b/demo-docker/docker-compose.yaml index d919e66e..4f9a32e9 100644 --- a/demo-docker/docker-compose.yaml +++ b/demo-docker/docker-compose.yaml @@ -274,6 +274,7 @@ services: - JS_IP_BIND=0.0.0.0 - JS_HTTP_PORT=8080 - JS_GRAFANA_SERVER=http://grafana:3000 + - JS_LOGIO_SERVER=http://dozzle:6688 - PGPORT=5432 - PGHOST=jsdemo_timescaledb - PGDATABASE=json_scada @@ -281,9 +282,6 @@ services: - PGPASSWORD= volumes: - ../src/server_realtime_auth:/server_realtime_auth - #- ../src/htdocs:/htdocs - #- ../src/htdocs-admin:/htdocs-admin - #- ../src/htdocs-login:/htdocs-login - ../src/AdminUI:/AdminUI - ../svg:/svg - ./conf:/conf @@ -291,6 +289,7 @@ services: links: - jsdemo_mongorsn1 - grafana + - dozzle # exports the HTTP port to the main host ports: - 8080:8080 @@ -400,6 +399,24 @@ services: networks: - jsdemo_net + # monitoring of logs of the docker containers + dozzle: + container_name: dozzle + image: amir20/dozzle:latest + volumes: + - /var/run/docker.sock:/var/run/docker.sock + environment: + - DOZZLE_ADDR=0.0.0.0:6688 + - DOZZLE_BASE=/log-io + - DOZZLE_NO_ANALYTICS=true + # - DOZZLE_LEVEL=debug + ports: + - 6688:6688 + expose: + - "6688" + networks: + - jsdemo_net + networks: jsdemo_net: driver: bridge diff --git a/src/server_realtime_auth/app/routes/user.routes.js b/src/server_realtime_auth/app/routes/user.routes.js index 93882559..168d4ef6 100644 --- a/src/server_realtime_auth/app/routes/user.routes.js +++ b/src/server_realtime_auth/app/routes/user.routes.js @@ -1,7 +1,8 @@ -const path = require('path') const express = require('express') const httpProxy = require('express-http-proxy') -const { legacyCreateProxyMiddleware: createProxyMiddleware } = require('http-proxy-middleware'); +const { + legacyCreateProxyMiddleware: createProxyMiddleware, +} = require('http-proxy-middleware') const { authJwt } = require('../middlewares') const controller = require('../controllers/user.controller') const authController = require('../controllers/auth.controller') @@ -61,7 +62,8 @@ module.exports = function ( httpProxy(metabaseServer) ) - // reverse proxy for log.io + // reverse proxy for log.io on Windows + // for docker it will be used Dozzle app.use( '/log-io', [authJwt.verifyToken], @@ -69,7 +71,12 @@ module.exports = function ( authController.addXWebAuthUser(req) next() }, - httpProxy(logioServer) + logioServer.indexOf('//dozzle') === -1 + ? httpProxy(logioServer) + : createProxyMiddleware({ + target: logioServer, + changeOrigin: true, + }) ) const wsProxy = createProxyMiddleware({ target: logioServer, @@ -86,7 +93,7 @@ module.exports = function ( wsProxy ) app.on('upgrade', wsProxy.upgrade) - app.use('/static', express.static('../log-io/ui/build/static')); + app.use('/static', express.static('../log-io/ui/build/static')) app.post(accessPoint, opcApi) // realtime data API @@ -101,7 +108,7 @@ module.exports = function ( ) app.get(accessPoint + 'test/admin', [authJwt.isAdmin], controller.adminBoard) - + app.use('/svg', [authJwt.verifyToken], express.static('../../svg')) // production @@ -109,7 +116,7 @@ module.exports = function ( app.use('/login', express.static('../AdminUI/dist')) app.use('/dashboard', express.static('../AdminUI/dist')) app.use('/admin', express.static('../AdminUI/dist')) - + // development //app.use('/', httpProxy('localhost:3000/')) //app.use('/login', httpProxy('localhost:3000/'))